All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Richard Kuo <rkuo@codeaurora.org>,
	Tony Luck <tony.luck@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Michal Simek <monstr@monstr.eu>,
	Ralf Baechle <ralf@linux-mips.org>,
	Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Stafford Horne <shorne@gmail.com>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	Helge Deller <deller@gmx.de>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 14:16:45 +0100	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017 at 03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Richard Kuo <rkuo@codeaurora.org>,
	Tony Luck <tony.luck@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Michal Simek <monstr@monstr.eu>,
	Ralf Baechle <ralf@linux-mips.org>,
	Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Stafford Horne <shorne@gmail.com>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	Helge Deller <deller@gmx.de>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	"David S. Miller" <davem@davemloft.net>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Chris Zankel <chris@zankel.net>,
	Max Filippov <jcmvbkbc@gmail.com>, Arnd Bergmann <arnd@arndb.de>,
	x86@kernel.org, linux-alpha@vger.kernel.org,
	linux-snps-arc@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org,
	linux-mips@linux-mips.org, openrisc@lists.librecores.org,
	linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, linux-sh@vger.kernel.org,
	sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org,
	linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 14:16:45 +0100	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
Message-ID: <20170515131645.h5vxGl1SErUwWv1aMtsMiC_P31yW39kvY6SPw13kUVI@z> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017 at 03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Richard Kuo <rkuo@codeaurora.org>,
	Tony Luck <tony.luck@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Michal Simek <monstr@monstr.eu>,
	Ralf Baechle <ralf@linux-mips.org>,
	Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Stafford Horne <shorne@gmail.com>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	Helge Deller <deller@gmx.de>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 13:16:45 +0000	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017 at 03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Richard Kuo <rkuo@codeaurora.org>,
	Tony Luck <tony.luck@intel.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Michal Simek <monstr@monstr.eu>,
	Ralf Baechle <ralf@linux-mips.org>,
	Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Stafford Horne <shorne@gmail.com>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	Helge Deller <deller@gmx.de>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
Subject: Re: [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 14:16:45 +0100	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017 at 03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-snps-arc@lists.infradead.org
Subject: [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 14:16:45 +0100	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017@03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: openrisc@lists.librecores.org
Subject: [OpenRISC] [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 14:16:45 +0100	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017 at 03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/1] futex: remove duplicated code
Date: Mon, 15 May 2017 14:16:45 +0100	[thread overview]
Message-ID: <20170515131644.GA3605@arm.com> (raw)
In-Reply-To: <20170515130742.18357-1-jslaby@suse.cz>

Hi Jiri,

On Mon, May 15, 2017 at 03:07:42PM +0200, Jiri Slaby wrote:
> There is code duplicated over all architecture's headers for
> futex_atomic_op_inuser. Namely op decoding, access_ok check for uaddr,
> and comparison of the result.
> 
> Remove this duplication and leave up to the arches only the needed
> assembly which is now in arch_futex_atomic_op_inuser.
> 
> Note that s390 removed access_ok check in d12a29703 ("s390/uaccess:
> remove pointless access_ok() checks") as access_ok there returns true.
> We introduce it back to the helper for the sake of simplicity (it gets
> optimized away anyway).

Whilst I think this is a good idea, the code in question actually results
in undefined behaviour per the C spec and is reported by UBSAN. See my
patch fixing arm64 here (which I'd forgotten about):

https://www.spinics.net/lists/linux-arch/msg38564.html

But, as stated in the thread above, I think we should go a step further
and remove FUTEX_OP_{OR,ANDN,XOR,OPARG_SHIFT} altogether. They don't
appear to be used by userspace, and this whole thing is a total mess.

Any thoughts?

Will

  reply	other threads:[~2017-05-15 13:16 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15 13:07 [PATCH 1/1] futex: remove duplicated code Jiri Slaby
2017-05-15 13:07 ` Jiri Slaby
2017-05-15 13:07 ` [OpenRISC] " Jiri Slaby
2017-05-15 13:07 ` Jiri Slaby
2017-05-15 13:07 ` Jiri Slaby
2017-05-15 13:07 ` Jiri Slaby
2017-05-15 13:07 ` Jiri Slaby
2017-05-15 13:16 ` Will Deacon [this message]
2017-05-15 13:16   ` Will Deacon
2017-05-15 13:16   ` [OpenRISC] " Will Deacon
2017-05-15 13:16   ` Will Deacon
2017-05-15 13:16   ` Will Deacon
2017-05-15 13:16   ` Will Deacon
2017-05-15 13:16   ` Will Deacon
2017-05-17  8:01   ` Jiri Slaby
2017-05-17  8:01     ` Jiri Slaby
2017-05-17  8:01     ` [OpenRISC] " Jiri Slaby
2017-05-17  8:01     ` Jiri Slaby
2017-05-17  8:01     ` Jiri Slaby
2017-05-17  8:01     ` Jiri Slaby
2017-05-17  8:01     ` Jiri Slaby
2017-05-18 17:30     ` Will Deacon
2017-05-18 17:30       ` Will Deacon
2017-05-18 17:30       ` [OpenRISC] " Will Deacon
2017-05-18 17:30       ` Will Deacon
2017-05-18 17:30       ` Will Deacon
2017-05-18 17:30       ` Will Deacon
2017-05-18 17:30       ` Will Deacon
2017-05-22 21:11   ` Thomas Gleixner
2017-05-22 21:11     ` Thomas Gleixner
2017-05-22 21:11     ` [OpenRISC] " Thomas Gleixner
2017-05-22 21:11     ` Thomas Gleixner
2017-05-22 21:11     ` Thomas Gleixner
2017-05-22 21:11     ` Thomas Gleixner
2017-05-22 21:11     ` Thomas Gleixner
2017-05-25 14:28     ` Will Deacon
2017-05-25 14:28       ` Will Deacon
2017-05-25 14:28       ` [OpenRISC] " Will Deacon
2017-05-25 14:28       ` Will Deacon
2017-05-25 14:28       ` Will Deacon
2017-05-25 14:28       ` Will Deacon
2017-05-25 14:28       ` Will Deacon
2017-05-26  6:54       ` Thomas Gleixner
2017-05-26  6:54         ` Thomas Gleixner
2017-05-26  6:54         ` [OpenRISC] " Thomas Gleixner
2017-05-26  6:54         ` Thomas Gleixner
2017-05-26  6:54         ` Thomas Gleixner
2017-05-26  6:54         ` Thomas Gleixner
2017-05-26  6:54         ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2017-06-21 11:53 [PATCH 1/1] futex: remove duplicated code and fix UB Jiri Slaby
2017-06-21 11:53 ` Jiri Slaby
2017-06-21 11:53 ` Jiri Slaby
2017-06-21 11:53 ` Jiri Slaby
2017-06-21 11:53 ` Jiri Slaby
2017-06-21 11:53 ` Jiri Slaby
2017-06-22  3:53 ` Darren Hart
2017-06-22  3:53   ` Darren Hart
2017-06-22  3:53   ` Darren Hart
2017-06-22  3:53   ` Darren Hart
2017-06-22  3:53   ` Darren Hart
2017-06-22  3:53   ` Darren Hart
2017-06-23  7:51 ` Thomas Gleixner
2017-06-23  7:51   ` Thomas Gleixner
2017-06-23  7:51   ` Thomas Gleixner
2017-06-23  7:51   ` Thomas Gleixner
2017-06-23  7:51   ` Thomas Gleixner
2017-06-23  7:51   ` Thomas Gleixner
2017-06-23  7:51   ` Thomas Gleixner
2017-06-26 12:02   ` Jiri Slaby
2017-06-26 12:02     ` Jiri Slaby
2017-06-26 12:02     ` Jiri Slaby
2017-06-26 12:02     ` Jiri Slaby
2017-06-26 12:02     ` Jiri Slaby
2017-06-26 12:08     ` Will Deacon
2017-06-26 12:08       ` Will Deacon
2017-06-26 12:08       ` Will Deacon
2017-06-26 12:08       ` Will Deacon
2017-06-26 12:08       ` Will Deacon
2017-07-03 10:18     ` Thomas Gleixner
2017-07-03 10:18       ` Thomas Gleixner
2017-07-03 10:18       ` Thomas Gleixner
2017-07-03 10:18       ` Thomas Gleixner
2017-07-03 10:18       ` Thomas Gleixner
2017-07-03 10:18       ` Thomas Gleixner
2017-07-03 10:18       ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170515131644.GA3605@arm.com \
    --to=will.deacon@arm.com \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=deller@gmx.de \
    --cc=fenghua.yu@intel.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jejb@parisc-linux.org \
    --cc=jonas@southpole.se \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=monstr@monstr.eu \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=rkuo@codeaurora.org \
    --cc=rth@twiddle.net \
    --cc=schwidefsky@de.ibm.com \
    --cc=shorne@gmail.com \
    --cc=stefan.kristiansson@saunalahti.fi \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=vgupta@synopsys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.