From: Jan Kara <jack@suse.cz>
To: "Paweł Jasiak" <pawel@jasiak.xyz>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
jack@suse.cz, 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, 2 Nov 2020 13:26:38 +0100 [thread overview]
Message-ID: <20201102122638.GB23988@quack2.suse.cz> (raw)
In-Reply-To: <20201101212738.GA16924@gmail.com>
On Sun 01-11-20 22:27:38, Paweł Jasiak wrote:
> I am trying to run examples from man fanotify.7 but fanotify_mark always
> fail with errno = EFAULT.
>
> fanotify_mark declaration is
>
> SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
> __u64, mask, int, dfd,
> const char __user *, pathname)
>
> When
>
> fanotify_mark(4, FAN_MARK_ADD | FAN_MARK_ONLYDIR,
> FAN_CREATE | FAN_ONDIR, AT_FDCWD, 0xdeadc0de)
>
> is called on kernel side I can see in do_syscall_32_irqs_on that CPU
> context is
> bx = 0x4 = 4
> cx = 0x9 = FAN_MARK_ADD | FAN_MARK_ONLYDIR,
> dx = 0x40000100 = FAN_CREATE | FAN_ONDIR
> si = 0x0
> di = 0xffffff9c = AT_FDCWD
> bp = 0xdeadc0de
> ax = 0xffffffda
> orix_ax = 0x153
>
> I am not sure if it is ok because third argument is uint64_t so if I
> understand correctly mask should be divided into two registers (dx and
> si).
>
> But in fanotify_mark we get
> fanotify_fd = 4 = bx
> flags = 0x9 = cx
> mask = 0x40000100 = dx
> dfd = 0 = si
> pathname = 0xffffff9c = di
>
> I believe that correct order is
> fanotify_fd = 4 = bx
> flags = 0x9 = cx
> mask = 0x40000100 = (si << 32) | dx
> dfd = 0xffffff9c = di
> pathname = 0xdeadc0de = bp
>
> I think that we should call COMPAT version of fanotify_mark here
>
> COMPAT_SYSCALL_DEFINE6(fanotify_mark,
> int, fanotify_fd, unsigned int, flags,
> __u32, mask0, __u32, mask1, int, dfd,
> const char __user *, pathname)
>
> or something wrong is with 64-bits arguments.
>
> I am running Linux 5.9.2 i686 on Pentium III (Coppermine).
> For tests I am using Debian sid on qemu with 5.9.2 and default kernel
> from repositories.
>
> Everything works fine on 5.5 and 5.4.
Strange. Thanks for report. Looks like some issue got created / exposed
somewhere between 5.5 and 5.9 (actually probably between 5.5 and 5.7
because the Linaro report you mentioned [1] is from 5.7-rc6). There were
no changes in this area in fanotify, I think it must have been some x86
change that triggered this. Hum, looking into x86 changelog in that time
range there was a series rewriting 32-bit ABI [2] that got merged into
5.7-rc1. Can you perhaps check whether 5.6 is good and 5.7-rc1 is bad?
Brian, any idea whether your series could regress fanotify_mark(2) syscall?
Do we have somewhere documented which syscalls need compat wrappers and how
they should look like?
Honza
[1] https://lists.linux.it/pipermail/ltp/2020-June/017436.html
[2] https://lore.kernel.org/lkml/20200313195144.164260-1-brgerst@gmail.com/
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-11-02 12:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-01 21:27 Paweł Jasiak
2020-11-01 21:38 ` Matthew Wilcox
2020-11-01 22:27 ` Paweł Jasiak
2020-11-02 12:26 ` Jan Kara [this message]
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
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
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=20201102122638.GB23988@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®