linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] evm: check for remount ro in progress before writing
@ 2018-03-01 12:38 Sascha Hauer
  2018-03-08 21:42 ` Mimi Zohar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-03-01 12:38 UTC (permalink / raw)
  To: linux-integrity; +Cc: Mimi Zohar, Sascha Hauer

EVM might update the evm xattr while the VFS performs a remount to
readonly mode. This is not properly checked for, additionally check
the s_readonly_remount superblock flag before writing.
The bug can for example be observed with UBIFS. UBIFS checks the free
space on the device before and after a remount. With EVM enabled the
free space sometimes differs between both checks.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 security/integrity/evm/evm_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index a8d502827270..4a147a998aa7 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -185,6 +185,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
 					iint->flags |= EVM_IMMUTABLE_DIGSIG;
 				evm_status = INTEGRITY_PASS_IMMUTABLE;
 			} else if (!IS_RDONLY(d_backing_inode(dentry)) &&
+				   !(dentry->d_inode->i_sb->s_readonly_remount) &&
 				   !IS_IMMUTABLE(d_backing_inode(dentry))) {
 				evm_update_evmxattr(dentry, xattr_name,
 						    xattr_value,
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] evm: check for remount ro in progress before writing
  2018-03-01 12:38 [PATCH] evm: check for remount ro in progress before writing Sascha Hauer
@ 2018-03-08 21:42 ` Mimi Zohar
  2018-03-11 21:52 ` Mimi Zohar
  2018-03-16 17:12 ` Mimi Zohar
  2 siblings, 0 replies; 4+ messages in thread
From: Mimi Zohar @ 2018-03-08 21:42 UTC (permalink / raw)
  To: Sascha Hauer, linux-integrity; +Cc: Matthew Garrett

On Thu, 2018-03-01 at 13:38 +0100, Sascha Hauer wrote:
> EVM might update the evm xattr while the VFS performs a remount to
> readonly mode. This is not properly checked for, additionally check
> the s_readonly_remount superblock flag before writing.
> The bug can for example be observed with UBIFS. UBIFS checks the free
> space on the device before and after a remount. With EVM enabled the
> free space sometimes differs between both checks.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  security/integrity/evm/evm_main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index a8d502827270..4a147a998aa7 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -185,6 +185,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
>  					iint->flags |= EVM_IMMUTABLE_DIGSIG;
>  				evm_status = INTEGRITY_PASS_IMMUTABLE;
>  			} else if (!IS_RDONLY(d_backing_inode(dentry)) &&
> +				   !(dentry->d_inode->i_sb->s_readonly_remount) &&
>  				   !IS_IMMUTABLE(d_backing_inode(dentry))) {
>  				evm_update_evmxattr(dentry, xattr_name,
>  						    xattr_value,

Mathew's EVM Portable signature patch should have inverted the (!rc)
test, but didn't.  With this patch, there's now a checkpatch over 80
character line warning.

Mimi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] evm: check for remount ro in progress before writing
  2018-03-01 12:38 [PATCH] evm: check for remount ro in progress before writing Sascha Hauer
  2018-03-08 21:42 ` Mimi Zohar
@ 2018-03-11 21:52 ` Mimi Zohar
  2018-03-16 17:12 ` Mimi Zohar
  2 siblings, 0 replies; 4+ messages in thread
From: Mimi Zohar @ 2018-03-11 21:52 UTC (permalink / raw)
  To: Sascha Hauer, linux-integrity

On Thu, 2018-03-01 at 13:38 +0100, Sascha Hauer wrote:
> EVM might update the evm xattr while the VFS performs a remount to
> readonly mode. This is not properly checked for, additionally check
> the s_readonly_remount superblock flag before writing.
> The bug can for example be observed with UBIFS. UBIFS checks the free
> space on the device before and after a remount. With EVM enabled the
> free space sometimes differs between both checks.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  security/integrity/evm/evm_main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index a8d502827270..4a147a998aa7 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -185,6 +185,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
>  					iint->flags |= EVM_IMMUTABLE_DIGSIG;
>  				evm_status = INTEGRITY_PASS_IMMUTABLE;
>  			} else if (!IS_RDONLY(d_backing_inode(dentry)) &&
> +				   !(dentry->d_inode->i_sb->s_readonly_remount) &&

The other 2 conditions are using d_back_inode().  Shouldn't this one
be too?

Mimi

>  				   !IS_IMMUTABLE(d_backing_inode(dentry))) {
>  				evm_update_evmxattr(dentry, xattr_name,
>  						    xattr_value,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] evm: check for remount ro in progress before writing
  2018-03-01 12:38 [PATCH] evm: check for remount ro in progress before writing Sascha Hauer
  2018-03-08 21:42 ` Mimi Zohar
  2018-03-11 21:52 ` Mimi Zohar
@ 2018-03-16 17:12 ` Mimi Zohar
  2 siblings, 0 replies; 4+ messages in thread
From: Mimi Zohar @ 2018-03-16 17:12 UTC (permalink / raw)
  To: Sascha Hauer, linux-integrity

On Thu, 2018-03-01 at 13:38 +0100, Sascha Hauer wrote:
> EVM might update the evm xattr while the VFS performs a remount to
> readonly mode. This is not properly checked for, additionally check
> the s_readonly_remount superblock flag before writing.
> The bug can for example be observed with UBIFS. UBIFS checks the free
> space on the device before and after a remount. With EVM enabled the
> free space sometimes differs between both checks.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

I've modified the patch to use d_backing_inode() and fixed the
checkpatch over 80 character warning.  It's now applied.

thanks!

Mimi

> ---
>  security/integrity/evm/evm_main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index a8d502827270..4a147a998aa7 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -185,6 +185,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
>  					iint->flags |= EVM_IMMUTABLE_DIGSIG;
>  				evm_status = INTEGRITY_PASS_IMMUTABLE;
>  			} else if (!IS_RDONLY(d_backing_inode(dentry)) &&
> +				   !(dentry->d_inode->i_sb->s_readonly_remount) &&
>  				   !IS_IMMUTABLE(d_backing_inode(dentry))) {
>  				evm_update_evmxattr(dentry, xattr_name,
>  						    xattr_value,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-16 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-01 12:38 [PATCH] evm: check for remount ro in progress before writing Sascha Hauer
2018-03-08 21:42 ` Mimi Zohar
2018-03-11 21:52 ` Mimi Zohar
2018-03-16 17:12 ` Mimi Zohar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).