lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <nycvar.YSQ.7.76.1811021205400.1498@knanqh.ubzr>
Date:   Fri, 2 Nov 2018 12:12:24 -0400 (EDT)
From:   Nicolas Pitre <nicolas.pitre@...aro.org>
To:     Linus Walleij <linus.walleij@...aro.org>
cc:     smuchun@...il.com, Bartosz Golaszewski <bgolaszewski@...libre.com>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] gpiolib: Fix possible use after free on label

On Fri, 2 Nov 2018, Linus Walleij wrote:

> On Thu, Nov 1, 2018 at 4:27 PM Linus Walleij <linus.walleij@...aro.org> wrote:
> > On Thu, Nov 1, 2018 at 2:13 PM Muchun Song <smuchun@...il.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@...il.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...

I didn't know about kstrdup_const() either before just now.

If the device tree lands in the kernel rodata area then all is fine. I 
don't know enough about the actual DT processing to be sure though.


Nicolas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ