Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbdINVdT (ORCPT ); Thu, 14 Sep 2017 17:33:19 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:40536 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751335AbdINVdS (ORCPT ); Thu, 14 Sep 2017 17:33:18 -0400 Date: Fri, 15 Sep 2017 00:33:16 +0300 From: "Dmitry V. Levin" To: Andy Lutomirski Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , X86 ML , Oleg Nesterov , Eugene Syromyatnikov , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] x86/asm/64: do not clear high 32 bits of syscall number when CONFIG_X86_X32=y Message-ID: <20170914213316.GB17533@altlinux.org> Mail-Followup-To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , X86 ML , Oleg Nesterov , Eugene Syromyatnikov , "linux-kernel@vger.kernel.org" References: <20170912225756.GA19364@altlinux.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="U+BazGySraz5kW0T" Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3029 Lines: 89 --U+BazGySraz5kW0T Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 14, 2017 at 02:05:04PM -0700, Andy Lutomirski wrote: > On Tue, Sep 12, 2017 at 3:57 PM, Dmitry V. Levin wrote: > > Before this change, CONFIG_X86_X32=3Dy fastpath behaviour was different > > from slowpath: > > > > $ gcc -xc -Wall -O2 - <<'EOF' > > #include > > #include > > int main(void) { > > unsigned long nr =3D ~0xffffffffUL | __NR_exit; > > return !!syscall(nr, 42, 1, 2, 3, 4, 5); > > } > > EOF > > $ ./a.out; echo \$?=3D$? > > $?=3D42 > > $ strace -enone ./a.out > > syscall_18446744069414584380(0x2a, 0x1, 0x2, 0x3, 0x4, 0x5) =3D -1 (err= no 38) > > +++ exited with 1 +++ > > > > This change syncs CONFIG_X86_X32=3Dy fastpath behaviour with the case > > when CONFIG_X86_X32 is not enabled. >=20 > Do you see real brokenness here, or is it just weird? It's definitely broken. A syscall should be either valid or invalid regardless of implementation peculiarities like fastpath vs slowpath. > > Fixes: fca460f95e92 ("x32: Handle the x32 system call flag") > > Cc: stable@vger.kernel.org > > Signed-off-by: Dmitry V. Levin > > --- > > arch/x86/entry/entry_64.S | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > > index 4916725..3bab6af 100644 > > --- a/arch/x86/entry/entry_64.S > > +++ b/arch/x86/entry/entry_64.S > > @@ -185,12 +185,10 @@ entry_SYSCALL_64_fastpath: > > */ > > TRACE_IRQS_ON > > ENABLE_INTERRUPTS(CLBR_NONE) > > -#if __SYSCALL_MASK =3D=3D ~0 > > - cmpq $__NR_syscall_max, %rax > > -#else > > - andl $__SYSCALL_MASK, %eax > > - cmpl $__NR_syscall_max, %eax > > +#if __SYSCALL_MASK !=3D ~0 > > + andq $__SYSCALL_MASK, %rax > > #endif > > + cmpq $__NR_syscall_max, %rax >=20 > I don't know much about x32 userspace, but there's an argument that > the high bits *should* be masked off if the x32 bit is set. Why? --=20 ldv --U+BazGySraz5kW0T Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJZuvWcAAoJEAVFT+BVnCUI/dcQANUR8vTvZg+PKHnYVkuyspDL qzKdZwtOEFKT0WTDkhD8FkYplqxXY3cCpGHJRDt+qIk58FmBrbQn6eqD8CN5+ZRz 1dyA9orSWxQ7oBqtWHraADASv8Z2iWDuBE6jI4y6LhE6XC0SjZjZfurPDhk55BKF rNxXOrMd7tWYgUDOhZDdufvPAOdbFTcOs1mPi8gLGUg2yXaSdKcMPCJZSAe8Vmdl cTTCBdnsnbszvWpal3VrmEIo4UyUTVUnEFebhO2WSS9yN3fF7gtU9NtX3JWV6qeB UOLoEPmwuyD19d7S1Xt+pEf0D06Tg8sOoYhPw/1Lkfru7JXBkI4ozGT0un2bp9dn 61pV0lkfz8ia+TzegnTnb2UOT337PyGgite+fjJAu09uVJkoUr5qZjXw5mTKgEsb h/9mjq40A5QvN1M30voKF/t5uVmNdVb25pFz+A4GDYejy877lo13AbaI6CvuB9Cr vHzBM7qqHkx/t6Bb4h043Ws36t0ZAcGBKvzL30spX666dV92rrRHoB+UcguLx6gg Zu8N4hFgzsGIQdKywhKytfTejP7bCEYO5HWh9b0WtwA2RwPCNOAG6jYNfIjxz8q4 IyKiD/eUIeJB2X4yuJ7atp+hnQMDavws2xZn2p580Hl28HWDoVKg1z7iYsxbKOBG yFEsQLri7UgCITKQlNJB =ocOI -----END PGP SIGNATURE----- --U+BazGySraz5kW0T--