linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Size mismatch between vfs_getxattr_alloc() and vfs_getxattr()
@ 2021-06-11  9:44 Roberto Sassu
  2021-06-16 13:22 ` [PATCH] fs: Return raw xattr for security.* if there is size disagreement with LSMs Roberto Sassu
  0 siblings, 1 reply; 11+ messages in thread
From: Roberto Sassu @ 2021-06-11  9:44 UTC (permalink / raw)
  To: viro, Mimi Zohar, paul, Stephen Smalley, casey, Stefan Berger
  Cc: linux-integrity, linux-security-module, linux-kernel, selinux

Hello

the ima-evm-utils tool discovered an issue doing signature
verification of xattrs.

On kernel side, EVM reads the xattr value with
vfs_getxattr_alloc(), which gets the value directly from the
xattr handler.

On user side, ima-evm-utils reads the value with the
lgetxattr() system call, which gets the value from LSMs.

There is a corner case, where security.selinux is set directly
with setfattr without adding \0 at the end.

In this case, the kernel and the user see different values
due to the fact that the former gets the raw value from the
xattr handler, and the latter gets the value normalized by
SELinux (which adds \0).

I found that originally also lgetxattr() was getting the value
from the xattr handler. This changed with:

commit 4bea58053f206be9a89ca35850f9ad295dac2042
Author: David P. Quigley <dpquigl@tycho.nsa.gov>
Date:   Mon Feb 4 22:29:40 2008 -0800

    VFS: Reorder vfs_getxattr to avoid unnecessary calls to the LSM

which directly calls LSMs for security.* xattrs.

Given that this patch is there for a long time, I would ask
if it makes sense to fix this issue. The way I would do it
is to check if the size returned by the xattr handler is the
same of the size returned by LSMs. If not, I would get
the value from the xattr handler.

Although this change does not check the xattr content,
it is sufficient to fix the issue.

Any opinion?

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli


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

end of thread, other threads:[~2021-06-18 17:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11  9:44 Size mismatch between vfs_getxattr_alloc() and vfs_getxattr() Roberto Sassu
2021-06-16 13:22 ` [PATCH] fs: Return raw xattr for security.* if there is size disagreement with LSMs Roberto Sassu
2021-06-16 14:40   ` Stefan Berger
2021-06-17  7:09     ` Roberto Sassu
2021-06-17 15:27       ` Mimi Zohar
2021-06-17 16:05         ` Roberto Sassu
2021-06-18  3:18         ` Paul Moore
2021-06-18 16:04           ` Mimi Zohar
2021-06-18 16:10             ` Roberto Sassu
2021-06-18 16:35             ` Paul Moore
2021-06-18 17:22               ` 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).