From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] stime: Only o32 system calls require 32-bit programs on mips
Date: Tue, 20 Jul 2021 11:40:36 +0200 [thread overview]
Message-ID: <YPaaFAdTO9coCUxN@pevik> (raw)
In-Reply-To: <045e5fc2-05a7-e006-3bb6-2f536c5634b4@uniontech.com>
Hi zhanglianjie,
[ Cc Thomas Bogendoerfer, MIPS kernel maintainer ]
> On 2021-07-20 15:56, Petr Vorel wrote:
> > Hi zhanglianjie,
> > > The stime() system call is only o32, not n32 and n64. If you do not
> > > specify that the current program is compiled to 32-bit when compiling
> > > the program on mips, the stime() system call will fail when the
> > > program is running.
> > You're right that stime() is only on o32. But tst_syscall() should catch that.
> > Or does it set different errno than ENOSYS?
> The returned errno is EFAULT. The o32 system call of stime is implemented on
> mips, so ENOSYS will not be returned.
I see.
> COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
> {
> ...
> if (get_user(tv.tv_sec, tptr))
> return -EFAULT;
> ...
> }
> The tptr address is in the user space 0x120010da0, and after the system
> call, it is 0x20010da0 in the kernel state, and the upper 32 bits are set to
> 0, resulting in a failure to copy data from the user space to the kernel
> space.
Thanks for explanation.
> This patch needs to be modified and cannot affect other architectures.
Yes, o2 has to fixed, but agree that this would affect other archs which
supports __NR_stime, i.e. i386 now also complains:
stime_var.h:31: TCONF: the stime() syscall only o32 ABI in mips, make sure the current program is 32-bit
but it should stay:
stime02.c:37: TPASS: stime(2) fails, Caller not root: EPERM (1)
> > ...
> > > +#if defined(__mips__) && _MIPS_SZLONG == 32
Not sure if this would work to whitelist only mips n32 and n64 (keep mips o32
and all other archs):
#if ! defined(_MIPS_SZLONG) || _MIPS_SZLONG == 32
Kind regards,
Petr
> > > return tst_syscall(__NR_stime, ntime);
> > > +#else
> > > + tst_brk(TCONF, "the stime() syscall only o32 ABI in mips, make sure the current program is 32-bit");
> > > +#endif
next prev parent reply other threads:[~2021-07-20 9:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-20 6:38 [LTP] [PATCH] stime: Only o32 system calls require 32-bit programs on mips zhanglianjie
2021-07-20 7:56 ` Petr Vorel
2021-07-20 8:17 ` zhanglianjie
2021-07-20 9:40 ` Petr Vorel [this message]
2021-07-21 1:57 ` zhanglianjie
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=YPaaFAdTO9coCUxN@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/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