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

Sign up!
EnGarde Community
What is the most important Linux security technology?
Linux Events
Linux User Groups
Link to Us
Security Center
Book Reviews
Security Dictionary
Security Tips
White Papers
Featured Blogs
All About Linux
DanWalsh LiveJournal
Latest Newsletters
Linux Security Week: March 30th, 2015
Linux Advisory Watch: March 27th, 2015
LinuxSecurity Newsletters
Choose Lists:
About our Newsletters
RSS Feeds
Get the LinuxSecurity news you want faster with RSS
Powered By

NetBSD: shmat Privilege escalation vulnerability Print E-mail
User Rating:      How can I rate this item?
Posted by Team   
NetBSD A programming error in the shmat(2) system call can result in a sharedmemory segment's reference count being erroneously incremented.

NetBSD Security Advisory 2004-004

Topic:		shmat reference counting bug

Version:	NetBSD-current:	source prior to February 6th, 2004
		NetBSD 1.6.1:	affected
		NetBSD 1.6:	affected
		NetBSD-1.5.3:	affected
		NetBSD-1.5.2:	affected
		NetBSD-1.5.1:	affected
		NetBSD-1.5:	affected

Severity:	local privilege escalation

Fixed:		NetBSD-current:		February 7th, 2004
                NetBSD-1.6 branch:      February 8th, 2004
					(1.6.2 will include the fix)

		NetBSD-1.5 branch:	This fix is not yet pulled
					up. This advisory will be
					updated when it has.
					Updating to NetBSD 1.6.2 is


A programming error in the shmat(2) system call can result in a shared
memory segment's reference count being erroneously incremented.

This system call is part of the System-V Shared Memory subsystem;
although this is enabled in the default (GENERIC*) kernels, custom
kernels built without "options SYSVSHM" are not affected.

Technical Details
The shmat(2) function maps a shared memory segment, previously created
with the shmget(2) function, into the address space of the calling

The shmat(2) function first increases the reference count on the
underlying vm_object and then attempts to insert the vm_object into
the process address space.

The vulnerability occurs because the shmat(2) function forgets to
decrease the reference count if the vm_map_find function returns

Since the caller of shmat(2) can specify the address at which the
segment should be mapped it is possible to have vm_map_find return
failure and thus end up with stale references.

In the end, an unprivileged user may have write access to an
unreferenced piece of kernel memory, which could later become part of a
privileged object.

Solutions and Workarounds

If you are unable to apply the patch as described below, you may
workaround the problem by removing SYSVSHM from your kernel config
file and rebuilding and reinstalling your kernel.

*** Patching from sources:

Otherwise, the fix for this issue is contained in the one file,
sys/kern/sysv_shm.c. The following table lists the fixed revisions and
dates of this file for each branch:

  CVS branch     revision     date
  -------------  -----------  ----------------
  HEAD           1.74         2004/02/05
  netbsd-1-6     2004/02/08

The following instructions describe how to upgrade your kernel
binaries by updating your source tree and rebuilding and installing a
new version of the kernel. In these instructions, replace:

  BRANCH   with the appropriate CVS branch (from the above table)
  ARCH     with your architecture (from uname -m), and
  KERNCONF with the name of your kernel configuration file.

To update from CVS, re-build, and re-install the kernel:

        # cd src
        # cvs update -d -P -r BRANCH sys/kern/sysv_shm.c
        # cd sys/arch/ARCH/conf
        # config KERNCONF
        # cd ../compile/KERNCONF
        # make depend;make
        # mv /netbsd /netbsd.old
        # cp netbsd /
        # reboot

* Binary Patch:

	Binary patches are being provided, in the form of replacement
	kernels built with the patches from the GENERIC kernel
	configuration. If you use a custom kernel configuration, these
	may not be suitable for you.

	NOTE: The path below says SA2004-002-kernel intentionally.
	The same kernel includes fixes for NetBSD-SA2004-002 and
	NetBSD-SA2004-004. If you already updated for 2004-002,
	you do not need to perform these steps again.

        To apply the binary patch, perform the following steps,
        replacing ARCH with the NetBSD architecture you are running
        (i.e. i386):

        cd / && cp /path/to/ARCH-kernel.gz /
        gzip -d ARCH-kernel.gz

        The tar file will extract a new copy of:

	Back up your old kernel:
	mv netbsd netbsd.old

        Then either rename:
        mv ARCH-kernel netbsd

        or link, as per local site policy:
        ln ARCH-kernel netbsd

        Then, reboot.

Thanks To

Joost Pol of Pine Digital Security

FreeBSD Security-Officer

Christos Zoulas for supplying a fix.

Revision History

	2004-02-18	Initial release

More Information

Advisories may be updated as new information becomes available.
The most recent version of this advisory (PGP signed) can be found at

Information about NetBSD and NetBSD security can be found at and

Copyright 2004, The NetBSD Foundation, Inc.  All Rights Reserved.
Redistribution permitted only in full, unmodified form.

$NetBSD: NetBSD-SA2004-004.txt.asc,v 1.2 2004/02/19 03:18:38 david Exp $

< Prev   Next >


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
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 2015 Guardian Digital, Inc. All rights reserved.