From nobody@FreeBSD.org  Mon Apr 15 14:23:03 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id D5EFAC0D
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Apr 2013 14:23:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id AAFA02C4
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Apr 2013 14:23:03 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r3FEN2c9034087
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Apr 2013 14:23:02 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r3FEN2Q5034086;
	Mon, 15 Apr 2013 14:23:02 GMT
	(envelope-from nobody)
Message-Id: <201304151423.r3FEN2Q5034086@red.freebsd.org>
Date: Mon, 15 Apr 2013 14:23:02 GMT
From: Luiz Otavio O Souza <loos.br@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [etherswitchcfg] [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         177872
>Category:       bin
>Synopsis:       [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-embedded
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 15 14:30:00 UTC 2013
>Closed-Date:    Tue Aug 20 10:41:46 UTC 2013
>Last-Modified:  Tue Aug 20 10:41:46 UTC 2013
>Originator:     Luiz Otavio O Souza
>Release:        -HEAD r248943
>Organization:
>Environment:
FreeBSD rb433 10.0-CURRENT FreeBSD 10.0-CURRENT #88 r248943M: Sat Apr 13 10:04:43 BRT 2013     root@devel:/data/rb/rb433/obj/mips.mips/data/rb/rb433/src/sys/RB433U  mips
>Description:
etherswitchcfg(8) crashes when you don't set vlangroup members.
>How-To-Repeat:
root@rb433:~ # etherswitchcfg vlangroup1 members
Apr 15 14:11:50 rb433 kernel: BAD_PAGE_FAULT: pid 973 tid 100050 (etherswitchcfg), uid 0: pc 0x405837e0 got a read fault (type 0x2) at 0
Apr 15 14:11:50 rb433 kernel: Trapframe Register Dump:
Apr 15 14:11:50 rb433 kernel: zero: 0   at: 0x405dd5fc  v0: 0x414058    v1: 0x414018
Apr 15 14:11:50 rb433 kernel: a0: 0     a1: 0x4031a0    a2: 0   a3: 0
Apr 15 14:11:50 rb433 kernel: t0: 0     t1: 0   t2: 0xccccccc   t3: 0xffffffffcccccccc
Apr 15 14:11:50 rb433 kernel: t4: 0x1   t5: 0   t6: 0x738       t7: 0x401de0
Apr 15 14:11:50 rb433 kernel: t8: 0x18  t9: 0x405837e0  s0: 0   s1: 0x2
Apr 15 14:11:50 rb433 kernel: s2: 0x4   s3: 0x7ffedc20  s4: 0x1 s5: 0x7fffdd1c
Apr 15 14:11:50 rb433 kernel: s6: 0x7ffedc20    s7: 0x401984    k0: 0   k1: 0
Apr 15 14:11:50 rb433 kernel: gp: 0x41c980      sp: 0x7ffedbc0  s8: 0x403504    ra: 0x400c8c
Apr 15 14:11:50 rb433 kernel: sr: 0xfc13        mullo: 0        mulhi: 0        badvaddr: 0
Apr 15 14:11:51 rb433 kernel: cause: 0x8        pc: 0x405837e0
Apr 15 14:11:51 rb433 kernel: Page table info for pc address 0x405837e0: pde = 0x827c6000, pte = 0xa0044f1a
Apr 15 14:11:51 rb433 kernel: Dumping 4 words starting at pc address 0x405837e0: 
Apr 15 14:11:51 rb433 kernel: 90880000 1100000b 90a90000 15090007
Apr 15 14:11:51 rb433 kernel: Page table info for bad address 0: pde = 0, pte = 0
Segmentation fault (core dumped)

>Fix:
Apply the attached patch which check for this condition and exit cleanly.

Patch attached with submission follows:

Index: sbin/etherswitchcfg/etherswitchcfg.c
===================================================================
--- sbin/etherswitchcfg/etherswitchcfg.c	(revision 241720)
+++ sbin/etherswitchcfg/etherswitchcfg.c	(working copy)
@@ -216,7 +216,9 @@
 	int member, untagged;
 	char *c, *d;
 	int v;
-	
+
+	if (!argv[1])
+		errx(EX_USAGE, "Members option need an argument");
 	member = untagged = 0;
 	if (strcmp(argv[1], "none") != 0) {
 		for (c=argv[1]; *c; c=d) {


>Release-Note:
>Audit-Trail:

From: Luiz Otavio O Souza <loos.br@gmail.com>
To: bug-followup@FreeBSD.org,
 loos.br@gmail.com
Cc:  
Subject: Re: bin/177872: [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members
Date: Wed, 17 Apr 2013 17:48:02 -0300

 Please, don't commit the fix in this PR, it's wrong. I'll submit the =
 correct fix later.=
State-Changed-From-To: open->suspended 
State-Changed-By: linimon 
State-Changed-When: Wed Apr 17 21:05:43 UTC 2013 
State-Changed-Why:  
at submitter's request. 

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

From: Luiz Otavio O Souza <loos.br@gmail.com>
To: Luiz Otavio O Souza <loos.br@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/177872: [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members
Date: Thu, 18 Apr 2013 10:07:23 -0300

 --Apple-Mail-4--711296950
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 Here is the correct fix. It fix all the cases where it can happen (i.e. =
 etherswitchctl vlangroupX vlan, etherswitchctl vlangroupX members, =
 etherswitchcfg port1 vlangroup, etherswitchcfg port1 media, etc.).
 
 
 On Apr 17, 2013, at 5:48 PM, Luiz Otavio O Souza wrote:
 
 > Please, don't commit the fix in this PR, it's wrong. I'll submit the =
 correct fix later.
 
 
 
 --Apple-Mail-4--711296950
 Content-Disposition: attachment;
 	filename=etherswitchcfg-check-arguments.diff
 Content-Type: application/octet-stream;
 	name="etherswitchcfg-check-arguments.diff"
 Content-Transfer-Encoding: 7bit
 
 Index: sbin/etherswitchcfg/etherswitchcfg.c
 ===================================================================
 --- sbin/etherswitchcfg/etherswitchcfg.c	(revision 249621)
 +++ sbin/etherswitchcfg/etherswitchcfg.c	(working copy)
 @@ -466,8 +466,11 @@
  		case MODE_PORT:
  		case MODE_VLANGROUP:
  			for(i=0; cmds[i].name != NULL; i++) {
 -				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0
 -					&& argc >= cmds[i].args) {
 +				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0) {
 +					if (argc < (cmds[i].args + 1)) {
 +						printf("%s needs an argument\n", cmds[i].name);
 +						break;
 +					}
  					(cmds[i].f)(&cfg, argv);
  					argc -= cmds[i].args;
  					argv += cmds[i].args;
 
 --Apple-Mail-4--711296950--
State-Changed-From-To: suspended->open 
State-Changed-By: linimon 
State-Changed-When: Thu Apr 18 14:14:53 UTC 2013 
State-Changed-Why:  
new fix submitted. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177872 
Responsible-Changed-From-To: freebsd-bugs->freebsd-embedded 
Responsible-Changed-By: adrian 
Responsible-Changed-When: Fri Apr 19 17:51:59 UTC 2013 
Responsible-Changed-Why:  
snarf. 


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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/177872: commit references a PR
Date: Mon, 22 Apr 2013 05:30:27 +0000 (UTC)

 Author: adrian
 Date: Mon Apr 22 05:30:20 2013
 New Revision: 249748
 URL: http://svnweb.freebsd.org/changeset/base/249748
 
 Log:
   etherswitchcfg(8) crashes when you don't set vlangroup members.
   Fix this to require an argument.
   
   PR:		kern/177872
   Submitted by:	Luiz Otavio O Souza <loos.br@gmail.com>
 
 Modified:
   head/sbin/etherswitchcfg/etherswitchcfg.c
 
 Modified: head/sbin/etherswitchcfg/etherswitchcfg.c
 ==============================================================================
 --- head/sbin/etherswitchcfg/etherswitchcfg.c	Mon Apr 22 05:27:13 2013	(r249747)
 +++ head/sbin/etherswitchcfg/etherswitchcfg.c	Mon Apr 22 05:30:20 2013	(r249748)
 @@ -467,8 +467,11 @@ main(int argc, char *argv[])
  		case MODE_PORT:
  		case MODE_VLANGROUP:
  			for(i=0; cmds[i].name != NULL; i++) {
 -				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0
 -					&& argc >= cmds[i].args) {
 +				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0) {
 +					if (argc < (cmds[i].args + 1)) {
 +						printf("%s needs an argument\n", cmds[i].name);
 +						break;
 +					}
  					(cmds[i].f)(&cfg, argv);
  					argc -= cmds[i].args;
  					argv += cmds[i].args;
 _______________________________________________
 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"
 
State-Changed-From-To: open->closed 
State-Changed-By: sbruno 
State-Changed-When: Tue Aug 20 10:41:18 UTC 2013 
State-Changed-Why:  
Committed at svn r249748 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177872 
>Unformatted:
