From nobody@FreeBSD.org  Wed Jun 18 16:59:54 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4C9A7106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Jun 2008 16:59:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 1ACD08FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Jun 2008 16:59:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m5IGxr31010624
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Jun 2008 16:59:53 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m5IGxrdo010623;
	Wed, 18 Jun 2008 16:59:53 GMT
	(envelope-from nobody)
Message-Id: <200806181659.m5IGxrdo010623@www.freebsd.org>
Date: Wed, 18 Jun 2008 16:59:53 GMT
From: "K. Zolotukhin" <heliar@at.nsu.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: netstat coredump on -stable
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         124724
>Category:       bin
>Synopsis:       [patch] netstat(1): netstat coredump on -stable
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 18 17:00:04 UTC 2008
>Closed-Date:    Mon Jan 19 10:44:44 UTC 2009
>Last-Modified:  Mon Jan 19 10:50:02 UTC 2009
>Originator:     K. Zolotukhin
>Release:        FreeBSD 7.0-STABLE
>Organization:
>Environment:
FreeBSD h51n30.campus.nsu.ru 7.0-STABLE FreeBSD 7.0-STABLE #3: Sun Jun  8 17:51:18 NOVST 2008     root@h51n30.campus.nsu.ru:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Error when parsing netstat arguments - coredump on netstat -m <foo>, if <foo> isn't number
>How-To-Repeat:
netstat -m iloveheliar
>Fix:


>Release-Note:
>Audit-Trail:

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: "K. Zolotukhin" <heliar@at.nsu.ru>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/124724: netstat coredump on -stable
Date: Wed, 18 Jun 2008 21:03:49 -0700

 > Same thing occurs on -CURRENT (backtrace):
 >
 > (gdb) bt
 > #0  0x280960ff in kvm_nlist () from /lib/libkvm.so.4
 > #1  0x2809b25e in memstat_kvm_malloc () from /usr/lib/libmemstat.so.2
 > #2  0x2809a0fa in memstat_kvm_all () from /usr/lib/libmemstat.so.2
 > #3  0x08050aa8 in mbpr (kvmd=0x0, mbaddr=0) at mbuf.c:103
 > #4  0x080500eb in main (argc=1, argv=0xbfbfec40) at main.c:510
 
 After doing some reading it appears that netstat is passing in an
 invalid value to memstat_kvm_all, which subsequently calls
 memstat_kvm_malloc for mbuf.c (kvmd = NULL). Calling malloc with NULL
 for a pointer address of course is invalid coding.
 
 main.c:510 should probably be modified to print out an error message
 of some kind instead of:
 
 mbpr(NULL, 0);
 
 The maintainer (gnn@, net@?) should be assigned this bug.
 
 -Garrett

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: "K. Zolotukhin" <heliar@at.nsu.ru>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/124724: netstat coredump on -stable
Date: Wed, 18 Jun 2008 20:47:39 -0700

 Same thing occurs on -CURRENT (backtrace):
 
 (gdb) bt
 #0  0x280960ff in kvm_nlist () from /lib/libkvm.so.4
 #1  0x2809b25e in memstat_kvm_malloc () from /usr/lib/libmemstat.so.2
 #2  0x2809a0fa in memstat_kvm_all () from /usr/lib/libmemstat.so.2
 #3  0x08050aa8 in mbpr (kvmd=0x0, mbaddr=0) at mbuf.c:103
 #4  0x080500eb in main (argc=1, argv=0xbfbfec40) at main.c:510

From: Jaakko Heinonen <jh@saunalahti.fi>
To: Garrett Cooper <yanefbsd@gmail.com>
Cc: bug-followup@FreeBSD.org, heliar@at.nsu.ru
Subject: Re: bin/124724: netstat coredump on -stable
Date: Mon, 23 Jun 2008 21:58:56 +0300

 Hi,
 
 On 2008-06-19, Garrett Cooper wrote:
 >  > Same thing occurs on -CURRENT (backtrace):
 >  >
 >  > (gdb) bt
 >  > #0  0x280960ff in kvm_nlist () from /lib/libkvm.so.4
 >  > #1  0x2809b25e in memstat_kvm_malloc () from /usr/lib/libmemstat.so.2
 >  > #2  0x2809a0fa in memstat_kvm_all () from /usr/lib/libmemstat.so.2
 >  > #3  0x08050aa8 in mbpr (kvmd=0x0, mbaddr=0) at mbuf.c:103
 >  > #4  0x080500eb in main (argc=1, argv=0xbfbfec40) at main.c:510
 >  
 >  After doing some reading it appears that netstat is passing in an
 >  invalid value to memstat_kvm_all, which subsequently calls
 >  memstat_kvm_malloc for mbuf.c (kvmd = NULL). Calling malloc with NULL
 >  for a pointer address of course is invalid coding.
 
 This happens when memf == NULL and nlistf != NULL (main.c). This
 situation (where memf == NULL and nlistf != NULL) doesn't make sense
 because kvm_openfiles(3) doesn't make use of nlistf value if memf is
 null (kvm_openfiles() call at line 674 in r179949). If both mentioned
 variables are NULL a live mode which copes with NULL values is enabled.
 
 The bug is also reproducible with following command line:
 
 $ netstat -m -N foo
 Segmentation fault: 11
 
 Below is a fix that makes it to exit with an error message if memf ==
 NULL and nlistf != NULL.
 
 After applying the fix:
 
 $ netstat -m foo
 netstat: no core file specified
 
 -- 
 Jaakko
 
 Index: usr.bin/netstat/main.c
 ===================================================================
 --- usr.bin/netstat/main.c	(revision 179949)
 +++ usr.bin/netstat/main.c	(working copy)
 @@ -492,7 +492,12 @@ main(int argc, char *argv[])
  	 * Discard setgid privileges if not the running kernel so that bad
  	 * guys can't print interesting stuff from kernel memory.
  	 */
 -	live = (nlistf == NULL && memf == NULL);
 +	if (memf == NULL) {
 +		if (nlistf != NULL)
 +			errx(1, "no core file specified");
 +		live = 1;
 +	}
 +
  	if (!live)
  		setgid(getgid());
  

From: "Li yonggang" <leeygang@gmail.com>
To: bug-followup@freebsd.org, heliar@at.nsu.ru
Cc:  
Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable
Date: Fri, 9 Jan 2009 10:26:52 +0800

 ------=_Part_239123_24298306.1231468012486
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 I think the root cause is that netstat does not check if the input is correct.
 so I think we should add some input checker while remove the
 BACKWARD_PATIBILITY code, which will lead to use incorrect input.
 
 ------=_Part_239123_24298306.1231468012486
 Content-Type: application/octet-stream; name=main.diff
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_fpq86ahi0
 Content-Disposition: attachment; filename=main.diff
 
 KioqIG1haW4uYwlUdWUgSmFuICA2IDE1OjAxOjI1IDIwMDkKLS0tIC4uL21haW4uYwlUaHUgSmFu
 ICA4IDEzOjU3OjM4IDIwMDkKKioqKioqKioqKioqKioqCioqKiAzNDEsMzQ2ICoqKioKLS0tIDM0
 MSwzNDcgLS0tLQogIGludAlhZjsJCS8qIGFkZHJlc3MgZmFtaWx5ICovCiAgaW50CWxpdmU7CQkv
 KiB0cnVlIGlmIHdlIGFyZSBleGFtaW5pbmcgYSBsaXZlIHN5c3RlbSAqLwogIAorIAogIGludAog
 IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKICB7CioqKioqKioqKioqKioqKgoqKiogNDYz
 LDQ4OSAqKioqCiAgCQlkZWZhdWx0OgogIAkJCXVzYWdlKCk7CiAgCQl9CiEgCWFyZ3YgKz0gb3B0
 aW5kOwohIAlhcmdjIC09IG9wdGluZDsKISAKISAjZGVmaW5lCUJBQ0tXQVJEX0NPTVBBVElCSUxJ
 VFkKISAjaWZkZWYJQkFDS1dBUkRfQ09NUEFUSUJJTElUWQohIAlpZiAoKmFyZ3YpIHsKISAJCWlm
 IChpc2RpZ2l0KCoqYXJndikpIHsKISAJCQlpbnRlcnZhbCA9IGF0b2koKmFyZ3YpOwohIAkJCWlm
 IChpbnRlcnZhbCA8PSAwKQohIAkJCQl1c2FnZSgpOwohIAkJCSsrYXJndjsKISAJCQlpZmxhZyA9
 IDE7CiEgCQl9CiEgCQlpZiAoKmFyZ3YpIHsKISAJCQlubGlzdGYgPSAqYXJndjsKISAJCQlpZiAo
 KisrYXJndikKISAJCQkJbWVtZiA9ICphcmd2OwohIAkJfQohIAl9CiEgI2VuZGlmCiEgCiAgCS8q
 CiAgCSAqIERpc2NhcmQgc2V0Z2lkIHByaXZpbGVnZXMgaWYgbm90IHRoZSBydW5uaW5nIGtlcm5l
 bCBzbyB0aGF0IGJhZAogIAkgKiBndXlzIGNhbid0IHByaW50IGludGVyZXN0aW5nIHN0dWZmIGZy
 b20ga2VybmVsIG1lbW9yeS4KLS0tIDQ2NCw0NzQgLS0tLQogIAkJZGVmYXVsdDoKICAJCQl1c2Fn
 ZSgpOwogIAkJfQohICAgICAvKgohICAgICAgKiBQYXJhbXMgc2hvdWxkIGJlIHBhcnNlZCB3aXRo
 b3V0IGVycm9yLgohICAgICAgKiAqLwohICAgICBpZigqKGFyZ3YgKz0gb3B0aW5kKSkKISAgICAg
 ICAgIHVzYWdlKCk7CiAgCS8qCiAgCSAqIERpc2NhcmQgc2V0Z2lkIHByaXZpbGVnZXMgaWYgbm90
 IHRoZSBydW5uaW5nIGtlcm5lbCBzbyB0aGF0IGJhZAogIAkgKiBndXlzIGNhbid0IHByaW50IGlu
 dGVyZXN0aW5nIHN0dWZmIGZyb20ga2VybmVsIG1lbW9yeS4K
 ------=_Part_239123_24298306.1231468012486--

From: Jaakko Heinonen <jh@saunalahti.fi>
To: Li yonggang <leeygang@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable
Date: Fri, 9 Jan 2009 13:51:16 +0200

 Hi,
 
 On 2009-01-09, Li yonggang wrote:
 >  I think the root cause is that netstat does not check if the input is
 >  correct.  so I think we should add some input checker while remove
 >  the
 >  BACKWARD_PATIBILITY code, which will lead to use incorrect input.
 
 Did you see my analysis and the patch for the problem?
 
 http://lists.freebsd.org/pipermail/freebsd-bugs/2008-June/031294.html
 
 Your patch doesn't address the "netstat -m -N foo" case. It also removes
 the backward compatibility code. I don't know if that code has any real
 value but I don't see need to remove it to fix this bug.
 
 -- 
 Jaakko

From: "Li yonggang" <leeygang@gmail.com>
To: "Jaakko Heinonen" <jh@saunalahti.fi>
Cc: bug-followup@freebsd.org
Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable
Date: Fri, 9 Jan 2009 15:23:36 +0000

 ------=_Part_245680_27460863.1231514616637
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 Thanks for your reply.
 your analysis is correct for netstat -m -N foo.
 but for netstat -m foo.I think it is caused by not checking the input,
 which is definitely not a good habit and bug latency.
 So a input check should be done as soon as possible.
 I combined the fixes of yours and mine to fix these 2 problems.
 
 I don't know why my diff can not show correctly, so I put it below as well:
 
 --- main.c	2009-01-09 15:05:05.000000000 +0000
 +++ ../main.c	2009-01-08 13:57:38.000000000 +0000
 @@ -341,6 +341,7 @@
  int	af;		/* address family */
  int	live;		/* true if we are examining a live system */
 
 +
  int
  main(int argc, char *argv[])
  {
 @@ -463,27 +464,11 @@
  		default:
  			usage();
  		}
 -	argv += optind;
 -	argc -= optind;
 -
 -#define	BACKWARD_COMPATIBILITY
 -#ifdef	BACKWARD_COMPATIBILITY
 -	if (*argv) {
 -		if (isdigit(**argv)) {
 -			interval = atoi(*argv);
 -			if (interval <= 0)
 -				usage();
 -			++argv;
 -			iflag = 1;
 -		}
 -		if (*argv) {
 -			nlistf = *argv;
 -			if (*++argv)
 -				memf = *argv;
 -		}
 -	}
 -#endif
 -
 +    /*
 +     * Check if params are parsed correctly
 +     * */
 +    if(*(argv += optind))
 +        usage();
  	/*
  	 * Discard setgid privileges if not the running kernel so that bad
  	 * guys can't print interesting stuff from kernel memory.
 
 
 
 On 1/9/09, Jaakko Heinonen <jh@saunalahti.fi> wrote:
 >
 > Hi,
 >
 > On 2009-01-09, Li yonggang wrote:
 >>  I think the root cause is that netstat does not check if the input is
 >>  correct.  so I think we should add some input checker while remove
 >>  the
 >>  BACKWARD_PATIBILITY code, which will lead to use incorrect input.
 >
 > Did you see my analysis and the patch for the problem?
 >
 > http://lists.freebsd.org/pipermail/freebsd-bugs/2008-June/031294.html
 >
 > Your patch doesn't address the "netstat -m -N foo" case. It also removes
 > the backward compatibility code. I don't know if that code has any real
 > value but I don't see need to remove it to fix this bug.
 >
 > --
 > Jaakko
 >
 
 ------=_Part_245680_27460863.1231514616637
 Content-Type: text/x-diff; name=main.diff
 Content-Transfer-Encoding: base64
 X-Attachment-Id: file0
 Content-Disposition: attachment; filename=main.diff
 
 LS0tIG1haW4uYwkyMDA5LTAxLTA5IDE1OjE3OjUxLjAwMDAwMDAwMCArMDAwMAorKysgLi4vbWFp
 bi5jCTIwMDktMDEtMDkgMTU6MTc6MDcuMDAwMDAwMDAwICswMDAwCkBAIC0zNDEsNiArMzQxLDcg
 QEAKIGludAlhZjsJCS8qIGFkZHJlc3MgZmFtaWx5ICovCiBpbnQJbGl2ZTsJCS8qIHRydWUgaWYg
 d2UgYXJlIGV4YW1pbmluZyBhIGxpdmUgc3lzdGVtICovCiAKKwogaW50CiBtYWluKGludCBhcmdj
 LCBjaGFyICphcmd2W10pCiB7CkBAIC00NjMsMzIgKzQ2NCwyMyBAQAogCQlkZWZhdWx0OgogCQkJ
 dXNhZ2UoKTsKIAkJfQotCWFyZ3YgKz0gb3B0aW5kOwotCWFyZ2MgLT0gb3B0aW5kOwotCi0jZGVm
 aW5lCUJBQ0tXQVJEX0NPTVBBVElCSUxJVFkKLSNpZmRlZglCQUNLV0FSRF9DT01QQVRJQklMSVRZ
 Ci0JaWYgKCphcmd2KSB7Ci0JCWlmIChpc2RpZ2l0KCoqYXJndikpIHsKLQkJCWludGVydmFsID0g
 YXRvaSgqYXJndik7Ci0JCQlpZiAoaW50ZXJ2YWwgPD0gMCkKLQkJCQl1c2FnZSgpOwotCQkJKyth
 cmd2OwotCQkJaWZsYWcgPSAxOwotCQl9Ci0JCWlmICgqYXJndikgewotCQkJbmxpc3RmID0gKmFy
 Z3Y7Ci0JCQlpZiAoKisrYXJndikKLQkJCQltZW1mID0gKmFyZ3Y7Ci0JCX0KLQl9Ci0jZW5kaWYK
 LQotCS8qCisgICAgLyoKKyAgICAgKiBQYXJhbXMgc2hvdWxkIGJlIHBhcnNlZCB3aXRob3V0IGVy
 cm9yLgorICAgICAqICovCisgICAgaWYoKihhcmd2ICs9IG9wdGluZCkpCisgICAgICAgIHVzYWdl
 KCk7CisgICAgLyoKKyAgICAgKiBrdm1fb3BlbmZpbGVzKDMpIGRvZXNuJ3QgbWFrZSB1c2Ugb2Yg
 bmxpc3RmIHZhbHVlIGlmIG1lbWYgaWYKKyAgICAgKiBudWxsLgorICAgICAqICovCisJaWYobmxp
 c3RmJiYhbWVtZikKKyAgICAgICAgZXJyeCgxLCJubyBjb3JlIGZpbGUgc3BlY2lmaWVkIik7Cisg
 ICAgLyoKIAkgKiBEaXNjYXJkIHNldGdpZCBwcml2aWxlZ2VzIGlmIG5vdCB0aGUgcnVubmluZyBr
 ZXJuZWwgc28gdGhhdCBiYWQKIAkgKiBndXlzIGNhbid0IHByaW50IGludGVyZXN0aW5nIHN0dWZm
 IGZyb20ga2VybmVsIG1lbW9yeS4KIAkgKi8KIAlsaXZlID0gKG5saXN0ZiA9PSBOVUxMICYmIG1l
 bWYgPT0gTlVMTCk7CisgICAgCiAJaWYgKCFsaXZlKQogCQlzZXRnaWQoZ2V0Z2lkKCkpOwogCg==
 
 ------=_Part_245680_27460863.1231514616637--

From: Jaakko Heinonen <jh@saunalahti.fi>
To: Li yonggang <leeygang@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable
Date: Sat, 10 Jan 2009 11:11:18 +0200

 Hi,
 
 On 2009-01-09, Li yonggang wrote:
 > your analysis is correct for netstat -m -N foo.
 > but for netstat -m foo.I think it is caused by not checking the input,
 > which is definitely not a good habit and bug latency.
 > So a input check should be done as soon as possible.
 > I combined the fixes of yours and mine to fix these 2 problems.
 
 I am not sure if I understand what you mean with "input checking" but I
 suspect that you mean checking of all command line arguments. netstat
 accepts for example following command line:
 
 $ netstat /boot/kernel/kernel /var/crash/vmcore.1 1 2 3 4 5
 
 It doesn't complain about extra command line arguments.
 
 However I disagree that my analysis is incorrect about the segfault with
 "netstat -m foo" command line. The crash happens in libkvm because
 kvm_openfiles() is called with non-NULL nlistf and NULL memf. My patch
 adds a check for this case and netstat aborts with an error message
 before any kvm(3) calls.
 
 I agree that it may be a good idea to remove the old backward
 compatibility code for an ancient (undocumented?) syntax for specifying
 some parameters without options provided that no one uses the syntax.
 It's also reasonable to give an error if superfluous command line
 arguments are given.
 
 -- 
 Jaakko
State-Changed-From-To: open->patched 
State-Changed-By: ru 
State-Changed-When: Sat Jan 10 12:39:23 UTC 2009 
State-Changed-Why:  
Fixed in HEAD. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Sat Jan 10 12:39:23 UTC 2009 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=124724 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/124724: commit references a PR
Date: Sat, 10 Jan 2009 12:39:27 +0000 (UTC)

 Author: ru
 Date: Sat Jan 10 12:39:12 2009
 New Revision: 187018
 URL: http://svn.freebsd.org/changeset/base/187018
 
 Log:
   Fix crash with "netstat -m -N foo".
   
   PR:		bin/124724
   MFC after:	3 days
 
 Modified:
   head/usr.bin/netstat/main.c
 
 Modified: head/usr.bin/netstat/main.c
 ==============================================================================
 --- head/usr.bin/netstat/main.c	Sat Jan 10 11:45:47 2009	(r187017)
 +++ head/usr.bin/netstat/main.c	Sat Jan 10 12:39:12 2009	(r187018)
 @@ -507,7 +507,7 @@ main(int argc, char *argv[])
  		exit(0);
  	}
  	if (mflag) {
 -		if (memf != NULL) {
 +		if (!live) {
  			if (kread(0, NULL, 0) == 0)
  				mbpr(kvmd, nl[N_MBSTAT].n_value);
  		} else
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: "Li yonggang" <leeygang@gmail.com>
To: "Jaakko Heinonen" <jh@saunalahti.fi>
Cc: bug-followup@freebsd.org
Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable
Date: Sat, 10 Jan 2009 21:54:13 +0800

 Thanks very much for your quick reply.
 Do you agree the last change that combines the fixes from you and me?
 
 One thing I should explain, I think your analysis is correct for
 netstat -m -N foo, and your fix also applies for netstat -m foo.
 but I don't think we should consider this kind of  exception made by
 illegal input(netstat -m foo), while any illegal input should be kept
 out of our door:). so all illegal input should be checked out as early
 as possible:).
 
 
 On Sat, Jan 10, 2009 at 5:11 PM, Jaakko Heinonen <jh@saunalahti.fi> wrote:
 >
 > Hi,
 >
 > On 2009-01-09, Li yonggang wrote:
 >> your analysis is correct for netstat -m -N foo.
 >> but for netstat -m foo.I think it is caused by not checking the input,
 >> which is definitely not a good habit and bug latency.
 >> So a input check should be done as soon as possible.
 >> I combined the fixes of yours and mine to fix these 2 problems.
 >
 > I am not sure if I understand what you mean with "input checking" but I
 > suspect that you mean checking of all command line arguments. netstat
 > accepts for example following command line:
 >
 > $ netstat /boot/kernel/kernel /var/crash/vmcore.1 1 2 3 4 5
 >
 > It doesn't complain about extra command line arguments.
 >
 > However I disagree that my analysis is incorrect about the segfault with
 > "netstat -m foo" command line. The crash happens in libkvm because
 > kvm_openfiles() is called with non-NULL nlistf and NULL memf. My patch
 > adds a check for this case and netstat aborts with an error message
 > before any kvm(3) calls.
 >
 > I agree that it may be a good idea to remove the old backward
 > compatibility code for an ancient (undocumented?) syntax for specifying
 > some parameters without options provided that no one uses the syntax.
 > It's also reasonable to give an error if superfluous command line
 > arguments are given.
 >
 > --
 > Jaakko
 >
State-Changed-From-To: patched->closed 
State-Changed-By: ru 
State-Changed-When: Mon Jan 19 10:44:24 UTC 2009 
State-Changed-Why:  
Fixed in 7.1-STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124724 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/124724: commit references a PR
Date: Mon, 19 Jan 2009 10:44:33 +0000 (UTC)

 Author: ru
 Date: Mon Jan 19 10:44:16 2009
 New Revision: 187431
 URL: http://svn.freebsd.org/changeset/base/187431
 
 Log:
   MFC:
   
   - Fix crash with "netstat -m -N foo".
   PR:             bin/124724
   
   - Sync usage() with SYNOPSIS.
 
 Modified:
   stable/7/usr.bin/netstat/   (props changed)
   stable/7/usr.bin/netstat/main.c
 
 Modified: stable/7/usr.bin/netstat/main.c
 ==============================================================================
 --- stable/7/usr.bin/netstat/main.c	Mon Jan 19 08:51:20 2009	(r187430)
 +++ stable/7/usr.bin/netstat/main.c	Mon Jan 19 10:44:16 2009	(r187431)
 @@ -503,7 +503,7 @@ main(int argc, char *argv[])
  		exit(0);
  	}
  	if (mflag) {
 -		if (memf != NULL) {
 +		if (!live) {
  			if (kread(0, NULL, 0) == 0)
  				mbpr(kvmd, nl[N_MBSTAT].n_value);
  		} else
 @@ -768,15 +768,16 @@ usage(void)
  	(void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
  "usage: netstat [-AaLnSW] [-f protocol_family | -p protocol]\n"
  "               [-M core] [-N system]",
 -"       netstat -i | -I interface [-abdhnt] [-f address_family]\n"
 +"       netstat -i | -I interface [-abdhntW] [-f address_family]\n"
  "               [-M core] [-N system]",
  "       netstat -w wait [-I interface] [-d] [-M core] [-N system]",
 -"       netstat -s [-s] [-z] [-f protocol_family | -p protocol] [-M core]",
 +"       netstat -s [-s] [-z] [-f protocol_family | -p protocol]\n"
 +"               [-M core] [-N system]",
  "       netstat -i | -I interface -s [-f protocol_family | -p protocol]\n"
  "               [-M core] [-N system]",
  "       netstat -m [-M core] [-N system]",
 -"       netstat -B [ -I interface]",
 -"       netstat -r [-AenW] [-f address_family] [-M core] [-N system]",
 +"       netstat -B [-I interface]",
 +"       netstat -r [-AanW] [-f address_family] [-M core] [-N system]",
  "       netstat -rs [-s] [-M core] [-N system]",
  "       netstat -g [-W] [-f address_family] [-M core] [-N system]",
  "       netstat -gs [-s] [-f address_family] [-M core] [-N system]");
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
