Prevent O_EXEC for mq_open(2), and O_EXEC with a writable fd for open(2).
This commit is contained in:
parent
df668d1f3a
commit
9246f6c782
@ -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 @@ sys_mq_open(struct lwp *l, const struct sys_mq_open_args *uap,
|
||||
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)
|
||||
|
@ -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 @@ do_open(lwp_t *l, struct vnode *dvp, struct pathbuf *pb, int open_flags,
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user