Re: [PATCH v3] selinux: hooks: use kmalloc() to allocate path buffer

From: Stephen Smalley

Date: Tue Jun 02 2026 - 09:54:47 EST


On Sun, May 31, 2026 at 12:58 PM Mike Rapoport <rppt@xxxxxxxxxx> wrote:
>
> From: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
>
> selinux_genfs_get_sid() allocates memory for a path with __get_free_page().
>
> Such usage does not require a "page" and the size of the buffer should
> actually be PATH_MAX which may be less than PAGE_SIZE on some
> architectures.
>
> Replace __get_free_page() for allocation of a path buffer with kmalloc()
> and make it explicit that the buffer size is PATH_MAX.
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

Acked-by: Stephen Smalley <stephen.smalley.work@xxxxxxxxx>