From: "Arnd Bergmann" <arnd@arndb.de>
To: "Daniel Palmer" <daniel@0x0f.com>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Greg Ungerer" <gerg@linux-m68k.org>,
linux-m68k@lists.linux-m68k.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] m68k: Define the m68k-specific syscalls with SYSCALL_DEFINE
Date: Tue, 24 Nov 2026 08:05:52 +0100 [thread overview]
Message-ID: <8d2febd9-3912-410d-898c-16500d2692a1@app.fastmail.com> (raw)
In-Reply-To: <20261124025555.2348580-1-daniel@0x0f.com>
On Tue, Nov 24, 2026, at 03:55, Daniel Palmer wrote:
> On m68k a syscall handler's stack arguments are the user's registers
> saved in pt_regs, and RESTORE_ALL reloads them on the way out. The C
> ABI lets a function reuse its incoming argument slots, so anything the
> handler writes there ends up in user space. SYSCALL_DEFINEn() stops
> the compiler doing that with asmlinkage_protect(), but sys_mmap2() and
> the other m68k-specific syscalls are plain asmlinkage functions.
>
> With GCC 16 and a kernel built with -O2, sys_mmap2() becomes a tail
> call to ksys_mmap_pgoff(), which builds its call to vm_mmap_pgoff() by
> shifting its arguments up one slot in place. User space gets d2-d5
> back holding addr/len/prot/flags.
>
> This issue was noticed in nolibc programs that are using mmap() and
> I initially thought nolibc's m68k support was to blame.
>
> Define sys_mmap2(), sys_cacheflush(), sys_atomic_cmpxchg_32() and
> sys_set_thread_area() with SYSCALL_DEFINEn() so their arguments are
> protected, and make their prototypes in asm/syscalls.h return long to
> match.
>
> Fixes: a90f590a1bee ("mm: add ksys_mmap_pgoff() helper; remove
> in-kernel calls to sys_mmap_pgoff()")
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
This looks all good to me, nice analysis and description!
With the follow-up fix you posted
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
It would be nice to also wrap the other four syscalls that don't
take an argument for consistency and also have them use
SYSCALL_DEFINE0(). Can you add a second patch for that?
Arnd
prev parent reply other threads:[~2026-11-24 7:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 2:55 Daniel Palmer
2026-11-24 3:45 ` Daniel Palmer
2026-11-24 7:05 ` Arnd Bergmann [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=8d2febd9-3912-410d-898c-16500d2692a1@app.fastmail.com \
--to=arnd@arndb.de \
--cc=daniel@0x0f.com \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.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®