]> git.ipfire.org Git - thirdparty/linux.git/commit
lsm: consolidate buffer size handling into lsm_fill_user_ctx()
authorPaul Moore <paul@paul-moore.com>
Tue, 24 Oct 2023 18:44:00 +0000 (14:44 -0400)
committerPaul Moore <paul@paul-moore.com>
Mon, 13 Nov 2023 03:54:42 +0000 (22:54 -0500)
commitd7cf3412a9f6c547e5ee443fa7644e08898aa3e2
treef5ab0f4687f6d7efae5ac221906a18ddf3b11330
parentfdcf699b60712ecd6e41d9fc09137279257a4bf8
lsm: consolidate buffer size handling into lsm_fill_user_ctx()

While we have a lsm_fill_user_ctx() helper function designed to make
life easier for LSMs which return lsm_ctx structs to userspace, we
didn't include all of the buffer length safety checks and buffer
padding adjustments in the helper.  This led to code duplication
across the different LSMs and the possibility for mistakes across the
different LSM subsystems.  In order to reduce code duplication and
decrease the chances of silly mistakes, we're consolidating all of
this code into the lsm_fill_user_ctx() helper.

The buffer padding is also modified from a fixed 8-byte alignment to
an alignment that matches the word length of the machine
(BITS_PER_LONG / 8).

Signed-off-by: Paul Moore <paul@paul-moore.com>
include/linux/security.h
security/apparmor/lsm.c
security/security.c
security/selinux/hooks.c
security/smack/smack_lsm.c