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

From: Mike Rapoport

Date: Tue Jun 02 2026 - 06:38:51 EST


On Mon, Jun 01, 2026 at 02:11:11PM -0400, Paul Moore wrote:
> 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 ...

Boot of fedora on an arm64 VM with 64K page size kernel.

> --
> paul-moore.com

--
Sincerely yours,
Mike.