2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* 32 bit compatibility code for System V IPC
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
|
|
|
* Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
|
|
|
|
* Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
|
|
|
|
* Copyright (C) 2000 VA Linux Co
|
|
|
|
* Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
|
|
|
|
* Copyright (C) 2000 Hewlett-Packard Co.
|
|
|
|
* Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
|
|
|
|
* Copyright (C) 2000 Gerhard Tonn (ton@de.ibm.com)
|
|
|
|
* Copyright (C) 2000-2002 Andi Kleen, SuSE Labs (x86-64 port)
|
|
|
|
* Copyright (C) 2000 Silicon Graphics, Inc.
|
|
|
|
* Copyright (C) 2001 IBM
|
|
|
|
* Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
|
|
|
|
* Copyright (C) 2004 Arnd Bergmann (arnd@arndb.de)
|
|
|
|
*
|
|
|
|
* This code is collected from the versions for sparc64, mips64, s390x, ia64,
|
|
|
|
* ppc64 and x86_64, all of which are based on the original sparc64 version
|
|
|
|
* by Jakub Jelinek.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/compat.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/highuid.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/msg.h>
|
|
|
|
#include <linux/shm.h>
|
|
|
|
#include <linux/syscalls.h>
|
[PATCH v3] ipc: provide generic compat versions of IPC syscalls
When using the "compat" APIs, architectures will generally want to
be able to make direct syscalls to msgsnd(), shmctl(), etc., and
in the kernel we would want them to be handled directly by
compat_sys_xxx() functions, as is true for other compat syscalls.
However, for historical reasons, several of the existing compat IPC
syscalls do not do this. semctl() expects a pointer to the fourth
argument, instead of the fourth argument itself. msgsnd(), msgrcv()
and shmat() expect arguments in different order.
This change adds an ARCH_WANT_OLD_COMPAT_IPC config option that can be
set to preserve this behavior for ports that use it (x86, sparc, powerpc,
s390, and mips). No actual semantics are changed for those architectures,
and there is only a minimal amount of code refactoring in ipc/compat.c.
Newer architectures like tile (and perhaps future architectures such
as arm64 and unicore64) should not select this option, and thus can
avoid having any IPC-specific code at all in their architecture-specific
compat layer. In the same vein, if this option is not selected, IPC_64
mode is assumed, since that's what the <asm-generic> headers expect.
The workaround code in "tile" for msgsnd() and msgrcv() is removed
with this change; it also fixes the bug that shmat() and semctl() were
not being properly handled.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
2012-03-15 17:13:38 +00:00
|
|
|
#include <linux/ptrace.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-03-26 09:37:17 +00:00
|
|
|
#include <linux/mutex.h>
|
2014-06-06 21:37:37 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
2017-07-09 14:03:23 +00:00
|
|
|
int get_compat_ipc64_perm(struct ipc64_perm *to,
|
|
|
|
struct compat_ipc64_perm __user *from)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-07-09 14:03:23 +00:00
|
|
|
struct compat_ipc64_perm v;
|
|
|
|
if (copy_from_user(&v, from, sizeof(v)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
2017-07-09 14:03:23 +00:00
|
|
|
to->uid = v.uid;
|
|
|
|
to->gid = v.gid;
|
|
|
|
to->mode = v.mode;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-07-09 14:03:23 +00:00
|
|
|
int get_compat_ipc_perm(struct ipc64_perm *to,
|
|
|
|
struct compat_ipc_perm __user *from)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-07-09 14:03:23 +00:00
|
|
|
struct compat_ipc_perm v;
|
|
|
|
if (copy_from_user(&v, from, sizeof(v)))
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EFAULT;
|
2017-07-09 14:03:23 +00:00
|
|
|
to->uid = v.uid;
|
|
|
|
to->gid = v.gid;
|
|
|
|
to->mode = v.mode;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-07-09 14:03:23 +00:00
|
|
|
void to_compat_ipc64_perm(struct compat_ipc64_perm *to, struct ipc64_perm *from)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-07-09 14:03:23 +00:00
|
|
|
to->key = from->key;
|
|
|
|
to->uid = from->uid;
|
|
|
|
to->gid = from->gid;
|
|
|
|
to->cuid = from->cuid;
|
|
|
|
to->cgid = from->cgid;
|
|
|
|
to->mode = from->mode;
|
|
|
|
to->seq = from->seq;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-07-09 14:03:23 +00:00
|
|
|
void to_compat_ipc_perm(struct compat_ipc_perm *to, struct ipc64_perm *from)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-07-09 14:03:23 +00:00
|
|
|
to->key = from->key;
|
|
|
|
SET_UID(to->uid, from->uid);
|
|
|
|
SET_GID(to->gid, from->gid);
|
|
|
|
SET_UID(to->cuid, from->cuid);
|
|
|
|
SET_GID(to->cgid, from->cgid);
|
|
|
|
to->mode = from->mode;
|
|
|
|
to->seq = from->seq;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|