Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9025200pxu; Mon, 28 Dec 2020 04:45:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwc7uhpMUT43TTCaNwO3hlN0Yh35+oO7yqR4/F1hXNOsWxwKfiPiJsoio9hUk22xFRiep8g X-Received: by 2002:aa7:c652:: with SMTP id z18mr40550487edr.60.1609159539375; Mon, 28 Dec 2020 04:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609159539; cv=none; d=google.com; s=arc-20160816; b=GJOpi083m9KzAqFjz8VdOEPRxpsdKPAt05dOHfrjZJg1weKbXjUW8rzsFzaYtLlY0B 807cPXmh4/xhqmgHt+8SAJyQzfyajQJP9CufgRFktQbIdSMyHM9AeDGnhSMJd2gJZBjJ +5SuZ6wvPEdtpZcf36j6K9QZrsl3hlYK64NDiDf3qjVrxh5RDwmCOGyH60dEIv1tjiQp N/WKlW2Ti1VpLqJFLYmQEW1uGhHN2FOE+k2YNz3P2qr5QxBDd8dZPRd4laSE3NAlmSy8 8GtnuI/vgMIIYSi6sbwZ0vpOhOLj2OVCfm4rR2WsPsMWgoYd5xBblPaX5nt+iuy+flVk LLkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=vI5Ejg0c9pPA0nRy89EGfL2mTFil+KVlTZjDL4PqgyI=; b=UKcD+mqWrhLtZPy7HfOU6+UInUJzR22WqczZPa3YG6d7sSEP+zV7kWZzUs0d5eco6t J2VTm2UruUUHPtB53Ri/2YZ4ya4gb/lNOdgmdf7DOYhlSpzspbrOKACwk2v3igdb7xR8 ppIgjRHNOYHd/Gvdo+QeljvWoY1un2Swzkednw0fD5abbEEnTbTvPqyq0qJ93mBsbpir HVdbD9OsXIwG5MX5Ybb0tqWj+rfCZSaLyjD4dO94RqVAp0GC8DnOfjz+yVBki9ADCzLF KdaLPBCfzdQm2ajgiVuDQ7JQCH/eUDMdJg8RBewQ1QNKAZErDODwv+eDTSFqYtLLpirs gq4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e5Nkxk2e; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si19837487edd.26.2020.12.28.04.45.16; Mon, 28 Dec 2020 04:45:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e5Nkxk2e; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbgL1Mok (ORCPT + 99 others); Mon, 28 Dec 2020 07:44:40 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:50834 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbgL1Mok (ORCPT ); Mon, 28 Dec 2020 07:44:40 -0500 Date: Mon, 28 Dec 2020 12:43:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1609159437; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vI5Ejg0c9pPA0nRy89EGfL2mTFil+KVlTZjDL4PqgyI=; b=e5Nkxk2e1rX7M+dDhrXoXERfNEDe7jYRML/k2LAgSRjc2czvPpHCctqkroic7Sg9dNY3bl 1QLZTNwQyOs+i/rfP5uhjQ6oO0FQl3HfbExJqu2v0mvHudUW9MRjGt6N1qkD2P4ARss15o EgJWt3sY4Uwm5KLbU16Gl7mQB50b7riwbiU+qXm4anE5k4mxjfgsSuXw46AXnuNsJI0mKb VvUzA+VaN+F+F/Rahk5i0ErgNkoqfuelMNaJjoW7NjJ2ArNctE82hqRdL51h+CiLg6X89O vS5Oe58u1jkGS81VVBNqvp3a4QqIf1IFYiwr5VJ1AWOEtz0nhbUIHX3liA8A+Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1609159437; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vI5Ejg0c9pPA0nRy89EGfL2mTFil+KVlTZjDL4PqgyI=; b=QslU7CoSkegyU+blU7ZogeKI5RUyUawNzH2b0FMYNOBf8V16KCgGxW/MoNISsixZ7CsP/E ECGTze6tb01Py5DQ== From: "tip-bot2 for Brian Gerst" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] fanotify: Fix sys_fanotify_mark() on native x86-32 Cc: pawel@jasiak.xyz, Brian Gerst , Borislav Petkov , Jan Kara , Andy Lutomirski , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20201130223059.101286-1-brgerst@gmail.com> References: <20201130223059.101286-1-brgerst@gmail.com> MIME-Version: 1.0 Message-ID: <160915943610.414.834531552346912074.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 2ca408d9c749c32288bc28725f9f12ba30299e8f Gitweb: https://git.kernel.org/tip/2ca408d9c749c32288bc28725f9f12ba302= 99e8f Author: Brian Gerst AuthorDate: Mon, 30 Nov 2020 17:30:59 -05:00 Committer: Borislav Petkov CommitterDate: Mon, 28 Dec 2020 11:58:59 +01:00 fanotify: Fix sys_fanotify_mark() on native x86-32 Commit 121b32a58a3a ("x86/entry/32: Use IA32-specific wrappers for syscalls taking= 64-bit arguments") converted native x86-32 which take 64-bit arguments to use the compat handlers to allow conversion to passing args via pt_regs. sys_fanotify_mark() was however missed, as it has a general compat handler. Add a config option that will use the syscall wrapper that takes the split args for native 32-bit. [ bp: Fix typo in Kconfig help text. ] Fixes: 121b32a58a3a ("x86/entry/32: Use IA32-specific wrappers for syscalls t= aking 64-bit arguments") Reported-by: Pawe=C5=82 Jasiak Signed-off-by: Brian Gerst Signed-off-by: Borislav Petkov Acked-by: Jan Kara Acked-by: Andy Lutomirski Link: https://lkml.kernel.org/r/20201130223059.101286-1-brgerst@gmail.com --- arch/Kconfig | 6 ++++++ arch/x86/Kconfig | 1 + fs/notify/fanotify/fanotify_user.c | 17 +++++++---------- include/linux/syscalls.h | 24 ++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 78c6f05..24862d1 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1105,6 +1105,12 @@ config HAVE_ARCH_PFN_VALID config ARCH_SUPPORTS_DEBUG_PAGEALLOC bool =20 +config ARCH_SPLIT_ARG64 + bool + help + If a 32-bit architecture requires 64-bit arguments to be split into + pairs of 32-bit arguments, select this option. + source "kernel/gcov/Kconfig" =20 source "scripts/gcc-plugins/Kconfig" diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7b6dd10..21f8511 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -19,6 +19,7 @@ config X86_32 select KMAP_LOCAL select MODULES_USE_ELF_REL select OLD_SIGACTION + select ARCH_SPLIT_ARG64 =20 config X86_64 def_bool y diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify= _user.c index 3e01d8f..dcab112 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1285,26 +1285,23 @@ fput_and_out: return ret; } =20 +#ifndef CONFIG_ARCH_SPLIT_ARG64 SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, __u64, mask, int, dfd, const char __user *, pathname) { return do_fanotify_mark(fanotify_fd, flags, mask, dfd, pathname); } +#endif =20 -#ifdef CONFIG_COMPAT -COMPAT_SYSCALL_DEFINE6(fanotify_mark, +#if defined(CONFIG_ARCH_SPLIT_ARG64) || defined(CONFIG_COMPAT) +SYSCALL32_DEFINE6(fanotify_mark, int, fanotify_fd, unsigned int, flags, - __u32, mask0, __u32, mask1, int, dfd, + SC_ARG64(mask), int, dfd, const char __user *, pathname) { - return do_fanotify_mark(fanotify_fd, flags, -#ifdef __BIG_ENDIAN - ((__u64)mask0 << 32) | mask1, -#else - ((__u64)mask1 << 32) | mask0, -#endif - dfd, pathname); + return do_fanotify_mark(fanotify_fd, flags, SC_VAL64(__u64, mask), + dfd, pathname); } #endif =20 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index f3929af..7688bc9 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -251,6 +251,30 @@ static inline int is_syscall_trace_event(struct trace_ev= ent_call *tp_event) static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) #endif /* __SYSCALL_DEFINEx */ =20 +/* For split 64-bit arguments on 32-bit architectures */ +#ifdef __LITTLE_ENDIAN +#define SC_ARG64(name) u32, name##_lo, u32, name##_hi +#else +#define SC_ARG64(name) u32, name##_hi, u32, name##_lo +#endif +#define SC_VAL64(type, name) ((type) name##_hi << 32 | name##_lo) + +#ifdef CONFIG_COMPAT +#define SYSCALL32_DEFINE1 COMPAT_SYSCALL_DEFINE1 +#define SYSCALL32_DEFINE2 COMPAT_SYSCALL_DEFINE2 +#define SYSCALL32_DEFINE3 COMPAT_SYSCALL_DEFINE3 +#define SYSCALL32_DEFINE4 COMPAT_SYSCALL_DEFINE4 +#define SYSCALL32_DEFINE5 COMPAT_SYSCALL_DEFINE5 +#define SYSCALL32_DEFINE6 COMPAT_SYSCALL_DEFINE6 +#else +#define SYSCALL32_DEFINE1 SYSCALL_DEFINE1 +#define SYSCALL32_DEFINE2 SYSCALL_DEFINE2 +#define SYSCALL32_DEFINE3 SYSCALL_DEFINE3 +#define SYSCALL32_DEFINE4 SYSCALL_DEFINE4 +#define SYSCALL32_DEFINE5 SYSCALL_DEFINE5 +#define SYSCALL32_DEFINE6 SYSCALL_DEFINE6 +#endif + /* * Called before coming back to user-mode. Returning to user-mode with an * address limit different than USER_DS can allow to overwrite kernel memory.