linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] mips ptrace32.c and compat_ptr()
@ 2019-04-01  0:01 Al Viro
  2019-04-03 21:59 ` Paul Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Al Viro @ 2019-04-01  0:01 UTC (permalink / raw)
  To: linux-mips; +Cc: Ralf Baechle

	There's something odd going on:

1)
static inline void __user *compat_ptr(compat_uptr_t uptr)
{
        /* cast to a __user pointer via "unsigned long" makes sparse happy */
        return (void __user *)(unsigned long)(long)uptr;
}

Huh?  The first impression is that it wants to sign-extend
the argument, but... compat_uptr_t is and always had been
unsigned.  Initially it went
+typedef u32            compat_uptr_t;
+
+static inline void *compat_ptr(compat_uptr_t uptr)
+{
+       return (void *)(long)uptr;
+}
so there never had been any sign-extension in that thing.
So what is that cast to long in the current version about?

2)
long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
                        compat_ulong_t caddr, compat_ulong_t cdata)
{
        int addr = caddr;
        int data = cdata;
...
                ret = put_user(tmp, (u32 __user *) (unsigned long) data);
                break;
and quite a few similar in the same function.  Here we _do_ get sign
extension.  Which is bloody odd, seeing that all other compat syscalls
end up using compat_ptr(), either explicitly or in the syscall glue.

Shouldn't it be doing
                ret = put_user(tmp, (u32 __user *)compat_ptr(cdata));
                break;
instead?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-03 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-01  0:01 [RFC] mips ptrace32.c and compat_ptr() Al Viro
2019-04-03 21:59 ` Paul Burton

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).