Re: [RFC][PATCH 10/13] get rid of audit_reusename()

Linus Torvalds
2025-11-10T16:50:31Z

On Sun, 9 Nov 2025 at 22:37, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> > @@ -258,13 +264,13 @@ struct filename *getname_kernel(const char * filename)
> >
> > tmp = kmalloc(size, GFP_KERNEL);
> > if (unlikely(!tmp)) {
> > - __putname(result);
> > + free_filename(result);
> > return ERR_PTR(-ENOMEM);
> > }
> > tmp->name = (char *)result;
> > result = tmp;
>
> That's wrong - putname() will choke on that (free_filename() on result of
> kmalloc()).

Yeah, that's me not doing the right conversion from the old crazy
"turn allocations around".

It should just do

char *tmp = kmalloc(len, GFP_KERNEL);
.... NULL check ..
result->name = tmp;

without any odd games with types. And yeah, that code could be
re-organized to be clearer.

Linus