[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220515200103.1408370-2-mussitantesmortem@gmail.com>
Date: Sun, 15 May 2022 23:01:03 +0300
From: Maxim Zhukov <crazycdeveloper@...il.com>
To: chi.minghao@....com.cn, varad.gautam@...e.com, arnd@...db.de
Cc: akpm@...ux-foundation.org, shakeelb@...gle.com,
vasily.averin@...ux.dev, manfred@...orfullife.com, dbueso@...e.de,
linux-kernel@...r.kernel.org,
Maxim Zhukov <mussitantesmortem@...il.com>
Subject: [RFC PATCH 1/1] ipc, sem: fix backward compatibility with x86-32 kernels
Since with 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 for 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
Signed-off-by: Maxim Zhukov <mussitantesmortem@...il.com>
---
ipc/sem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipc/sem.c b/ipc/sem.c
index 0dbdb98fdf2d..824244170000 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1706,7 +1706,7 @@ static long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg, int v
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
--
2.36.1
Powered by blists - more mailing lists