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: <20200117012520.1234720728@mail.kernel.org>
Date:   Thu, 16 Jan 2020 17:25:19 -0800
From:   Stephen Boyd <sboyd@...nel.org>
To:     Doug Anderson <dianders@...omium.org>,
        Thomas Gleixner <tglx@...utronix.de>
Cc:     Stephen Boyd <swboyd@...omium.org>,
        John Stultz <john.stultz@...aro.org>,
        Ravi Chandra Sadineni <ravisadineni@...omium.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/4] alarmtimer: Make alarmtimer platform device child of RTC device

Quoting Doug Anderson (2020-01-15 11:22:26)
> Hi,
> 
> On Wed, Jan 15, 2020 at 2:07 AM Thomas Gleixner <tglx@...utronix.de> wrote:
> >
> > Doug Anderson <dianders@...omium.org> writes:
> > > On Thu, Jan 9, 2020 at 7:59 AM Stephen Boyd <swboyd@...omium.org> wrote:
> > >> diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
> > >> index 4b11f0309eee..ccb6aea4f1d4 100644
> > >> --- a/kernel/time/alarmtimer.c
> > >> +++ b/kernel/time/alarmtimer.c
> > >> @@ -88,6 +88,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
> > >>         unsigned long flags;
> > >>         struct rtc_device *rtc = to_rtc_device(dev);
> > >>         struct wakeup_source *__ws;
> > >> +       struct platform_device *pdev;
> > >>         int ret = 0;
> > >>
> > >>         if (rtcdev)
> > >> @@ -99,6 +100,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
> > >>                 return -1;
> > >>
> > >>         __ws = wakeup_source_register(dev, "alarmtimer");
> > >> +       pdev = platform_device_register_data(dev, "alarmtimer", -1, NULL, 0);
> > >
> > > Don't you need to check for an error here?  If pdev is an error you'll
> > > continue on your merry way.  Before your patch if you got an error
> > > registering the device it would have caused probe to fail.
> >
> > Yes, that return value should be checked
> >
> > > I guess you'd only want it to be an error if "rtcdev" is NULL?
> >
> > If rtcdev is not NULL then this code is not reached. See the begin of
> > this function :)
> 
> Wow, not sure how I missed that.  I guess the one at the top of the
> function is an optimization, though?  It's being accessed without the
> spinlock which means that it's not necessarily reliable, right?  I
> guess once the rtcdev has been set then it is never unset, but it does
> seem like if two threads could call alarmtimer_rtc_add_device() at the
> same time then it's possible that we could end up calling
> wakeup_source_register() for both of them.  Did I understand that
> correctly?  If I did then maybe it deserves a comment?

It also looks like we call wakeup_source_register() and get lucky that
they're both called alarmtimer but they don't conflict with each other
in sysfs. Once we try to add a device named "alarmtimer" to the platform
bus it is the only one that can be added. I'll have to make this
autogenerate some number for the device instead of using -1 as the id so
that we don't see device name conflicts on the same bus.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ