linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Ralf Baechle <ralf@linux-mips.org>,
	Paul Burton <paulburton@kernel.org>,
	James Hogan <jhogan@kernel.org>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Helge Deller <deller@gmx.de>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Robert Richter <rric@kernel.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	Parisc List <linux-parisc@vger.kernel.org>,
	linuxppc-dev@zytor.com
Subject: Re: [PATCH v3 02/22] compat: provide compat_ptr() on all architectures
Date: Tue, 7 Jan 2020 09:40:05 +0100	[thread overview]
Message-ID: <CAK8P3a21u6FacA-EfGoaVMmd-iXux=wACG5JTpoUZ8cwvNjuOg@mail.gmail.com> (raw)
In-Reply-To: <202001070820.0078K3ZN3264752@mail.zytor.com>

On Tue, Jan 7, 2020 at 9:20 AM H. Peter Anvin <hpa@zytor.com> wrote:
>
> <linuxppc-dev@lists.ozlabs.org>,oprofile-list@lists.sf.net,linux-s390 <linux-s390@vger.kernel.org>,sparclinux <sparclinux@vger.kernel.org>
> From: hpa@zytor.com
> Message-ID: <41625F06-D755-4C82-86DF-A9415FEEE13D@zytor.com>
>
> On January 7, 2020 12:08:31 AM PST, Arnd Bergmann <arnd@arndb.de> wrote:
> >On Tue, Jan 7, 2020 at 3:05 AM Michael Ellerman <mpe@ellerman.id.au>
> >wrote:
> >> Arnd Bergmann <arnd@arndb.de> writes:
> >> > +
> >> > +static inline compat_uptr_t ptr_to_compat(void __user *uptr)
> >> > +{
> >> > +     return (u32)(unsigned long)uptr;
> >> > +}
> >>
> >> Is there a reason we cast to u32 directly instead of using
> >compat_uptr_t?
> >
> >Probably Al found this to be more explicit at the time when he
> >introduced
> >it on all the architectures in 2005. I just moved it here and kept the
> >definition.
> >
> >       Arnd
>
> Did compat_uptr_t exist back then?

Yes, compat_uptr_t (and the earlier compat_ptr_t) goes back
to at least 2003 with the introduction of compat_ptr().

These are some related commits from bitkeeper:

commit 29d04cca305a93cfa90afe1c6440ce5421837213
Author: Stephen Rothwell <sfr@canb.auug.org.au>
Date:   Sun Mar 23 04:59:16 2003 -0800

    [PATCH] compat_uptr_t and compat_ptr

    This creates compat_uptr_t (to represent a user mode pointer passed to
    the kernel other than as a syscall parameter) and compat_ptr() to
    convert it to a kernel pointer.

    This fixes a couple of bugs in s390x (where the conversion of pointers
    actually does something).

diff --git a/include/asm-s390x/compat.h b/include/asm-s390x/compat.h
index 55e23c9b36fe..d1e948ae4bff 100644
--- a/include/asm-s390x/compat.h
+++ b/include/asm-s390x/compat.h
@@ -101,4 +101,17 @@ typedef u32                compat_sigset_word;
 #define COMPAT_OFF_T_MAX       0x7fffffff
 #define COMPAT_LOFF_T_MAX      0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef        u32             compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+       return (void *)(uptr & 0x7fffffffUL);
+}
+
 #endif /* _ASM_S390X_COMPAT_H */


commit 9d814250b08868cb39cc5a4f43f5cbf5e517f5f4
Author: Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Date:   Tue Feb 1 21:21:39 2005 -0800

    [PATCH] sparc64 compat annotations

    same story as for amd64 - ptr_to_compat() + normal __user annotations

    Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
    Signed-off-by: Linus Torvalds <torvalds@osdl.org>

diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h
index 874b136ded90..e26d7d85c55a 100644
--- a/include/asm-sparc64/compat.h
+++ b/include/asm-sparc64/compat.h
@@ -121,6 +121,11 @@ static inline void __user *compat_ptr(compat_uptr_t uptr)
        return (void __user *)(unsigned long)uptr;
 }

+static inline compat_uptr_t ptr_to_compat(void __user *uptr)
+{
+       return (u32)(unsigned long)uptr;
+}
+
 static __inline__ void __user *compat_alloc_user_space(long len)
 {
        struct pt_regs *regs = current_thread_info()->kregs;

  reply	other threads:[~2020-01-07  8:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-02 14:55 [GIT PULL v3 00/27] block, scsi: final compat_ioctl cleanup Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 01/22] compat: ARM64: always include asm-generic/compat.h Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 02/22] compat: provide compat_ptr() on all architectures Arnd Bergmann
2020-01-06 17:40   ` Will Deacon
2020-01-06 17:59   ` H. Peter Anvin
2020-01-07  2:05   ` Michael Ellerman
2020-01-07  8:08     ` Arnd Bergmann
2020-01-07  8:19       ` H. Peter Anvin
2020-01-07  8:40         ` Arnd Bergmann [this message]
2020-01-07 17:51   ` Heiko Carstens
2020-01-02 14:55 ` [PATCH v3 03/22] compat: scsi: sg: fix v3 compat read/write interface Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 04/22] compat_ioctl: block: add blkdev_compat_ptr_ioctl Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 05/22] compat_ioctl: ubd, aoe: use blkdev_compat_ptr_ioctl Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 06/22] compat_ioctl: move CDROM_SEND_PACKET handling into scsi Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 07/22] compat_ioctl: move CDROMREADADIO to cdrom.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 08/22] compat_ioctl: cdrom: handle CDROM_LAST_WRITTEN Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 09/22] compat_ioctl: block: handle cdrom compat ioctl in non-cdrom drivers Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 10/22] compat_ioctl: add scsi_compat_ioctl Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 11/22] compat_ioctl: bsg: add handler Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 12/22] compat_ioctl: ide: floppy: " Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 13/22] compat_ioctl: scsi: move ioctl handling into drivers Arnd Bergmann
2020-01-02 16:33   ` Stefan Hajnoczi
2020-02-12 21:14   ` Johannes Hirte
2020-02-12 21:49     ` Arnd Bergmann
2020-02-13  6:53       ` Johannes Hirte
2020-01-02 14:55 ` [PATCH v3 14/22] compat_ioctl: move sys_compat_ioctl() to ioctl.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 15/22] compat_ioctl: simplify the implementation Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 16/22] compat_ioctl: move cdrom commands into cdrom.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 17/22] compat_ioctl: scsi: handle HDIO commands from drivers Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 18/22] compat_ioctl: move HDIO ioctl handling into drivers/ide Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 19/22] compat_ioctl: block: move blkdev_compat_ioctl() into ioctl.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 20/22] compat_ioctl: block: simplify compat_blkpg_ioctl() Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 21/22] compat_ioctl: simplify up block/ioctl.c Arnd Bergmann
2020-01-02 14:55 ` [PATCH v3 22/22] Documentation: document ioctl interfaces better Arnd Bergmann
2020-01-02 20:22 ` [GIT PULL v3 00/27] block, scsi: final compat_ioctl cleanup Arnd Bergmann
2020-01-03  0:22 ` Ben Hutchings
2020-01-03  8:56   ` Arnd Bergmann
2020-01-03  3:02 ` Martin K. Petersen

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='CAK8P3a21u6FacA-EfGoaVMmd-iXux=wACG5JTpoUZ8cwvNjuOg@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=benh@kernel.crashing.org \
    --cc=borntraeger@de.ibm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=gor@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=jejb@linux.ibm.com \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linuxppc-dev@zytor.com \
    --cc=martin.petersen@oracle.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulburton@kernel.org \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=rric@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).