From a0135d7e95bcd249ba99870995c64d34307c12ab Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Mon, 30 Oct 1995 22:39:34 +0000 Subject: [PATCH] Security fix - do not allow anyone but root to choose the interrupts used in the the randomising process. (This is a change to the /dev/random ioctl())) --- sys/amd64/amd64/mem.c | 10 +++++++++- sys/i386/i386/mem.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c index 47e927bfc119..1e040ab4e699 100644 --- a/sys/amd64/amd64/mem.c +++ b/sys/amd64/amd64/mem.c @@ -38,7 +38,7 @@ * * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * $Id: mem.c,v 1.15 1995/10/28 16:57:55 markm Exp $ + * $Id: mem.c,v 1.16 1995/10/29 11:37:56 bde Exp $ */ /* @@ -351,12 +351,20 @@ mmioctl(dev, cmd, cmdarg, flags, p) struct proc *p; { #ifdef DEVRANDOM + int error; + if (minor(dev) != 3 && minor(dev) != 4) return (ENODEV); if (*(u_int16_t *)cmdarg >= 16) return (EINVAL); + /* Only root can do this */ + error = suser(p->p_ucred, &p->p_acflag); + if (error != 0) { + return (error); + } + switch (cmd){ case MEM_SETIRQ: diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index 47e927bfc119..1e040ab4e699 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -38,7 +38,7 @@ * * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * $Id: mem.c,v 1.15 1995/10/28 16:57:55 markm Exp $ + * $Id: mem.c,v 1.16 1995/10/29 11:37:56 bde Exp $ */ /* @@ -351,12 +351,20 @@ mmioctl(dev, cmd, cmdarg, flags, p) struct proc *p; { #ifdef DEVRANDOM + int error; + if (minor(dev) != 3 && minor(dev) != 4) return (ENODEV); if (*(u_int16_t *)cmdarg >= 16) return (EINVAL); + /* Only root can do this */ + error = suser(p->p_ucred, &p->p_acflag); + if (error != 0) { + return (error); + } + switch (cmd){ case MEM_SETIRQ: