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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171215084515.GB8221@amd>
Date:   Fri, 15 Dec 2017 09:45:15 +0100
From:   Pavel Machek <pavel@....cz>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     shrikant.maurya@...hveda.org,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Len Brown <len.brown@...el.com>,
        Greg KH <gregkh@...uxfoundation.org>,
        Linux PM list <linux-pm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Suniel Mahesh <sunil.m@...hveda.org>,
        Karthik Tummala <karthik@...hveda.org>, raghu@...hveda.org
Subject: Re: [PATCH] drivers: base: power: Fix GFP_KERNEL in spinlock context

On Tue 2017-12-12 15:58:00, Geert Uytterhoeven wrote:
> Hi Shrikant,
> 
> On Tue, Dec 12, 2017 at 2:45 PM,  <shrikant.maurya@...hveda.org> wrote:
> > From: Shrikant Maurya <shrikant.maurya@...hveda.org>
> >
> > As reported by Jia-Ju Bai (https://lkml.org/lkml/2017/12/11/872):
> > API's are using GFP_KERNEL to allocate memory which may sleep.
> >
> > To ensure atomicity such allocations must be avoided in critical
> > sections under spinlock.
> > Fixed by replacing GFP_KERNEL to GFP_ATOMIC.
> >
> > Reported-by: Jia-Ju Bai <baijiaju1990@...il.com>
> > Signed-off-by: Shrikant Maurya <shrikant.maurya@...hveda.org>
> > Signed-off-by: Suniel Mahesh <sunil.m@...hveda.org>
> > Signed-off-by: Raghu Bharadwaj <raghu@...hveda.org>
> > Signed-off-by: Karthik Tummala <karthik@...hveda.org>
> 
> Can't the call to device_init_wakeup() in isp116x_start() just be moved
> below the spinlock release?
> 
> > --- a/drivers/base/power/wakeup.c
> > +++ b/drivers/base/power/wakeup.c
> > @@ -92,11 +92,11 @@ struct wakeup_source *wakeup_source_create(const char *name)
> >  {
> >         struct wakeup_source *ws;
> >
> > -       ws = kmalloc(sizeof(*ws), GFP_KERNEL);
> > +       ws = kmalloc(sizeof(*ws), GFP_ATOMIC);
> 
> With GFP_ATOMIC, allocation failure is much more likely to occur.
> So IMHO it's better to fix the isp116x, than to impose this burden on
> every user.
> 
> >         if (!ws)
> >                 return NULL;
> >
> > -       wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_KERNEL) : NULL);
> > +       wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_ATOMIC) : NULL);
> >         return ws;

NAK. This will silently replace name with NULL if memory is low.

									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ