[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191017113939.GH24485@dhcp22.suse.cz>
Date: Thu, 17 Oct 2019 13:39:39 +0200
From: Michal Hocko <mhocko@...nel.org>
To: David Laight <David.Laight@...LAB.COM>
Cc: Pavel Machek <pavel@...x.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"stable@...r.kernel.org" <stable@...r.kernel.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Heinrich Schuchardt <xypron.glpk@....de>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 4.19 56/81] kernel/sysctl.c: do not override max_threads
provided by userspace
On Thu 17-10-19 11:25:47, David Laight wrote:
> From: Michal Hocko
> > Sent: 17 October 2019 12:05
> ...
> > > Plus, I don't see any locking here, should this be WRITE_ONCE() at
> > > minimum?
> >
> > Why would that matter? Do you expect several root processes race to set
> > the value?
>
> One of them wins. No one is going to notice is the value is set an extra time.
Right, this is quite obvious. The question is whether/how much it really
matters.
> WRITE_ONCE() is rarely required.
> Probably only if other code is going to update the value after seeing the first write.
> (eg if you are unlocking a mutex - although they have to be more complex)
>
> READ_ONCE() is a different matter.
> IMHO the compiler shouldn't be allowed to do more reads than the source requests.
Right, we are talking about setting an int value. While nobody can rule
out that the compiler splitting the single write into multiple ones I
would be quite curious about seeing that...
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists