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

From: Paul Moore

Date: Mon Jun 01 2026 - 14:18:43 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>
> ---
> v3:
> get the args in the right order
>
> v2:
> * explicitly use kmalloc() with PATH_MAX
>
> security/selinux/hooks.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)

Considering the problems with the first two versions of this patch I
have to ask what sort of testing you've done on this? I know it's a
trivial patch, but we're on v3 ...

--
paul-moore.com