All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: "Paweł Jasiak" <pawel@jasiak.xyz>
Cc: Jan Kara <jack@suse.cz>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Brian Gerst <brgerst@gmail.com>,
	Andy Lutomirski <luto@kernel.org>
Subject: Re: PROBLEM: fanotify_mark EFAULT on x86
Date: Mon, 23 Nov 2020 17:46:22 +0100	[thread overview]
Message-ID: <20201123164622.GJ27294@quack2.suse.cz> (raw)
In-Reply-To: <20201103211747.GA3688@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

On Tue 03-11-20 22:17:47, Paweł Jasiak wrote:
> I have written small patch that fixes problem for me and doesn't break
> x86_64.

OK, with a help of Boris Petkov I think I have a fix that looks correct
(attach). Can you please try whether it works for you? Thanks!

								Honza

> 
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 3e01d8f2ab90..cf0b97309975 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -1285,12 +1285,27 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
>  	return ret;
>  }
>  
> +#if defined(CONFIG_X86) && !defined(CONFIG_64BIT)
> +SYSCALL_DEFINE6(fanotify_mark,
> +			int, fanotify_fd, unsigned int, flags, __u32, mask0,
> +			__u32, mask1, 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);
> +}
> +#else
>  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
>  
>  #ifdef CONFIG_COMPAT
>  COMPAT_SYSCALL_DEFINE6(fanotify_mark,
> 
> 
> -- 
> 
> Paweł Jasiak
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[-- Attachment #2: 0001-fanotify-Fix-fanotify_mark-on-32-bit-archs.patch --]
[-- Type: text/x-patch, Size: 2201 bytes --]

From fc9104a50a774ec198c1e3a145372cde77df7967 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Mon, 23 Nov 2020 17:37:00 +0100
Subject: [PATCH] fanotify: Fix fanotify_mark() on 32-bit archs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit converting syscalls taking 64-bit arguments to new scheme of compat
handlers omitted converting fanotify_mark(2) which then broke the
syscall for 32-bit ABI. Add missed conversion.

CC: Brian Gerst <brgerst@gmail.com>
Suggested-by: Borislav Petkov <bp@suse.de>
Reported-by: Paweł Jasiak <pawel@jasiak.xyz>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Fixes: 121b32a58a3a ("x86/entry/32: Use IA32-specific wrappers for syscalls taking 64-bit arguments")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
---
 arch/x86/entry/syscalls/syscall_32.tbl | 2 +-
 fs/notify/fanotify/fanotify_user.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index 0d0667a9fbd7..b2ec6ff88307 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -350,7 +350,7 @@
 336	i386	perf_event_open		sys_perf_event_open
 337	i386	recvmmsg		sys_recvmmsg_time32		compat_sys_recvmmsg_time32
 338	i386	fanotify_init		sys_fanotify_init
-339	i386	fanotify_mark		sys_fanotify_mark		compat_sys_fanotify_mark
+339	i386	fanotify_mark		sys_ia32_fanotify_mark
 340	i386	prlimit64		sys_prlimit64
 341	i386	name_to_handle_at	sys_name_to_handle_at
 342	i386	open_by_handle_at	sys_open_by_handle_at		compat_sys_open_by_handle_at
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 3e01d8f2ab90..e20e7b53a87f 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -1293,7 +1293,7 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
 }
 
 #ifdef CONFIG_COMPAT
-COMPAT_SYSCALL_DEFINE6(fanotify_mark,
+SYSCALL_DEFINE6(ia32_fanotify_mark,
 				int, fanotify_fd, unsigned int, flags,
 				__u32, mask0, __u32, mask1, int, dfd,
 				const char  __user *, pathname)
-- 
2.16.4


  parent reply	other threads:[~2020-11-23 16:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-01 21:27 PROBLEM: fanotify_mark EFAULT on x86 Paweł Jasiak
2020-11-01 21:38 ` Matthew Wilcox
2020-11-01 22:27   ` Paweł Jasiak
2020-11-02 12:26 ` Jan Kara
2020-11-02 17:16   ` Paweł Jasiak
2020-11-03 21:17   ` Paweł Jasiak
2020-11-04 10:14     ` Jan Kara
2020-11-23 16:46     ` Jan Kara [this message]
2020-11-23 22:46       ` Paweł Jasiak
2020-11-24  8:45         ` Borislav Petkov
2020-11-24 10:20           ` Jan Kara
2020-11-24 10:28             ` Borislav Petkov
2020-11-26 10:48               ` Jan Kara
2020-11-26 10:52                 ` Borislav Petkov
2020-11-25 19:31             ` Naresh Kamboju
2020-11-26 10:48               ` Jan Kara
2020-11-23 23:07       ` [PATCH] fanotify: Fix fanotify_mark() on 32-bit archs kernel test robot
2020-11-23 23:07         ` kernel test robot

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=20201123164622.GJ27294@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=brgerst@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=pawel@jasiak.xyz \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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.