[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9629068a41a160de0145a18dd22924bce70f37fe.camel@oracle.com>
Date: Thu, 15 Aug 2019 12:35:26 +0200
From: Knut Omang <knut.omang@...cle.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kbuild@...r.kernel.org,
Shuah Khan <shuah@...nel.org>,
Jonathan Corbet <corbet@....net>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Michal Marek <michal.lkml@...kovi.net>,
Shreyans Devendra Doshi <0xinfosect0r@...il.com>,
Alan Maguire <alan.maguire@...cle.com>,
Brendan Higgins <brendanhiggins@...gle.com>,
Kevin Hilman <khilman@...libre.com>,
Hidenori Yamaji <hidenori.yamaji@...y.com>,
Frank Rowand <frowand.list@...il.com>,
Timothy Bird <Tim.Bird@...y.com>,
Luis Chamberlain <mcgrof@...nel.org>,
"Theodore Ts'o" <tytso@....edu>, Daniel Vetter <daniel@...ll.ch>,
Stephen Boyd <sboyd@...nel.org>
Subject: Re: [RFC 06/19] ktf: A simple debugfs interface to test results
On Thu, 2019-08-15 at 10:49 +0200, Greg Kroah-Hartman wrote:
> On Wed, Aug 14, 2019 at 07:17:07PM +0200, Knut Omang wrote:
> > I notice the discussion and your response here:
> > http://linux-kernel.2935.n7.nabble.com/debugfs-and-module-unloading-td865175.html
> > I assume that means that protection against module unload while a debugfs file
> > is open is now safe.
>
> It should be, if you set the *owner field of your file_operations
> properly. Try it and see!
Might be a case for a KTF selftest to play with the timing to increase the chance :)
Wasn't able to make it crash with these simple, short files.
I notice I had set the .owner field correctly myself in that driver
code I referred to, so that's a "copy regression".
> > On older kernels, having this code in place is far better than an unprotected
> > debugfs entry/exit - I have tested it extensively in the past :-)
>
> Yes, it seems to work, but again, it really is racy and will fail.
> Please don't use it.
>
> > I perfectly agree with you that reducing the hole for a race condition
> > is generally a bad idea, but from the above mail thread
> > it seems that's the only available choice for older kernels?
>
> I have no idea, but please, do not use that pattern of code as it is
> racy in all kernels, from all of time.
Ok, will remove it :-)
I tried in vain to find the commit from Al Viro that made the code safe,
to identify which kernels that are safe from this issue,
but he has a **lot** of commits, do you have a clue for what/where to look?
It will be good to have a mention/comment on this for future reference,
like the earliest kernel version where this is safe.
Maybe we can even get rid of some more of the remaining of these too..
(I notice there's 65 cases of 'if (!try_module_get(THIS_MODULE))'
right now)
Thanks!
Knut
>
> thanks,
>
> greg k-h
Powered by blists - more mailing lists