Skip to content

Commit 47e33c0

Browse files
committed
seccomp: Fix ioctl number for SECCOMP_IOCTL_NOTIF_ID_VALID
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 <[email protected]>
1 parent 279ed89 commit 47e33c0

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

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
@@ -44,6 +44,14 @@
4444
#include <linux/anon_inodes.h>
4545
#include <linux/lockdep.h>
4646

47+
/*
48+
* When SECCOMP_IOCTL_NOTIF_ID_VALID was first introduced, it had the
49+
* wrong direction flag in the ioctl number. This is the broken one,
50+
* which the kernel needs to keep supporting until all userspaces stop
51+
* using the wrong command number.
52+
*/
53+
#define SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR SECCOMP_IOR(2, __u64)
54+
4755
enum notify_state {
4856
SECCOMP_NOTIFY_INIT,
4957
SECCOMP_NOTIFY_SENT,
@@ -1236,6 +1244,7 @@ static long seccomp_notify_ioctl(struct file *file, unsigned int cmd,
12361244
return seccomp_notify_recv(filter, buf);
12371245
case SECCOMP_IOCTL_NOTIF_SEND:
12381246
return seccomp_notify_send(filter, buf);
1247+
case SECCOMP_IOCTL_NOTIF_ID_VALID_WRONG_DIR:
12391248
case SECCOMP_IOCTL_NOTIF_ID_VALID:
12401249
return seccomp_notify_id_valid(filter, buf);
12411250
default:

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct seccomp_metadata {
186186
#define SECCOMP_IOCTL_NOTIF_RECV SECCOMP_IOWR(0, struct seccomp_notif)
187187
#define SECCOMP_IOCTL_NOTIF_SEND SECCOMP_IOWR(1, \
188188
struct seccomp_notif_resp)
189-
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOR(2, __u64)
189+
#define SECCOMP_IOCTL_NOTIF_ID_VALID SECCOMP_IOW(2, __u64)
190190

191191
struct seccomp_notif {
192192
__u64 id;

0 commit comments

Comments
 (0)