Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Prevent O_EXEC for mq_open(2), and O_EXEC with a wr...
details: https://anonhg.NetBSD.org/src/rev/cecc1bd5e574
branches: trunk
changeset: 1003453:cecc1bd5e574
user: christos <christos%NetBSD.org@localhost>
date: Sun Sep 15 20:51:03 2019 +0000
description:
Prevent O_EXEC for mq_open(2), and O_EXEC with a writable fd for open(2).
diffstat:
sys/kern/sys_mqueue.c | 7 +++++--
sys/kern/vfs_syscalls.c | 11 +++++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diffs (60 lines):
diff -r d6f9091a4474 -r cecc1bd5e574 sys/kern/sys_mqueue.c
--- a/sys/kern/sys_mqueue.c Sun Sep 15 20:26:51 2019 +0000
+++ b/sys/kern/sys_mqueue.c Sun Sep 15 20:51:03 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_mqueue.c,v 1.44 2019/04/16 01:02:41 martin Exp $ */
+/* $NetBSD: sys_mqueue.c,v 1.45 2019/09/15 20:51:03 christos Exp $ */
/*
* Copyright (c) 2007-2011 Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.44 2019/04/16 01:02:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.45 2019/09/15 20:51:03 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -614,6 +614,9 @@
struct mq_attr *attr = NULL, a;
int error;
+ if ((SCARG(uap, oflag) & O_EXEC) != 0)
+ return EINVAL;
+
if ((SCARG(uap, oflag) & O_CREAT) != 0 && SCARG(uap, attr) != NULL) {
error = copyin(SCARG(uap, attr), &a, sizeof(a));
if (error)
diff -r d6f9091a4474 -r cecc1bd5e574 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Sun Sep 15 20:26:51 2019 +0000
+++ b/sys/kern/vfs_syscalls.c Sun Sep 15 20:51:03 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.533 2019/07/06 14:37:24 maxv Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.534 2019/09/15 20:51:03 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.533 2019/07/06 14:37:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.534 2019/09/15 20:51:03 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -1572,6 +1572,13 @@
open_flags &= ~(int)O_SEARCH;
}
+ /*
+ * Only one of the O_EXEC, O_RDONLY, O_WRONLY and O_RDWR flags
+ * may be specified.
+ */
+ if ((open_flags & O_EXEC) && (open_flags & O_ACCMODE))
+ return EINVAL;
+
flags = FFLAGS(open_flags);
if ((flags & (FREAD | FWRITE)) == 0)
return EINVAL;
Home |
Main Index |
Thread Index |
Old Index