Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * 32 bit compatibility code for System V IPC
0004  *
0005  * Copyright (C) 1997,1998  Jakub Jelinek (jj@sunsite.mff.cuni.cz)
0006  * Copyright (C) 1997       David S. Miller (davem@caip.rutgers.edu)
0007  * Copyright (C) 1999       Arun Sharma <arun.sharma@intel.com>
0008  * Copyright (C) 2000       VA Linux Co
0009  * Copyright (C) 2000       Don Dugger <n0ano@valinux.com>
0010  * Copyright (C) 2000           Hewlett-Packard Co.
0011  * Copyright (C) 2000           David Mosberger-Tang <davidm@hpl.hp.com>
0012  * Copyright (C) 2000           Gerhard Tonn (ton@de.ibm.com)
0013  * Copyright (C) 2000-2002      Andi Kleen, SuSE Labs (x86-64 port)
0014  * Copyright (C) 2000       Silicon Graphics, Inc.
0015  * Copyright (C) 2001       IBM
0016  * Copyright (C) 2004       IBM Deutschland Entwicklung GmbH, IBM Corporation
0017  * Copyright (C) 2004       Arnd Bergmann (arnd@arndb.de)
0018  *
0019  * This code is collected from the versions for sparc64, mips64, s390x, ia64,
0020  * ppc64 and x86_64, all of which are based on the original sparc64 version
0021  * by Jakub Jelinek.
0022  *
0023  */
0024 #include <linux/compat.h>
0025 #include <linux/errno.h>
0026 #include <linux/highuid.h>
0027 #include <linux/init.h>
0028 #include <linux/msg.h>
0029 #include <linux/shm.h>
0030 #include <linux/syscalls.h>
0031 #include <linux/ptrace.h>
0032 
0033 #include <linux/mutex.h>
0034 #include <linux/uaccess.h>
0035 
0036 #include "util.h"
0037 
0038 int get_compat_ipc64_perm(struct ipc64_perm *to,
0039               struct compat_ipc64_perm __user *from)
0040 {
0041     struct compat_ipc64_perm v;
0042     if (copy_from_user(&v, from, sizeof(v)))
0043         return -EFAULT;
0044     to->uid = v.uid;
0045     to->gid = v.gid;
0046     to->mode = v.mode;
0047     return 0;
0048 }
0049 
0050 int get_compat_ipc_perm(struct ipc64_perm *to,
0051             struct compat_ipc_perm __user *from)
0052 {
0053     struct compat_ipc_perm v;
0054     if (copy_from_user(&v, from, sizeof(v)))
0055         return -EFAULT;
0056     to->uid = v.uid;
0057     to->gid = v.gid;
0058     to->mode = v.mode;
0059     return 0;
0060 }
0061 
0062 void to_compat_ipc64_perm(struct compat_ipc64_perm *to, struct ipc64_perm *from)
0063 {
0064     to->key = from->key;
0065     to->uid = from->uid;
0066     to->gid = from->gid;
0067     to->cuid = from->cuid;
0068     to->cgid = from->cgid;
0069     to->mode = from->mode;
0070     to->seq = from->seq;
0071 }
0072 
0073 void to_compat_ipc_perm(struct compat_ipc_perm *to, struct ipc64_perm *from)
0074 {
0075     to->key = from->key;
0076     SET_UID(to->uid, from->uid);
0077     SET_GID(to->gid, from->gid);
0078     SET_UID(to->cuid, from->cuid);
0079     SET_GID(to->cgid, from->cgid);
0080     to->mode = from->mode;
0081     to->seq = from->seq;
0082 }