Re: [PATCH 1/3] selinux: use k[mz]alloc() to allocate temporary buffers
From: Paul Moore
Date: Wed May 27 2026 - 19:42:45 EST
On May 20, 2026 "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxx
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
> security/selinux/selinuxfs.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
I suspect if we look closer we can probably also trim some of those
allocations to less then a page, but that can be work for another day.
Merged into selinux/dev, thanks Mike.
--
paul-moore.com