Skip to content

Commit 51ef07c

Browse files
keesgregkh
authored andcommitted
seccomp: Fix ioctl number for SECCOMP_IOCTL_NOTIF_ID_VALID
[ Upstream commit 47e33c0 ] When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced it had the wrong direction flag set. While this isn't a big deal as nothing currently enforces these bits in the kernel, it should be defined correctly. Fix the define and provide support for the old command until it is no longer needed for backward compatibility. Fixes: 6a21cc5 ("seccomp: add a return code to trap to userspace") Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d2d0910 commit 51ef07c

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎include/uapi/linux/seccomp.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,6 @@ struct seccomp_notif_resp {
123123
#define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif)
124124
#define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \
125125
struct seccomp_notif_resp)
126-
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64)
126+
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
127+
127128
#endif /* _UAPI_LINUX_SECCOMP_H */

‎kernel/seccomp.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
#include <linux/uaccess.h>
4343
#include <linux/anon_inodes.h>
4444

45+
/*
46+
* When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced, it had the
47+
* wrong direction flag in the ioctl number. This is the broken one,
48+
* which the kernel needs to keep supporting until all userspaces stop
49+
* using the wrong command number.
50+
*/
51+
#define SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR SECCOMP_IOR(2, __u64)
52+
4553
enum notify_state {
4654
SECCOMP_NOTIFY_INIT,
4755
SECCOMP_NOTIFY_SENT,
@@ -1186,6 +1194,7 @@ static long seccomp_notify_ioctl(struct file *file, unsigned int cmd,
11861194
return seccomp_notify_recv(filter, buf);
11871195
case SECCOMP_IOCTL_NOTIF_SEND:
11881196
return seccomp_notify_send(filter, buf);
1197+
case SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR:
11891198
case SECCOMP_IOCTL_NOTIF_ID_VALID:
11901199
return seccomp_notify_id_valid(filter, buf);
11911200
default:

‎tools/testing/selftests/seccomp/seccomp_bpf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct seccomp_metadata {
180180
#define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif)
181181
#define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \
182182
struct seccomp_notif_resp)
183-
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64)
183+
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
184184

185185
struct seccomp_notif {
186186
__u64 id;

0 commit comments

Comments
 (0)