From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 16 09:11:10 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8F82716A420; Fri, 16 Dec 2005 09:11:10 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from mail18.syd.optusnet.com.au (mail18.syd.optusnet.com.au [211.29.132.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id D151043D4C; Fri, 16 Dec 2005 09:11:08 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c220-239-19-236.belrs4.nsw.optusnet.com.au [220.239.19.236]) by mail18.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id jBG9AvZl023085 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Fri, 16 Dec 2005 20:10:59 +1100 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.10/8.12.10) with ESMTP id jBG9AvHh082748; Fri, 16 Dec 2005 20:10:57 +1100 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost) by cirb503493.alcatel.com.au (8.12.10/8.12.9/Submit) id jBG9AvtU082747; Fri, 16 Dec 2005 20:10:57 +1100 (EST) (envelope-from pjeremy) Date: Fri, 16 Dec 2005 20:10:57 +1100 From: Peter Jeremy To: "Wojciech A. Koszek" Message-ID: <20051216091057.GQ77268@cirb503493.alcatel.com.au> References: <20051215223745.GA37768@FreeBSD.czest.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051215223745.GA37768@FreeBSD.czest.pl> User-Agent: Mutt/1.4.2.1i X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc Cc: freebsd-hackers@freebsd.org, phk@freebsd.org Subject: Re: [CALL FOR TESTERS] New system call: abort2() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 09:11:10 -0000 On Thu, 2005-Dec-15 22:37:45 +0000, Wojciech A. Koszek wrote: > abort2(const char *why, int nargs, void **args); > >"why" is reason of program abort, "nargs" is number of arguments >passed in "args". Both "why" and "args" (with "%p" format) will be >printed via log(9). Sample output: >[..] >pid <3004> abort2: ABORT2 >pid <3019> abort2: invalid argument >[..] I don't believe the following code is correct. uap->args is a userspace pointer so uap->args[i] is dereferencing a userspace argument in kernelspace. + arg = uargs[i] = (void *) fuword(uap->args[i]); I think it should be fuword(uap->args + i); I don't see the point of the following test. "arg" is printed using %p and never de-referenced so there's no reason it can't be NULL. I would see that a legitimate use of abort2() is when the application detects that a pointer is unexpectedly NULL. Aborting on -1 is less clear - if fuword() fails, it will return -1 but, equally, a faulty user application may have left -1 in a pointer. (Note that mmap(2) returns -1 on error so it's not inconceivable that a pointer could contain -1). + /* Prevent from faults in user-space */ + if (arg == NULL || arg == (void *)-1) { + error = EINVAL; + break; + } Taking the above into account, I believe the code should be: + if (uap->args == NULL) + break; + error = copyin(uap->args, uargs, uap->nargs * sizeof (void *)); + if (error != 0) + break; -- Peter Jeremy