From: guenther Date: Thu, 14 Dec 2017 03:30:43 +0000 (+0000) Subject: fcntl(F_SETFL) invokes the FIONBIO and FIOASYNC ioctls internally, so X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c2a35b387f9d3ccb845c838c1eb887d74221f42f;p=openbsd fcntl(F_SETFL) invokes the FIONBIO and FIOASYNC ioctls internally, so the memory devices (/dev/null, /dev/zero, etc) need to permit them. problem noted, tweak, and testing by jeremy@ ok deraadt@ --- diff --git a/sys/arch/alpha/alpha/mem.c b/sys/arch/alpha/alpha/mem.c index 8dc87b3f3d8..ec29894dff9 100644 --- a/sys/arch/alpha/alpha/mem.c +++ b/sys/arch/alpha/alpha/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.32 2016/09/27 05:01:29 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.33 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.26 2000/03/29 03:48:20 simonb Exp $ */ /* @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -242,5 +243,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c index 15e30a7a29d..7fc09e1fb4a 100644 --- a/sys/arch/amd64/amd64/mem.c +++ b/sys/arch/amd64/amd64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.32 2017/10/14 04:44:43 jsg Exp $ */ +/* $OpenBSD: mem.c,v 1.33 2017/12/14 03:30:43 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -237,6 +238,13 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + #ifdef MTRR switch (minor(dev)) { case 0: diff --git a/sys/arch/arm/arm/mem.c b/sys/arch/arm/arm/mem.c index c05990f6c52..ec82d414342 100644 --- a/sys/arch/arm/arm/mem.c +++ b/sys/arch/arm/arm/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.19 2016/09/25 15:23:37 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.20 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -246,5 +247,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/arm64/arm64/mem.c b/sys/arch/arm64/arm64/mem.c index 1de1c9a67e0..5b2cb6b3a7c 100644 --- a/sys/arch/arm64/arm64/mem.c +++ b/sys/arch/arm64/arm64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.2 2017/01/23 12:29:50 kettenis Exp $ */ +/* $OpenBSD: mem.c,v 1.3 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -246,5 +247,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/hppa/hppa/mem.c b/sys/arch/hppa/hppa/mem.c index f903e9ac065..785ad2bd76b 100644 --- a/sys/arch/hppa/hppa/mem.c +++ b/sys/arch/hppa/hppa/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.3 2017/09/08 05:36:51 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.4 2017/12/14 03:30:43 guenther Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -420,5 +421,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c index 1db1e6efb51..e9af7eb43fa 100644 --- a/sys/arch/i386/i386/mem.c +++ b/sys/arch/i386/i386/mem.c @@ -1,5 +1,5 @@ /* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */ -/* $OpenBSD: mem.c,v 1.52 2017/04/20 14:13:00 visa Exp $ */ +/* $OpenBSD: mem.c,v 1.53 2017/12/14 03:30:43 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -250,6 +251,13 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + #ifdef MTRR switch (minor(dev)) { case 0: diff --git a/sys/arch/m88k/m88k/mem.c b/sys/arch/m88k/m88k/mem.c index 93167c253ab..5ccc2d50c85 100644 --- a/sys/arch/m88k/m88k/mem.c +++ b/sys/arch/m88k/m88k/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.5 2016/09/25 15:23:37 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.6 2017/12/14 03:30:43 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -164,5 +165,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/macppc/macppc/mem.c b/sys/arch/macppc/macppc/mem.c index e84f574b743..0ea44c381ac 100644 --- a/sys/arch/macppc/macppc/mem.c +++ b/sys/arch/macppc/macppc/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.25 2017/09/08 05:36:52 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.26 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */ /* @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -306,5 +307,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/mips64/mips64/mem.c b/sys/arch/mips64/mips64/mem.c index 28706b9ba6d..619a1dc1467 100644 --- a/sys/arch/mips64/mips64/mem.c +++ b/sys/arch/mips64/mips64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.22 2016/09/25 15:23:37 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.23 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.6 1995/04/10 11:55:03 mycroft Exp $ */ /* @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -196,5 +197,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/sh/sh/mem.c b/sys/arch/sh/sh/mem.c index 596864a52ca..a42e0cd3782 100644 --- a/sys/arch/sh/sh/mem.c +++ b/sys/arch/sh/sh/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.9 2016/09/25 15:23:37 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.10 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.21 2006/07/23 22:06:07 ad Exp $ */ /* @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -221,6 +222,13 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/socppc/socppc/mem.c b/sys/arch/socppc/socppc/mem.c index c9450994ed8..109790ae753 100644 --- a/sys/arch/socppc/socppc/mem.c +++ b/sys/arch/socppc/socppc/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.7 2017/09/08 05:36:52 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.8 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */ /* @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -172,5 +173,12 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); } diff --git a/sys/arch/sparc64/sparc64/mem.c b/sys/arch/sparc64/sparc64/mem.c index d4780e51c4b..f4deaa41c5b 100644 --- a/sys/arch/sparc64/sparc64/mem.c +++ b/sys/arch/sparc64/sparc64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.18 2016/09/25 15:23:37 deraadt Exp $ */ +/* $OpenBSD: mem.c,v 1.19 2017/12/14 03:30:43 guenther Exp $ */ /* $NetBSD: mem.c,v 1.18 2001/04/24 04:31:12 thorpej Exp $ */ /* @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -193,6 +194,13 @@ mmmmap(dev_t dev, off_t off, int prot) int mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { + switch (cmd) { + case FIONBIO: + case FIOASYNC: + /* handled by fd layer */ + return 0; + } + return (EOPNOTSUPP); }