From patchwork Mon Dec 14 22:04:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10008 X-Patchwork-Delegate: tuliom@linux.vnet.ibm.com Received: (qmail 9032 invoked by alias); 14 Dec 2015 22:04:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 8733 invoked by uid 89); 14 Dec 2015 22:04:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 X-HELO: mout.kundenserver.de From: Arnd Bergmann To: "Paul E. Murphy" Cc: libc-alpha@sourceware.org, Andreas Schwab , Tulio Magno Quites Machado Filho Subject: Re: [PATCH] powerpc: Enable demuxed sysv IPC syscalls Date: Mon, 14 Dec 2015 23:04:26 +0100 Message-ID: <1904883.fPjB3uFKBy@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <566EF0EC.1050606@linux.vnet.ibm.com> References: <5660A8D0.5090003@linux.vnet.ibm.com> <2124912.ITjUQ6nO6Y@wuerfel> <566EF0EC.1050606@linux.vnet.ibm.com> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:l3Xaw/UX+y8=:1CfmB5DUXqbp/gDCEXTt/u Tca27cPO2ClZGOn8AqjUWnVWlbPj2erHMaoRRTIJGkxA5h4GHFjZbtHkPVo4x0Kj4QUtZQ5NP Ech9wHUdjiiEbAl87yRHZCAvCqwlWjq+3IUNakNRRe5jNJWmiBLkD186JDXOLxaOcXKoE+X5N jkNW2YsrZZ3f5D61QAXuxdJWB2dzgv6bP8RCJbdobnBdjwd3lsNi+DOB0UBWAgo9Er0Tc7NG1 Jp8vDpv4FTDHg5RZApFh9cFfHaymXswejbllXjSfvozv7KwcFuMx0Up+emScqonb6WbTdo6ol RvLrGMpMbd+vxKX5IZUCKVBaMoY7a8A0KaN7rwd34BU9O973EHKsNa+0g3NPR2U3LS26RZOim qQyM5M19OzWueJlNWY5lJJ6NK1eQRnTCTJQ29kbt8/7fujJZYcOumRMQzmrvIxRwxLdgo309t bvaYIkhY4/Q6LuLkbcsb+QSgjCOwaaGjBfV3qzK7LwCuiVpQw6Am4DvrKrSGdHyZD2KVLznRD PNp1Q9mR0uD/JuC1kDeZ3JqhvxTM7mqlHUFQQW+e0dpdL7qLHlaBWJNXy801z5SZBNLkHL7q4 5S/s52gJi3A/chQKHdln70aD+k5C6b9R7Fjcrx1rYoBLIKupQk+WfNijwccDDglVrPJhT8JjD L5eaVll9g2GVGSRYwQwWvb/g+t0NSmsTZQqF1gPRQzM+woROPjiJkMJjiGtY7Cb0v/PogK+Bj cLoz6pseTblBOBPj On Monday 14 December 2015 10:40:12 Paul E. Murphy wrote: > On 12/03/2015 05:13 PM, Arnd Bergmann wrote: > > On Friday 04 December 2015 00:09:08 Arnd Bergmann wrote: > >> On Thursday 03 December 2015 23:12:10 Andreas Schwab wrote: > >>>> #endif > >>>> @@ -64,7 +68,12 @@ compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0); > >>>> int > >>>> __new_msgctl (int msqid, int cmd, struct msqid_ds *buf) > >>>> { > >>>> +#ifdef __ASSUME_MSGCTL_SYSCALL > >>>> + return INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, buf); > >>> > >>> Why does a brand new syscall need IPC_64? > >> > >> This is a bug in the kernel, which we should fix there. The same > >> problem currently exists on ARM and AVR32, which also support the > >> old IPC API (pre-__IPC64) and are adding separate syscalls now. > > > > Correction, I looked at the wrong place: ARM and AVR32 have had this > > problem for a long time, so we can't fix it any more. But we should > > fix it for PowerPC and all other architectures that add these calls > > in the future. > > I'm not clear as to what you are suggesting for this patch. Looking at the > kernel code, it does not look trivial to remove the IPC_64 bit. It seems > to boil down to whether ARCH_WANT_IPC_PARSE_VERSION is configured on the > kernel. > > Should the compat versions of these be left untouched? Or is it safe to > switch them to the demuxed version? It is a little tricky indeed, especially on powerpc where we do this differently on 32-bit and 64-bit kernels. I think the patch below would be the simplest way to do this for all three affected syscalls, but we probably don't want to it this late in the kernel cycle. Maybe we can do it this way for 4.5, and change the powerpc syscall table for 4.4 to leave out the separate calls until we get this right? Arnd diff --git a/ipc/compat.c b/ipc/compat.c index 9b3c85f8a538..e583e7e83c0e 100644 --- a/ipc/compat.c +++ b/ipc/compat.c @@ -495,20 +495,19 @@ static inline int put_compat_msqid_ds(struct msqid64_ds *m, return err; } -COMPAT_SYSCALL_DEFINE3(msgctl, int, first, int, second, void __user *, uptr) +static long do_compat_msgctl(int msqid, int cmd, void __user *uptr, int version) { int err, err2; struct msqid64_ds m64; - int version = compat_ipc_parse_version(&second); void __user *p; memset(&m64, 0, sizeof(m64)); - switch (second & (~IPC_64)) { + switch (cmd & (~IPC_64)) { case IPC_INFO: case IPC_RMID: case MSG_INFO: - err = sys_msgctl(first, second, uptr); + err = sys_msgctl(msqid, cmd, uptr); break; case IPC_SET: @@ -523,13 +522,13 @@ COMPAT_SYSCALL_DEFINE3(msgctl, int, first, int, second, void __user *, uptr) if (copy_to_user(p, &m64, sizeof(m64))) err = -EFAULT; else - err = sys_msgctl(first, second, p); + err = sys_msgctl(msqid, cmd, p); break; case IPC_STAT: case MSG_STAT: p = compat_alloc_user_space(sizeof(m64)); - err = sys_msgctl(first, second, p); + err = sys_msgctl(msqid, cmd, p); if (err < 0) break; if (copy_from_user(&m64, p, sizeof(m64))) @@ -549,6 +548,18 @@ COMPAT_SYSCALL_DEFINE3(msgctl, int, first, int, second, void __user *, uptr) return err; } +COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr) +{ + int version = compat_ipc_parse_version(&cmd); + + return do_compat_msgctl(msqid, cmd, uptr, version); +} + +COMPAT_SYSCALL_DEFINE3(msgctl64, int, first, int, second, void __user *, uptr) +{ + return do_compat_msgctl(msqid, cmd, uptr, IPC_64); +} + COMPAT_SYSCALL_DEFINE3(shmat, int, shmid, compat_uptr_t, shmaddr, int, shmflg) { unsigned long ret; diff --git a/ipc/msg.c b/ipc/msg.c index 59559a215401..acbb82a80647 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -520,15 +520,13 @@ out_unlock: return err; } -SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) +static long do_msgctl(int msqid, int cmd, struct msqid_ds __user * buf, int version) { - int version; struct ipc_namespace *ns; if (msqid < 0 || cmd < 0) return -EINVAL; - version = ipc_parse_version(&cmd); ns = current->nsproxy->ipc_ns; switch (cmd) { @@ -545,6 +543,18 @@ SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) } } +SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) +{ + int version = ipc_parse_version(&cmd); + + return do_msgctl(msqid, cmd, buf, version); +} + +SYSCALL_DEFINE3(msgctl64, int, msqid, int, cmd, struct msqid_ds __user *, buf) +{ + return do_msgctl(msqid, cmd, buf, IPC_64); +} + static int testmsg(struct msg_msg *msg, long type, int mode) { switch (mode) {