All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Dmitry V. Levin" <ldv@altlinux.org>,
	Elvira Khabirova <lineprinter0@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>, Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 27/39] x86/signal: Fix restart_syscall number for x32 tasks
Date: Mon, 25 Jan 2016 12:50:08 +0100	[thread overview]
Message-ID: <8e8175d601a4f1763ba0a4db42e834e2aeb7bd17.1453722244.git.jslaby@suse.cz> (raw)
In-Reply-To: <d15adb13198353245e982527750b7f04cca1042b.1453722244.git.jslaby@suse.cz>
In-Reply-To: <cover.1453722244.git.jslaby@suse.cz>

From: "Dmitry V. Levin" <ldv@altlinux.org>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit 22eab1108781eff09961ae7001704f7bd8fb1dce upstream.

When restarting a syscall with regs->ax == -ERESTART_RESTARTBLOCK,
regs->ax is assigned to a restart_syscall number.  For x32 tasks, this
syscall number must have __X32_SYSCALL_BIT set, otherwise it will be
an x86_64 syscall number instead of a valid x32 syscall number. This
issue has been there since the introduction of x32.

Reported-by: strace/tests/restart_syscall.test
Reported-and-tested-by: Elvira Khabirova <lineprinter0@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Cc: Elvira Khabirova <lineprinter0@gmail.com>
Link: http://lkml.kernel.org/r/20151130215436.GA25996@altlinux.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/x86/kernel/signal.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index b88fc86309bc..5d3e60156683 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -682,12 +682,15 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
 	signal_setup_done(failed, ksig, test_thread_flag(TIF_SINGLESTEP));
 }
 
-#ifdef CONFIG_X86_32
-#define NR_restart_syscall	__NR_restart_syscall
-#else /* !CONFIG_X86_32 */
-#define NR_restart_syscall	\
-	test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
-#endif /* CONFIG_X86_32 */
+static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
+{
+#if defined(CONFIG_X86_32) || !defined(CONFIG_X86_64)
+	return __NR_restart_syscall;
+#else /* !CONFIG_X86_32 && CONFIG_X86_64 */
+	return test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall :
+		__NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT);
+#endif /* CONFIG_X86_32 || !CONFIG_X86_64 */
+}
 
 /*
  * Note that 'init' is a special process: it doesn't get signals it doesn't
@@ -716,7 +719,7 @@ static void do_signal(struct pt_regs *regs)
 			break;
 
 		case -ERESTART_RESTARTBLOCK:
-			regs->ax = NR_restart_syscall;
+			regs->ax = get_nr_restart_syscall(regs);
 			regs->ip -= 2;
 			break;
 		}
-- 
2.7.0

  parent reply	other threads:[~2016-01-25 11:51 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 11:49 [PATCH 3.12 00/39] 3.12.53-stable review Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 01/39] efi: Disable interrupts around EFI calls, not in the epilog/prolog calls Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 02/39] tools: Add a "make all" rule Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 03/39] ALSA: hda - Fix noise problems on Thinkpad T440s Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 04/39] dlm: make posix locks interruptible Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 05/39] PCI: Drop "setting latency timer" messages Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 06/39] ipv4: Don't increase PMTU with Datagram Too Big message Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 07/39] route: Use ipv4_mtu instead of raw rt_pmtu Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 08/39] SUNRPC: Fix oops when trace sunrpc_task events in nfs client Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 09/39] ring-buffer: Always run per-cpu ring buffer resize with schedule_work_on() Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 10/39] drm/i915: Fix SRC_COPY width on 830/845g Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 11/39] lpfc: Fix null ndlp dereference in target_reset_handler Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 12/39] block: Always check queue limits for cloned requests Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 13/39] Input: aiptek - fix crash on detecting device without endpoints Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 14/39] qla2xxx: Fix hardware lock/unlock issue causing kernel panic Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 15/39] module: remove MODULE_GENERIC_TABLE Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 16/39] staging/dgnc: fix info leak in ioctl Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 17/39] pm: use GFP_ATOMIC when pm core call this function Jiri Slaby
2016-01-25 11:49 ` [PATCH 3.12 18/39] m32r: fix potential NULL-pointer dereference Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 19/39] m68k: handle pgtable_page_ctor() fail Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 20/39] m68k/mm: Check for mm != NULL in do_page_fault() debug code Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 21/39] m68k/mac: Make SCC reset work more reliably Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 22/39] sctp: Prevent soft lockup when sctp_accept() is called during a timeout event Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 23/39] USB: quirks: Fix another ELAN touchscreen Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 24/39] KEYS: Fix race between read and revoke Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 25/39] KEYS: Fix keyring ref leak in join_session_keyring() Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 26/39] udp: properly support MSG_PEEK with truncated buffers Jiri Slaby
2016-01-25 11:50 ` Jiri Slaby [this message]
2016-01-25 11:50 ` [PATCH 3.12 28/39] xen/gntdev: Grant maps should not be subject to NUMA balancing Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 29/39] x86/xen: don't reset vcpu_info on a cancelled suspend Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 30/39] KVM: PPC: Book3S HV: Prohibit setting illegal transaction state in MSR Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 31/39] x86/reboot/quirks: Add iMac10,1 to pci_reboot_dmi_table[] Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 32/39] x86/boot: Double BOOT_HEAP_SIZE to 64KB Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 33/39] ipmi: move timer init to before irq is setup Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 34/39] ALSA: hda - Add Intel Lewisburg device IDs Audio Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 35/39] ALSA: hda - Apply pin fixup for HP ProBook 6550b Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 36/39] MAINTAINERS: Add public mailing list for ARC Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 37/39] ARC: Fix silly typo in MAINTAINERS file commit 30b9dbee895ff0d5cbf155bd1ef3f0f5992bca6f upstream. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 38/39] isdn_ppp: Add checks for allocation failure in isdn_ppp_open() Jiri Slaby
2016-01-25 11:50 ` [PATCH 3.12 39/39] ppp, slip: Validate VJ compression slot parameters completely Jiri Slaby
2016-01-25 14:50 ` [PATCH 3.12 00/39] 3.12.53-stable review Guenter Roeck
2016-01-25 15:05   ` Jiri Slaby
2016-01-25 17:00 ` Shuah Khan

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=8e8175d601a4f1763ba0a4db42e834e2aeb7bd17.1453722244.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=ldv@altlinux.org \
    --cc=lineprinter0@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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.