Skip to contentSkip to conversation

evm: skip replacing EVM signature with HMAC on read-only filesystem

PATCH Mimi Zohar 2 participants 3 messages Sep 29, 2014 2 messages not in the archive

lore
Share & tools
lore

Mimi Zohar

author
#2 lore raw
In reply to a message not in the archive
Quoted 16 lines · Dmitry Kasatkin

If filesystem is mounted read-only or file is immutable, updating xattr will fail. This is a usual case during early boot until filesystem is remount read-write. This patch verifies conditions to skip unnecessary attempt to calculate HMAC and set xattr.

---
 security/integrity/evm/evm_main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
security/integrity/evm/evm_main.c +0 -0
index 9685af3..a30be77 100644
@@ -162,9 +162,14 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
 					(const char *)xattr_data, xattr_len,

security/integrity/evm/evm_main.c static enum integrity_status evm_verify_hmac(struct dentry *dentry, · line 169

Quoted 10 lines
security/integrity/evm/evm_main.c +5 -3
 					calc.digest, sizeof(calc.digest));
 		if (!rc) {
-			/* we probably want to replace rsa with hmac here */
-			evm_update_evmxattr(dentry, xattr_name, xattr_value,
-				   xattr_value_len);
+			/* Replace RSA with HMAC if not mounted readonly and
+			 * not immutable
+			 */
+			if (!IS_RDONLY(dentry->d_inode) &&
+					!IS_IMMUTABLE(dentry->d_inode))

Previously patches conformed to Lindent, unless there was a valid reason not to use it, like conflicting with checkpatch.pl. Joe Perches submitted a patch to remove it from the Documentation/CodingStyle a while ago - https://lkml.org/lkml/2013/2/11/390 and recommends using "checkpatch.pl --fix" instead.

Andrew, Greg, what is the current best practice?

thanks,

Mimi

Quoted 6 lines
security/integrity/evm/evm_main.c +3 -0
+				evm_update_evmxattr(dentry, xattr_name,
+						    xattr_value,
+						    xattr_value_len);
 		}
 		break;
 	default:
#3 lore raw
Quoted 34 lines · Mimi Zohar
Quoted 16 lines · Dmitry Kasatkin

If filesystem is mounted read-only or file is immutable, updating xattr will fail. This is a usual case during early boot until filesystem is remount read-write. This patch verifies conditions to skip unnecessary attempt to calculate HMAC and set xattr.

---
 security/integrity/evm/evm_main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
security/integrity/evm/evm_main.c +0 -0
index 9685af3..a30be77 100644
@@ -162,9 +162,14 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
 					(const char *)xattr_data, xattr_len,

security/integrity/evm/evm_main.c static enum integrity_status evm_verify_hmac(struct dentry *dentry, · line 169

Quoted 10 lines
security/integrity/evm/evm_main.c +5 -3
 					calc.digest, sizeof(calc.digest));
 		if (!rc) {
-			/* we probably want to replace rsa with hmac here */
-			evm_update_evmxattr(dentry, xattr_name, xattr_value,
-				   xattr_value_len);
+			/* Replace RSA with HMAC if not mounted readonly and
+			 * not immutable
+			 */
+			if (!IS_RDONLY(dentry->d_inode) &&
+					!IS_IMMUTABLE(dentry->d_inode))

Previously patches conformed to Lindent, unless there was a valid reason not to use it, like conflicting with checkpatch.pl. Joe Perches submitted a patch to remove it from the Documentation/CodingStyle a while ago - https://lkml.org/lkml/2013/2/11/390 and recommends using "checkpatch.pl --fix" instead.

Quoted 1 line

Andrew, Greg, what is the current best practice?

I don't understand, what is wrong with the formatting of this patch? It looks ok to me. If you want to indent the second line of the if to the left some more, that's fine, but just minor nits, nothing major at all.

thanks,

greg k-h

author
#4 lore raw
Quoted 35 lines · Greg KH
Quoted 34 lines · Mimi Zohar
Quoted 16 lines · Dmitry Kasatkin

If filesystem is mounted read-only or file is immutable, updating xattr will fail. This is a usual case during early boot until filesystem is remount read-write. This patch verifies conditions to skip unnecessary attempt to calculate HMAC and set xattr.

---
 security/integrity/evm/evm_main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
security/integrity/evm/evm_main.c +0 -0
index 9685af3..a30be77 100644
@@ -162,9 +162,14 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
 					(const char *)xattr_data, xattr_len,

security/integrity/evm/evm_main.c static enum integrity_status evm_verify_hmac(struct dentry *dentry, · line 169

Quoted 10 lines
security/integrity/evm/evm_main.c +5 -3
 					calc.digest, sizeof(calc.digest));
 		if (!rc) {
-			/* we probably want to replace rsa with hmac here */
-			evm_update_evmxattr(dentry, xattr_name, xattr_value,
-				   xattr_value_len);
+			/* Replace RSA with HMAC if not mounted readonly and
+			 * not immutable
+			 */
+			if (!IS_RDONLY(dentry->d_inode) &&
+					!IS_IMMUTABLE(dentry->d_inode))

Previously patches conformed to Lindent, unless there was a valid reason not to use it, like conflicting with checkpatch.pl. Joe Perches submitted a patch to remove it from the Documentation/CodingStyle a while ago - https://lkml.org/lkml/2013/2/11/390 and recommends using "checkpatch.pl --fix" instead.

Quoted 5 lines
Quoted 1 line

Andrew, Greg, what is the current best practice?

I don't understand, what is wrong with the formatting of this patch? It looks ok to me. If you want to indent the second line of the if to the left some more, that's fine, but just minor nits, nothing major at all.

Right, scripts/Lindent is only about formatting, nothing major.

Mimi