SELinux Security Module development
 help / color / mirror / Atom feed
* [PATCH v1 0/2] lsm: Preserve full ioctl commands in audit records
@ 2026-09-10 14:48 Mickaël Salaün
  2026-09-10 14:48 ` [PATCH v1 1/2] " Mickaël Salaün
  2026-09-10 14:48 ` [PATCH v1 2/2] selftests/landlock: Check " Mickaël Salaün
  0 siblings, 2 replies; 6+ messages in thread
From: Mickaël Salaün @ 2026-09-10 14:48 UTC (permalink / raw)
  To: Paul Moore
  Cc: Mickaël Salaün, Günther Noack, Jeff Vander Stoep,
	Nick Kralevich, Ondrej Mosnacek, Serge E . Hallyn,
	Stephen Smalley, audit, kernel-team, linux-kernel,
	linux-security-module, selinux

Hi,

Ioctl commands are unsigned int values, with conventionally encoded size
and direction fields above bit 15.  However, struct lsm_ioctlop_audit
stores only a u16 and the common audit formatter uses %hx.  SELinux also
narrows the command before constructing this audit data.  As a result,
LSM audit records can conflate distinct ioctl requests; for example,
Landlock currently records 0xc00ffeee as 0xfeee.

The narrow audit field dates to its 2015 introduction [1] alongside
SELinux ioctl extended permissions.  Using the low type and number bytes
for those policy checks was deliberate, but the mailing-list review
contains no separate decision to truncate the audit value.  Audit
discussion instead identified ioctlcmd with the ioctl request in syscall
argument a1, and the audit field dictionary defines it as the request
argument to ioctl.

This also exposes an audit2allow -x assumption: it copies ioctlcmd
directly into a 16-bit SELinux extended-permission rule.  It needs to
derive that rule from the low 16 bits of the full audited request;
otherwise checkpolicy rejects generated values above 0xffff.

Patch 1 preserves the full command in shared audit data without changing
SELinux's low-16-bit policy checks.  Patch 2 updates the existing
Landlock test to exercise upper command bits.

[1] https://lore.kernel.org/r/1428616171-14767-1-git-send-email-jeffv@google.com

Mickaël Salaün (2):
  lsm: Preserve full ioctl commands in audit records
  selftests/landlock: Check full ioctl commands in audit records

 include/linux/lsm_audit.h                  |  2 +-
 security/lsm_audit.c                       |  2 +-
 security/selinux/hooks.c                   |  6 +++---
 tools/testing/selftests/landlock/fs_test.c | 10 +++++++---
 4 files changed, 12 insertions(+), 8 deletions(-)

-- 
2.55.0


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

end of thread, other threads:[~2026-09-11 11:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10 14:48 [PATCH v1 0/2] lsm: Preserve full ioctl commands in audit records Mickaël Salaün
2026-09-10 14:48 ` [PATCH v1 1/2] " Mickaël Salaün
2026-09-10 14:56   ` sashiko-bot
2026-09-10 14:48 ` [PATCH v1 2/2] selftests/landlock: Check " Mickaël Salaün
2026-09-10 15:02   ` sashiko-bot
2026-09-11 11:24   ` Günther Noack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox