+ ipc-sem-fix-backward-compatibility-with-x86-32-kernels.patch added to mm-nonmm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: ipc, sem: fix backward compatibility with x86-32 kernels
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     ipc-sem-fix-backward-compatibility-with-x86-32-kernels.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/ipc-sem-fix-backward-compatibility-with-x86-32-kernels.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Maxim Zhukov <crazycdeveloper@xxxxxxxxx>
Subject: ipc, sem: fix backward compatibility with x86-32 kernels
Date: Sun, 15 May 2022 23:01:03 +0300

Since commit 275f22148e87 ("ipc: rename old-style shmctl/semctl/msgctl
syscalls") we have changed behavior:

ksys_semctl lost parse ipc version (ipc_parse_version), because the new
syscall works with IPC_64 only, but the parse function has some side
effect - it removes IPC_64 bit from `cmd`.

Some libc forced sends IPC_64 bit in semctl syscall[1][2][3], this leads
to a bug - X86-32 kernel does not have compat headers and does not
correctly parse received command (cmd) from semctl syscall: cmd have
actual command and IPC_64 bit, thus throw EINVAL error in ksys_semctl

This commit forcibly removes IPC_64 bit from the cmd to restore backward
compatibility.

[1]: https://elixir.bootlin.com/uclibc-ng/v1.0.40/source/libc/misc/sysvipc/sem.c#L58
[2]: https://elixir.bootlin.com/musl/v1.2.3/source/src/ipc/semctl.c#L48 -> https://elixir.bootlin.com/musl/v1.2.3/source/src/ipc/ipc.h#L22
[3]: https://elixir.bootlin.com/glibc/glibc-2.35/source/sysdeps/unix/sysv/linux/semctl.c#L124

Link: https://lkml.kernel.org/r/20220515200103.1408370-2-mussitantesmortem@xxxxxxxxx
Signed-off-by: Maxim Zhukov <mussitantesmortem@xxxxxxxxx>
Cc: Minghao Chi <chi.minghao@xxxxxxxxxx>
Cc: Varad Gautam <varad.gautam@xxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Shakeel Butt <shakeelb@xxxxxxxxxx>
Cc: Vasily Averin <vasily.averin@xxxxxxxxx>
Cc: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
Cc: Davidlohr Bueso <dbueso@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 ipc/sem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/ipc/sem.c~ipc-sem-fix-backward-compatibility-with-x86-32-kernels
+++ a/ipc/sem.c
@@ -1704,7 +1704,7 @@ static long ksys_semctl(int semid, int s
 
 SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, unsigned long, arg)
 {
-	return ksys_semctl(semid, semnum, cmd, arg, IPC_64);
+	return ksys_semctl(semid, semnum, cmd & (~IPC_64), arg, IPC_64);
 }
 
 #ifdef CONFIG_ARCH_WANT_IPC_PARSE_VERSION
_

Patches currently in -mm which might be from crazycdeveloper@xxxxxxxxx are

ipc-sem-fix-backward-compatibility-with-x86-32-kernels.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux