From: Yury Norov <yury.norov@gmail.com>
To: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Cc: bobo.shaobowang@huawei.com,
Catalin Marinas <catalin.marinas@arm.com>,
Arnd Bergmann <arnd@arndb.de>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
Adam Borowski <kilobyte@angband.pl>,
Alexander Graf <agraf@suse.de>,
Alexey Klimov <klimov.linux@gmail.com>,
Andreas Schwab <schwab@suse.de>,
Andrew Pinski <pinskia@gmail.com>,
Bamvor Zhangjian <bamv2005@gmail.com>,
Chris Metcalf <cmetcalf@mellanox.com>,
Christoph Muellner <christoph.muellner@theobroma-systems.com>,
Dave Martin <Dave.Martin@arm.com>,
"David S . Miller" <davem@davemloft.net>,
Florian Weimer <fweimer@redhat.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
James Hogan <james.hogan@imgtec.com>,
James Morse <james.morse@arm.com>,
Joseph Myers <joseph@codesourcery.com>,
Lin Yongting <linyongting@huawei.com>,
Manuel Montezelo <manuel.montezelo@gmail.com>,
Mark Brown <broonie@kernel.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
Nathan_Lynch <Nathan_Lynch@mentor.com>,
Philipp Tomsich <philipp.tomsich@theobroma-systems.com>,
Prasun Kapoor <Prasun.Kapoor@caviumnetworks.com>,
Ramana Radhakrishnan <ramana.gcc@googlemail.com>,
Steve Ellcey <sellcey@caviumnetworks.com>,
Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: Re: [Question] About SECCOMP issue for ILP32
Date: Wed, 25 Nov 2020 10:14:42 -0800 [thread overview]
Message-ID: <CAAH8bW8Zo1U3oMu5Gggp-MyNNZ8_WieQn+GKYiML93O9sJB=Dg@mail.gmail.com> (raw)
In-Reply-To: <CAAH8bW_p3LJPgOoJgUHt6O0run+LB2RbjnAVpeLn_KCAZKNR+A@mail.gmail.com>
On Mon, Aug 31, 2020 at 11:15 AM Yury Norov <yury.norov@gmail.com> wrote:
>
> On Mon, Aug 31, 2020 at 5:48 AM Xiongfeng Wang
> <wangxiongfeng2@huawei.com> wrote:
> >
> > Hi Yury,
> >
>
> Hi Xiongfeng,
>
> [restore CC list]
>
> Haven't seen this before. What kernel / glibc / ltp do you use?
>
> > We were testing the ILP32 feature and came accross a problem. Very apperaciate
> > it if you could give us some help !
> >
> > We compile the LTP testsuite with '-mabi=ilp32' and run it on a machine with
> > kernel and glibc applied with ILP32 patches. But we failed on one testcase,
> > prctl04. It print the following error info.
> > 'prctl04.c:199: FAIL: SECCOMP_MODE_STRICT doesn't permit read(2) write(2) and
> > _exit(2)'
> >
> > The testcase is like below, syscall 'prctl' followed by a syscall 'write'.
> > prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);
> > SAFE_WRITE(1, fd, "a", 1);
> >
> > When we execute syscall 'write', we receive a SIGKILL. It's not as expected.
> > We track the kernel and found out it is because we failed the syscall_whitelist
> > check in '__secure_computing_strict'. Because flag 'TIF_32BIT_AARCH64' is set,
> > we falls into the 'in_compat_syscall()' branch. We compare the parameter
> > 'this_syscall' with return value of 'get_compat_model_syscalls()'
> > The syscall number of '__NR_write' for ilp32 application is 64, but it is 4 for
> > 'model_syscalls_32' returned from 'get_compat_model_syscalls()'
> > So '__secure_computing_strict' retuned with 'do_exit(SIGKILL)'. We have a
> > modification like below, but I am not sure if it correct or not.
> >
> > --- a/kernel/seccomp.c
> > +++ b/kernel/seccomp.c
> > @@ -618,7 +618,7 @@ static void __secure_computing_strict(int this_syscall)
> > {
> > const int *syscall_whitelist = mode1_syscalls;
> > #ifdef CONFIG_COMPAT
> > - if (in_compat_syscall())
> > + if (is_a32_compat_task())
> > syscall_whitelist = get_compat_mode1_syscalls();
>
> It calls the arch function from generic code. It may break build for
> other arches.
> This also looks dangerous because it treats ILP32 execution as non-compat.
>
> The right approach would be implementing arch-specific
> get_compat_mode1_syscalls()
> in arch/arm64/include/asm/seccomp.h that returns an appropriate table.
> Refer MIPS
> code for this: arch/mips/include/asm/seccomp.h
>
> Thanks,
> Yury
>
> > #endif
> > do {
> >
> >
> > Thanks,
> > Xiongfeng
> >
The fix is on my repo; versions 5.2 and 4.19 are updated:
https://github.com/norov/linux/commits/ilp32-4.19
https://github.com/norov/linux/commits/ilp32-5.2
prev parent reply other threads:[~2020-11-25 18:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <30b491ad-a7e1-f7b5-26b8-2cfffc81a080@huawei.com>
2020-08-31 18:15 ` [Question] About SECCOMP issue for ILP32 Yury Norov
2020-09-01 11:40 ` Xiongfeng Wang
2021-12-16 12:03 ` Xiongfeng Wang
2020-11-25 18:14 ` Yury Norov [this message]
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='CAAH8bW8Zo1U3oMu5Gggp-MyNNZ8_WieQn+GKYiML93O9sJB=Dg@mail.gmail.com' \
--to=yury.norov@gmail.com \
--cc=Dave.Martin@arm.com \
--cc=Nathan_Lynch@mentor.com \
--cc=Prasun.Kapoor@caviumnetworks.com \
--cc=agraf@suse.de \
--cc=arnd@arndb.de \
--cc=bamv2005@gmail.com \
--cc=bobo.shaobowang@huawei.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christoph.muellner@theobroma-systems.com \
--cc=cmetcalf@mellanox.com \
--cc=davem@davemloft.net \
--cc=fweimer@redhat.com \
--cc=geert@linux-m68k.org \
--cc=heiko.carstens@de.ibm.com \
--cc=james.hogan@imgtec.com \
--cc=james.morse@arm.com \
--cc=joseph@codesourcery.com \
--cc=kilobyte@angband.pl \
--cc=klimov.linux@gmail.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linyongting@huawei.com \
--cc=manuel.montezelo@gmail.com \
--cc=maxim.kuvyrkov@linaro.org \
--cc=philipp.tomsich@theobroma-systems.com \
--cc=pinskia@gmail.com \
--cc=ramana.gcc@googlemail.com \
--cc=schwab@suse.de \
--cc=schwidefsky@de.ibm.com \
--cc=sellcey@caviumnetworks.com \
--cc=szabolcs.nagy@arm.com \
--cc=wangxiongfeng2@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).