NetBSD Problem Report #50573

From gson@gson.org  Sat Dec 19 19:55:41 2015
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 607947ABEC
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 19 Dec 2015 19:55:41 +0000 (UTC)
Message-Id: <20151219193612.21E6F744712@guava.gson.org>
Date: Sat, 19 Dec 2015 21:36:12 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@gnats.NetBSD.org
Subject: puffs can crash kernel for lack of argument checking
X-Send-Pr-Version: 3.95

>Number:         50573
>Category:       kern
>Synopsis:       puffs can crash kernel for lack of argument checking
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 19 20:00:00 +0000 2015
>Closed-Date:    Sun Dec 20 18:31:23 +0000 2015
>Last-Modified:  Sun Dec 20 18:31:23 +0000 2015
>Originator:     Andreas Gustafsson
>Release:        NetBSD-current, source date >= 2015.12.06.08.53.22
>Organization:
>Environment:
System: NetBSD
Architecture: x86_64
Machine: amd64
>Description:

I noticed that the mountfuzz8 test case of the fs/puffs/t_fuzz
test had been failing on amd64 (but not i386 nor sparc)
since the commit of uvm_vnode.c 1.101 by mlelstv on December 6.

The test is failing with:

  panic: kernel diagnostic assertion "newsize != VSIZENOTSET && newsize >= 0" failed: file "/tmp/bracket/build/2015.12.06.08.53.22-amd64/src/lib/librumpvfs/../../sys/rump/../uvm/uvm_vnode.c", line 351 

The full test log is at:

  http://releng.netbsd.org/b5reports/amd64/build/2015.12.06.08.53.22/test.html#fs_puffs_t_fuzz_mountfuzz8

mlelstv pointed out that the bug triggering this is is the lack
of parameter checking in fs/puffs/puffs_vfsops.c line 270ff
(marked with an XXX, no less):

 	/* XXX: check parameters */
 	pmp->pmp_root_cookie = args->pa_root_cookie;
 	pmp->pmp_root_vtype = args->pa_root_vtype; 
 	pmp->pmp_root_vsize = args->pa_root_vsize;
 	pmp->pmp_root_rdev = args->pa_root_rdev;
 	pmp->pmp_docompat = args->pa_time32;

where pa_root_vsize seems to have a negative value.

I also verified that this problem affects the real kernel and not just
the rump kernel by replacing every instance of "sys_rump_" in t_fuzz.c
by the empty string, rebuilding, and rerunning the test.  As expected,
this triggered a kernel panic.

>How-To-Repeat:

On amd64,

  cd /usr/tests/fs/puffs
  atf-run t_fuzz

>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50573 CVS commit: src/sys/fs/puffs
Date: Sat, 19 Dec 2015 20:34:00 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sun Dec 20 01:34:00 UTC 2015

 Modified Files:
 	src/sys/fs/puffs: puffs_vfsops.c

 Log Message:
 PR/50573: Andreas Gustafsson: puffs can crash kernel for lack of argument
 checking


 To generate a diff of this commit:
 cvs rdiff -u -r1.117 -r1.118 src/sys/fs/puffs/puffs_vfsops.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Sun, 20 Dec 2015 18:31:23 +0000
State-Changed-Why:
The test now passes.  Thanks to Christos for the fix.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.