-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

===========================================================================
             AUSCERT External Security Bulletin Redistribution

                               ESB-2014.2030
             Multiple vulnerabilities in the mount system call
                              4 November 2014

===========================================================================

        AusCERT Security Bulletin Summary
        ---------------------------------

Product:          kernel
Publisher:        NetBSD
Operating System: NetBSD
Impact/Access:    Denial of Service -- Existing Account
Resolution:       Patch/Upgrade

- --------------------------BEGIN INCLUDED TEXT--------------------

- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

		NetBSD Security Advisory 2014-014
		=================================

Topic:		Multiple vulnerabilities in the mount system call


Version:	NetBSD-current:		source prior to Sun, Apr 20th 2014
		NetBSD 6.1.5:		not affected
		NetBSD 6.1 - 6.1.4:	affected
		NetBSD 6.0.6:		not affected
		NetBSD 6.0 - 6.0.5:	affected
		NetBSD 5.1 - 5.1.4:	affected
		NetBSD 5.2 - 5.2.2:	affected

Severity:	Local DoS

Fixed:		NetBSD-current:		Sun, Apr 20th 2014
		NetBSD-6-0 branch:	Mon, 21 Apr 2014
		NetBSD-6-1 branch:	Mon, 21 Apr 2014
		NetBSD-6 branch:	Mon, 21 Apr 2014
		NetBSD-5-2 branch:	Tue, 29 Apr 2014
		NetBSD-5-1 branch:	Tue, 29 Apr 2014
		NetBSD-5 branch:	Sat, 26 Apr 2014

Teeny versions released later than the fix date will contain the fix.

Please note that NetBSD releases prior to 5.1 are no longer supported.
It is recommended that all users upgrade to a supported release.


Abstract
========

Due to:
	- missing input validation checks in the mount syscall
	- a wrong assumption on the file systems side
	- a memory corruption bug
the kernel could:
	- allocate an unbounded or zero-sized memory buffer
	- dereference a NULL pointer
	- behave unexpectedly


Technical Details
=================

The mount syscall takes as fourth and fifth arguments an input buffer
and its size. A kernel buffer of the same size is allocated via kmem,
and is then handed over to the appropriate file system. This buffer is
then freed when no longer needed.

The checks on the size of the kernel-allocated buffer were not strict
enough, and a local user could easily make the kernel perform a zero-
sized or unbounded memory allocation, resulting in a crash.

Also, in particular cases, the buffer pointer given to the underlying
file systems is allowed to be NULL - some file systems don't need it.
The others didn't explicitly check for NULL, and were wrongly making the
assumption that it was always a valid, readable buffer, causing the
kernel to panic with a page fault.

Finally, a bug could corrupt memory when freeing the kernel-allocated
buffer. The buffer is freed via kmem_free, whose second argument
indicates the size of the allocated buffer. This size was held by a
local variable which was modified by the underlying file systems, thus
creating a memory inconsistency when freeing which could lead to a
crash or unexpected behavior.


Solutions and Workarounds
=========================

For all NetBSD versions, you need to obtain fixed kernel sources,
rebuild and install the new kernel, and reboot the system.
                                      
The fixed source may be obtained from the NetBSD CVS repository.        
The following instructions briefly summarise how to upgrade your        
kernel.  In these instructions, replace:

  ARCH     with your architecture (from uname -m),               
  KERNCONF with the name of your kernel configuration file and  
  VERSION  with the file version below

File versions containing the fixes:

files relative to src/sys/fs/:

 HEAD  netbsd-6  netbsd-6-1    netbsd-6-0    netbsd-5   netbsd-5-2    netbsd-5-1
 ----  --------  ----------    ----------    --------   ----------    ----------
adosfs/advfsops.c
 1.70  1.63.6.1  1.63.12.1     1.63.10.1     1.53.6.1   1.53.20.1     1.53.16.1
cd9660/cd9660_vfsops.c
 1.84  1.74.6.1  1.74.12.1     1.74.10.1     1.63.6.2   1.63.6.1.6.1  1.63.6.1.2.1
efs/efs_vfsops.c
 1.25  1.22.8.1  1.22.14.1     1.22.12.1     1.16.4.2   1.16.4.1.10.1 1.16.4.1.6.1
filecorefs/filecore_vfsops.c
 1.76  1.68.6.1  1.68.12.1     1.68.10.1     1.55.6.1   1.55.20.1     1.55.16.1
hfs/hfs_vfsops.c
 1.31  1.27.8.2  1.27.8.1.6.1  1.27.8.1.4.1  1.19.4.1   1.19.16.1     1.19.12.1
msdosfs/msdosfs_vfsops.c
 1.107 1.93.6.2  1.93.6.1.6.1  1.93.6.1.4.1  1.68.6.3   1.68.6.2.10.1 1.68.6.2.6.1
nilfs/nilfs_vfsops.c
 1.16  1.8.6.1   1.8.12.1      1.8.10.1      n/a        n/a           n/a
ntfs/ntfs_vfsops.c
 1.94  1.87.6.1  1.87.20.1     1.87.12.1     1.72.6.2   1.72.6.1.6.1  1.72.6.1.2.1
ptyfs/ptyfs_vfsops.c
 1.50  1.42.18.2 1.42.18.1.4.1 1.42.18.1.2.1 1.37.4.1   1.37.18.1     1.37.14.1
puffs/puffs_vfsops.c
 1.110 1.100.8.3 1.100.8.2.6.1 1.100.8.2.4.1 1.81.8.4   1.81.8.3.2.1  1.81.8.1.2.1
smbfs/smbfs_vfsops.c
 1.100 1.95.8.1  1.95.22.1     1.95.14.1     1.85.4.2   1.85.4.1.6.1  1.85.4.1.2.1
sysvbfs/sysvbfs_vfsops.c
 1.43  1.38.6.2  1.38.6.1.6.1  1.38.6.1.4.1  1.26.4.1   1.26.18.1     1.26.14.1
tmpfs/tmpfs_vfsops.c
 1.59  1.52.8.1  1.52.22.1     1.52.14.1     1.44.4.1   1.44.22.1     1.44.18.1
udf/udf_vfsops.c
 1.67  1.62.6.1  1.62.12.1     1.62.10.1     1.52.2.4   1.52.2.3.6.1  1.52.2.3.2.1
union/union_vfsops.c
 1.72  1.67.2.1  1.67.8.1      1.67.6.1      1.57.6.3   1.57.6.2.2.1  1.57.6.1.6.1
unionfs/unionfs_vfsops.c
 1.13  1.9.10.1  1.9.18.1      1.9.16.1      1.5.6.1    1.5.16.1      1.5.12.1
v7fs/v7fs_vfsops.c
 1.10  1.5.6.2   1.5.6.1.6.1   1.5.6.1.4.1   n/a        n/a           n/a

files relative to src/sys/miscfs/:

 HEAD  netbsd-6  netbsd-6-1    netbsd-6-0    netbsd-5   netbsd-5-2    netbsd-5-1
 ----  --------  ----------    ----------    --------   ----------    ----------
nullfs/null_vfsops.c
 1.88  1.83.14.1 1.83.20.1     1.83.18.1     1.77.6.1   1.77.16.1     1.77.12.1
overlay/overlay_vfsops.c
 1.61  1.56.14.1 1.56.20.1     1.56.18.1     1.53.6.1   1.53.16.1     1.53.12.1
procfs/procfs_vfsops.c
 1.91  1.86.8.1  1.86.14.1     1.86.12.1     1.81.6.1   1.81.20.1     1.81.16.1
umapfs/umap_vfsops.c
 1.92  1.86.14.1 1.86.20.1     1.86.18.1     1.80.6.1   1.80.16.1     1.80.12.1

files relative to src/sys/ufs/:

 HEAD  netbsd-6  netbsd-6-1    netbsd-6-0    netbsd-5   netbsd-5-2    netbsd-5-1
 ----  --------  ----------    ----------    --------   ----------    ----------
chfs/chfs_vfsops.c
 1.11  1.2.4.1   1.2.10.1      1.2.8.1       n/a        n/a           n/a
ext2fs/ext2fs_vfsops.c
 1.180 1.162.6.1 1.162.12.1    1.162.10.1    1.137.6.7  1.137.6.6.2.1 1.137.6.5.2.1
ffs/ffs_vfsops.c
 1.297 1.275.2.3 1.275.2.2.4.1 1.275.2.2.2.1 1.239.2.5  1.239.2.4.6.1 1.239.2.4.2.1
lfs/lfs_vfsops.c
 1.321 1.293.2.2 1.293.2.1.6.1 1.293.2.1.4.1 1.267.6.2  1.267.6.1.10.1
                                                                      1.267.6.1.6.1
mfs/mfs_vfsops.c
 1.107 1.103.8.1 1.103.22.1    1.103.14.1    1.98.6.1   1.98.16.1     1.98.12.1

remaining files:

 HEAD  netbsd-6  netbsd-6-1    netbsd-6-0    netbsd-5   netbsd-5-2    netbsd-5-1
 ----  --------  ----------    ----------    --------   ----------    ----------
src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
 1.12  1.7.2.1   1.7.10.1      1.7.8.1       n/a        n/a           n/a
src/sys/coda/coda_vfsops.c
 1.81  1.70.8.1  1.70.14.1     1.70.12.1     1.66.8.1   1.66.22.1     1.66.18.1
src/sys/kern/vfs_syscalls.c
 1.482 1.449.2.3 1.449.2.2.6.1 1.449.2.2.4.1 1.376.4.8  1.376.4.7.2.1 1.376.4.5.2.2
src/sys/nfs/nfs_vfsops.c
 1.227 1.220.8.1 1.220.16.1    1.220.14.1    1.203.4.1  1.203.14.1    1.203.10.1


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

	# cd src
	# cvs update -d -P -r VERSION \
		external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
	# cvs update -d -P -r VERSION sys/coda/coda_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/adosfs/advfsops.c
	# cvs update -d -P -r VERSION sys/fs/cd9660/cd9660_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/efs/efs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/filecorefs/filecore_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/hfs/hfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/msdosfs/msdosfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/nilfs/nilfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/ntfs/ntfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/ptyfs/ptyfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/puffs/puffs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/smbfs/smbfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/sysvbfs/sysvbfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/tmpfs/tmpfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/udf/udf_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/union/union_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/unionfs/unionfs_vfsops.c
	# cvs update -d -P -r VERSION sys/fs/v7fs/v7fs_vfsops.c
	# cvs update -d -P -r VERSION sys/kern/vfs_syscalls.c
	# cvs update -d -P -r VERSION sys/miscfs/nullfs/null_vfsops.c
	# cvs update -d -P -r VERSION sys/miscfs/overlay/overlay_vfsops.c
	# cvs update -d -P -r VERSION sys/miscfs/procfs/procfs_vfsops.c
	# cvs update -d -P -r VERSION sys/miscfs/umapfs/umap_vfsops.c
	# cvs update -d -P -r VERSION sys/nfs/nfs_vfsops.c
	# cvs update -d -P -r VERSION sys/ufs/chfs/chfs_vfsops.c
	# cvs update -d -P -r VERSION sys/ufs/ext2fs/ext2fs_vfsops.c
	# cvs update -d -P -r VERSION sys/ufs/ffs/ffs_vfsops.c
	# cvs update -d -P -r VERSION sys/ufs/lfs/lfs_vfsops.c
	# cvs update -d -P -r VERSION sys/ufs/mfs/mfs_vfsops.c
	# ./build.sh kernel=KERNCONF
	# mv /netbsd /netbsd.old
	# cp sys/arch/ARCH/compile/obj/KERNCONF/netbsd /netbsd 
	# shutdown -r now

For more information on how to do this, see:    

   http://www.NetBSD.org/guide/en/chap-kernel.html


Thanks To
=========

Thanks to Maxime Villard, Christos Zoulas and matthew green; Maxime Villard
for finding the issues and all three for developing fixes.


Note
====

It is to be noted that despite the long, unusual time the NetBSD Foundation
took to release this Security Advisory, the fixes listed above were applied
and propagated to the stable branches as soon as the vulnerabilities were
discovered.


Revision History
================

	2014-11-03	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 
  http://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2014-014.txt.asc

Information about NetBSD and NetBSD security can be found at
http://www.NetBSD.org/ and http://www.NetBSD.org/Security/ .


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

$NetBSD: NetBSD-SA2014-014.txt,v 1.2 2014/11/03 09:09:54 spz Exp $

- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (NetBSD)

iQIcBAEBAgAGBQJUV/DWAAoJEAZJc6xMSnBuNLgP/AnDp79AhVChEzy0RadpTO2Z
xOPhtl9Dd8XCQ/UgIYEs1F0Z0yR31g7vrC+d5T6Y81UV+AR+2DtecUmWyc4rTSH9
sCQZFKNWocYh61AFiKMb8INnYp5a0KHK4HcD/mFeQKf3fhpJG9JrgDLzHoa7oqde
N/gUt6sPdRGpTjBpdBcHX2H9o1w9s/3YY0VGimTzNCyKK1cnKNn1m4+sWnQp2nvC
507uUeyxIfX4QWtFeErRnijynLsVnBsC5MasOz7/EgEfIAQ+2LHOcEPkUf7Z7iMg
Lupz733aGahRYKud64LrNtunZ7BLDfxKkZ4Csf5NhKPudw7paNdmgOy++/ENqBNS
SmtCDf7i7ooH4mCHmKhD15oFXK+RQaJRp9yLzJ2KWDsukVu3Unt8xUXEc28L5LTd
Ng3DaZDU9h0QdCgYsbkqQQk+82iraJWqkap0eZEVVv6jgzsutvzC2mcdufprjhIw
eIlpcOEYiwVPUnKEfwpz9lwVCYgBORDTBAwTXxjZFNn/MsBh5cqYN7fio1KFwRPO
xSnA2EQOOfw3rVosQt6kAk7Mal/X9ylxshU32l6EjokHwSXyXYswcXRu3E9VV2bX
acFNypOhjIic3oeIxqIljzZzvmi3TebWkv/AOChaDkbShpklvmRd5FsSAJOKbNd/
Z5cyxU2JgFao3/aVxP/S
=dGEn
- -----END PGP SIGNATURE-----

- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

NOTE: Third Party Rights
This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content. The decision to follow or act on information or advice
contained in this security bulletin is the responsibility of each user or
organisation, and should be considered in accordance with your organisation's
site policies and procedures. AusCERT takes no responsibility for consequences
which may arise from following or acting on information or advice contained in
this security bulletin.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:

        http://www.auscert.org.au/render.html?cid=1980

===========================================================================
Australian Computer Emergency Response Team
The University of Queensland
Brisbane
Qld 4072

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for member emergencies only.
===========================================================================
-----BEGIN PGP SIGNATURE-----
Comment: http://www.auscert.org.au/render.html?it=1967

iQIVAwUBVFgaVxLndAQH1ShLAQLt1A//RRHS0oTfsMb5t+Owd1PXZv54Af3INrQl
EyVE6+Koa17mnIVmFXzr6Vd359AGwFabyAcgZfAzoi+Lbxt/ljd884WFhZS5lNhk
dvJa7FcgdFckZ9ByfwfYkrUUmkNsw+whrBPyjQSm+OodyeTjsMqGkBFNjTJ/5e3t
GZgytuLP9bDhM22jsKJGfC/BnYiE0xy4pEtWSjOxhZLsBNPQHXC90uwXI5ncqkqH
Sw358EeSLWL5B76aiUvE7aZd4Vuztn+x5vPZdgKxZCqVloacbCQONt0md006no5o
o41DcBpTNcXyN6iOsPV8vU/wGr6sCm4jZMSAwFdsxiU3ozqy0JXW0PRasCNOROT1
avyORjakCuvRye6obVRn+vFimHg2sAQuvf2MiFQ4Zg2N3lfHyqRYSkblEXuKReSC
n016JVZ+rjg8gAtb/k7jX+ePPIVTbrIylPOTNtBIMnZx2CWlxecAQG+btXJdZ7EX
/ta0cIS4DNhfYo1xEdzOOCixQDg8nvrKQEo0OATT5A9/g5blVC13NuHbIfYQ182j
iTYTKy4VoLgCEey46KaHupuZ6Vc26fj8T+mQFwo2ANVVV4i/2ciAXLO7q1pJTX2U
kdifDrODm/QONyVJYWIg0ZzlcgOCazZX5YvHYjK+qwFM7kMSUrCkEKcSv87PWAC5
nt2ai7gDtDo=
=GgA2
-----END PGP SIGNATURE-----