]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selinux: use k[mz]alloc() to allocate temporary buffers
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Wed, 20 May 2026 08:18:55 +0000 (11:18 +0300)
committerPaul Moore <paul@paul-moore.com>
Wed, 27 May 2026 23:42:39 +0000 (19:42 -0400)
commitbc3f08d1ef15ebbd32faf0b10cd9699b90b9d30c
tree18f06ce2ff644bd890c0462d0cda588cb353c9f9
parent2f0af91353cb64b54cfee5423820d2149039338d
selinux: use k[mz]alloc() to allocate temporary buffers

Several functions in selinuxfs.c allocate temporary buffers using
__get_free_page() or get_zeroed_page().

These buffers are used either to store a string generated by snprintf() (in
sel_make_bools()) or to copy data from user (sel_read_avc_hash_stats() and
sel_read_sidtab_hash_stats()).

Such usage does not require struct page access and it is better to allocate
these buffers with kzalloc()/kmalloc() that provide better scalability and
more debugging possibilities.

Replace use of get_zeroed_page() with kzalloc() and usage of
__get_free_page() with kmalloc().

Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/selinuxfs.c