Skip to content

Commit b1aaab2

Browse files
Dmitry KasatkinMimi Zohar
authored andcommitted
ima: pass full xattr with the signature
For possibility to use xattr type for new signature formats, pass full xattr to the signature verification function. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
1 parent d3634d0 commit b1aaab2

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎security/integrity/digsig.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ int integrity_digsig_verify(const unsigned int id, const char *sig, int siglen,
4444
}
4545
}
4646

47-
switch (sig[0]) {
47+
switch (sig[1]) {
4848
case 1:
49-
return digsig_verify(keyring[id], sig, siglen,
49+
/* v1 API expect signature without xattr type */
50+
return digsig_verify(keyring[id], sig + 1, siglen - 1,
5051
digest, digestlen);
5152
case 2:
5253
return asymmetric_verify(keyring[id], sig, siglen,

‎security/integrity/evm/evm_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
123123
goto out;
124124
}
125125

126-
xattr_len = rc - 1;
126+
xattr_len = rc;
127127

128128
/* check value type */
129129
switch (xattr_data->type) {
@@ -143,7 +143,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
143143
if (rc)
144144
break;
145145
rc = integrity_digsig_verify(INTEGRITY_KEYRING_EVM,
146-
xattr_data->digest, xattr_len,
146+
(const char *)xattr_data, xattr_len,
147147
calc.digest, sizeof(calc.digest));
148148
if (!rc) {
149149
/* we probably want to replace rsa with hmac here */

‎security/integrity/ima/ima_appraise.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ int ima_appraise_measurement(int func, struct integrity_iint_cache *iint,
205205
case EVM_IMA_XATTR_DIGSIG:
206206
iint->flags |= IMA_DIGSIG;
207207
rc = integrity_digsig_verify(INTEGRITY_KEYRING_IMA,
208-
xattr_value->digest, rc - 1,
208+
(const char *)xattr_value, rc,
209209
iint->ima_hash.digest,
210210
iint->ima_hash.length);
211211
if (rc == -EOPNOTSUPP) {

‎security/integrity/integrity.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct ima_digest_data {
7474
* signature format v2 - for using with asymmetric keys
7575
*/
7676
struct signature_v2_hdr {
77+
uint8_t type; /* xattr type */
7778
uint8_t version; /* signature format version */
7879
uint8_t hash_algo; /* Digest algorithm [enum pkey_hash_algo] */
7980
uint32_t keyid; /* IMA key identifier - not X509/PGP specific */

0 commit comments

Comments
 (0)