LinuxSecurity.com
Share your story
The central voice for Linux and Open Source security news
Home News Topics Advisories HOWTOs Features Newsletters About Register

Welcome!
Sign up!
EnGarde Community
Login
Polls
What is the most important Linux security technology?
 
Advisories
Community
Linux Events
Linux User Groups
Link to Us
Security Center
Book Reviews
Security Dictionary
Security Tips
SELinux
White Papers
Featured Blogs
All About Linux
DanWalsh LiveJournal
Securitydistro
Latest Newsletters
Linux Security Week: April 7th, 2014
Linux Advisory Watch: April 4th, 2014
Subscribe
LinuxSecurity Newsletters
E-mail:
Choose Lists:
About our Newsletters
RSS Feeds
Get the LinuxSecurity news you want faster with RSS
Powered By

  
OpenBSD 2.2: Bug in vm system Print E-mail
User Rating:      How can I rate this item?
Posted by LinuxSecurity.com Team   
OpenBSD A bug in the vm system permits a file descriptor opened read-only on a device, to later on be mmap(2)'d read-write, and then modified.
This does not result in a security hole by itself, but it does violate the 
safety semantics which securelevels are supposed to provide. If a user manages 
to gain kmem group permissions, using this problem they can then gain root 
trivially and/or turn securelevels off.

This is revision 3 of this patch.

Apply by doing
	cd /sys
	patch < vm_mmap.patch

Index: vm/vm_mmap.c
===================================================================
RCS file: /cvs/src/sys/vm/vm_mmap.c,v
retrieving revision 1.10
retrieving revision 1.13
diff -u -r1.10 -r1.13
--- vm_mmap.c	1997/11/14 20:56:08	1.10
+++ vm_mmap.c	1998/02/25 22:13:46	1.13
@@ -1,4 +1,4 @@
-/*	$OpenBSD: vm_mmap.c,v 1.8 1997/07/25 06:03:08 mickey Exp $	*/
+/*	$OpenBSD: vm_mmap.c,v 1.13 1998/02/25 22:13:46 deraadt Exp $	*/
 /*	$NetBSD: vm_mmap.c,v 1.47 1996/03/16 23:15:23 christos Exp $	*/
 
 /*
@@ -213,8 +213,7 @@
 		if (fp->f_type != DTYPE_VNODE)
 			return (EINVAL);
 		vp = (struct vnode *)fp->f_data;
-		if (vp->v_type != VREG && vp->v_type != VCHR)
-			return (EINVAL);
+
 		/*
 		 * XXX hack to handle use of /dev/zero to map anon
 		 * memory (ala SunOS).
@@ -223,6 +222,14 @@
 			flags |= MAP_ANON;
 			goto is_anon;
 		}
+
+		/*
+		 * Only files and cdevs are mappable, and cdevs does not
+		 * provide private mappings of any kind.
+		 */
+		if (vp->v_type != VREG &&
+		    (vp->v_type != VCHR || (flags & (MAP_PRIVATE|MAP_COPY))))
+			return (EINVAL);
 		/*
 		 * Ensure that file and memory protections are
 		 * compatible.  Note that we only worry about
@@ -236,13 +243,18 @@
 		if (fp->f_flag & FREAD)
 			maxprot |= VM_PROT_READ;
 		else if (prot & PROT_READ)
+			return (EACCES);
+
+		/*
+		 * If we are sharing potential changes (either via MAP_SHARED
+		 * or via the implicit sharing of character device mappings),
+		 * and we are trying to get write permission although we
+		 * opened it without asking for it, bail out.
+		 */
+		if (((flags & MAP_SHARED) != 0 || vp->v_type == VCHR) &&
+		    (fp->f_flag & FWRITE) == 0 && (prot & PROT_WRITE) != 0)
 			return (EACCES);
-		if (flags & MAP_SHARED) {
-			if (fp->f_flag & FWRITE)
-				maxprot |= VM_PROT_WRITE;
-			else if (prot & PROT_WRITE)
-				return (EACCES);
-		} else
+		else
 			maxprot |= VM_PROT_WRITE;
 		handle = (caddr_t)vp;
 	} else {
 
< Prev   Next >
    
Partner

 

Latest Features
Peter Smith Releases Linux Network Security Online
Securing a Linux Web Server
Password guessing with Medusa 2.0
Password guessing as an attack vector
Squid and Digest Authentication
Squid and Basic Authentication
Demystifying the Chinese Hacking Industry: Earning 6 Million a Night
Free Online security course (LearnSIA) - A Call for Help
What You Need to Know About Linux Rootkits
Review: A Practical Guide to Fedora and Red Hat Enterprise Linux - Fifth Edition
Yesterday's Edition
'Snowden effect' has changed cloud data security assumption, survey claims
Galaxy S5 fingerprint scanner hacked with glue mould
Partner Sponsor

Community | HOWTOs | Blogs | Features | Book Reviews | Networking
 Security Projects |  Latest News |  Newsletters |  SELinux |  Privacy |  Home
 Hardening |   About Us |   Advertise |   Legal Notice |   RSS |   Guardian Digital
(c)Copyright 2014 Guardian Digital, Inc. All rights reserved.