lkml.org 
[lkml]   [2018]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] gpiolib: Fix possible use after free on label
On Thu, Nov 1, 2018 at 4:27 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Nov 1, 2018 at 2:13 PM Muchun Song <smuchun@gmail.com> wrote:
>
> > gpiod_request_commit() copies the pointer to the label passed as
> > an argument only to be used later. But there's a chance the caller
> > could immediately free the passed string(e.g., local variable).
> > This could trigger a use after free when we use gpio label(e.g.,
> > gpiochip_unlock_as_irq(), gpiochip_is_requested()).
> >
> > To be on the safe side: duplicate the string with kstrdup_const()
> > so that if an unaware user passes an address to a stack-allocated
> > buffer, we won't get the arbitrary label.
> >
> > Also fix gpiod_set_consumer_name().
> >
> > Signed-off-by: Muchun Song <smuchun@gmail.com>
>
> I am still a bit worried about the kstrdup_const() that this
> introduces.

Forget it. I realized after actually reading the code
for kstrdup_const() that it really does exactly
what we want.

I should stop assuming things are syntactic sugar
in the kernel, we have some really smart people
working with it...

Patch applied.

Yours,
Linus Walleij

\
 
 \ /
  Last update: 2018-11-02 10:25    [W:0.044 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site