aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2012-07-30 17:42:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:20 -0400
commit079a96ae3871f0ed9083aac2218136ccec5b9877 (patch)
tree52acdeda67006d3d85eee0a17d6241657ba270dc /ipc/shm.c
parent63dca8d5b5ef7effb58b8d6892a024125c0fab0b (diff)
ipc: add COMPAT_SHMLBA support
If the SHMLBA definition for a native task differs from the definition for a compat task, the do_shmat() function would need to handle both. This patch introduces COMPAT_SHMLBA, which is used by the compat shmat syscall when calling the ipc code and allows architectures such as AArch64 (where the native SHMLBA is 64k but the compat (AArch32) definition is 16k) to provide the correct semantics for compat IPC system calls. Cc: David S. Miller <davem@davemloft.net> Cc: Chris Zankel <chris@zankel.net> Cc: Arnd Bergmann <arnd@arndb.de> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 41c1285d697a..00faa05cf72a 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -953,7 +953,8 @@ out:
953 * "raddr" thing points to kernel space, and there has to be a wrapper around 953 * "raddr" thing points to kernel space, and there has to be a wrapper around
954 * this. 954 * this.
955 */ 955 */
956long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr) 956long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
957 unsigned long shmlba)
957{ 958{
958 struct shmid_kernel *shp; 959 struct shmid_kernel *shp;
959 unsigned long addr; 960 unsigned long addr;
@@ -973,9 +974,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
973 if (shmid < 0) 974 if (shmid < 0)
974 goto out; 975 goto out;
975 else if ((addr = (ulong)shmaddr)) { 976 else if ((addr = (ulong)shmaddr)) {
976 if (addr & (SHMLBA-1)) { 977 if (addr & (shmlba - 1)) {
977 if (shmflg & SHM_RND) 978 if (shmflg & SHM_RND)
978 addr &= ~(SHMLBA-1); /* round down */ 979 addr &= ~(shmlba - 1); /* round down */
979 else 980 else
980#ifndef __ARCH_FORCE_SHMLBA 981#ifndef __ARCH_FORCE_SHMLBA
981 if (addr & ~PAGE_MASK) 982 if (addr & ~PAGE_MASK)
@@ -1107,7 +1108,7 @@ SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg)
1107 unsigned long ret; 1108 unsigned long ret;
1108 long err; 1109 long err;
1109 1110
1110 err = do_shmat(shmid, shmaddr, shmflg, &ret); 1111 err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
1111 if (err) 1112 if (err)
1112 return err; 1113 return err;
1113 force_successful_syscall_return(); 1114 force_successful_syscall_return();