NetBSD Problem Report #42436

From www@NetBSD.org  Thu Dec 10 22:45:18 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id D36C363BB2F
	for <gnats-bugs@gnats.netbsd.org>; Thu, 10 Dec 2009 22:45:18 +0000 (UTC)
Message-Id: <20091210224518.A324063BAB5@www.NetBSD.org>
Date: Thu, 10 Dec 2009 22:45:18 +0000 (UTC)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@NetBSD.org
Subject: Installer dumps core running dhcp
X-Send-Pr-Version: www-1.0

>Number:         42436
>Category:       install
>Synopsis:       Installer dumps core running dhcp
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 10 22:50:00 +0000 2009
>Closed-Date:    Sat Jan 16 18:47:46 +0000 2010
>Last-Modified:  Sat Jan 16 18:47:46 +0000 2010
>Originator:     David A. Holland
>Release:        current of 20091208
>Organization:
>Environment:
>Description:
When installing a new machine here, giving "y" to "Perform DHCP autoconfiguration?" apparently fails (the stuff went by too fast to see), then on a cleared screen I get the shell's "Segmentation fault [sysinst]" message and then the "Press return for /bin/sh" prompt.

This report contains no useful information, but if someone wants to tell me what to watch for I can try again.

>How-To-Repeat:
Probably, use our (probably) broken dhcp setup here.

>Fix:
no idea.

>Release-Note:

>Audit-Trail:
From: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: install/42436
Date: Tue, 12 Jan 2010 17:44:18 +0100

 Same problem here, but with 5.0_STABLE with today's sources.

 DHCP gets a correct lease (verified in tmp/dhcp_leases); the crash
 happens right after that.

 If I manually configure the network instead, using the same values
 for host name, domain, addresses etc., I can install the machine 
 successfully.

 I have saved sysinst.core on a USB flash driver; I'll look at it
 tomorrow.

 Regards
 	-is

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: dholland@eecs.harvard.edu, is@NetBSD.org
Subject: Re: install/42436
Date: Tue, 12 Jan 2010 21:03:01 +0100

 Since the sockaddr changes struct ifreq and struct ifmediareq are no longer
 "compatible" in the strange kind of way this code assumed. (The crash happens
 dereferencing sa_in, which is NULL, in the code below after the first ioctl.)

 Proof of concept patch below (not even compile tested, but you get the idea).
 If nobody beats me to it, I'll test and commit tomorrow.

 Martin

 Index: net.c
 ===================================================================
 RCS file: /cvsroot/src/distrib/utils/sysinst/net.c,v
 retrieving revision 1.123
 diff -c -u -p -r1.123 net.c
 --- net.c	16 Oct 2009 19:01:03 -0000	1.123
 +++ net.c	12 Jan 2010 19:56:35 -0000
 @@ -303,7 +303,25 @@ get_ifconfig_info(void)
  }

  static int
 -do_ifreq(struct ifmediareq *ifmr, unsigned long cmd)
 +do_ifreq(struct ifreq *ifr, unsigned long cmd)
 +{
 +	int sock;
 +	int rval;
 +
 +	sock = socket(PF_INET, SOCK_DGRAM, 0);
 +	if (sock == -1)
 +		return -1;
 +
 +	memset(ifr, 0, sizeof *ifr);
 +	strncpy(ifr->ifr_name, net_dev, sizeof ifr->ifr_name);
 +	rval = ioctl(sock, cmd, ifr);
 +	close(sock);
 +
 +	return rval;
 +}
 +
 +static int
 +do_ifmreq(struct ifmediareq *ifmr, unsigned long cmd)
  {
  	int sock;
  	int rval;
 @@ -324,19 +342,20 @@ do_ifreq(struct ifmediareq *ifmr, unsign
  static void
  get_ifinterface_info(void)
  {
 +	struct ifreq ift;
  	struct ifmediareq ifmr;
 -	struct sockaddr_in *sa_in = (void *)&((struct ifreq *)&ifmr)->ifr_addr;
 +	struct sockaddr_in *sa_in = (void*)&ifr.ifr_addr;
  	int modew;
  	const char *media_opt;
  	const char *sep;

 -	if (do_ifreq(&ifmr, SIOCGIFADDR) == 0 && sa_in->sin_addr.s_addr != 0)
 +	if (do_ifreq(&ifr, SIOCGIFADDR) == 0 && sa_in->sin_addr.s_addr != 0)
  		strlcpy(net_ip, inet_ntoa(sa_in->sin_addr), sizeof net_ip);

 -	if (do_ifreq(&ifmr, SIOCGIFNETMASK) == 0 && sa_in->sin_addr.s_addr != 0)
 +	if (do_ifreq(&ifr, SIOCGIFNETMASK) == 0 && sa_in->sin_addr.s_addr != 0)
  		strlcpy(net_mask, inet_ntoa(sa_in->sin_addr), sizeof net_mask);

 -	if (do_ifreq(&ifmr, SIOCGIFMEDIA) == 0) {
 +	if (do_ifmreq(&ifmr, SIOCGIFMEDIA) == 0) {
  		/* Get the name of the media word */
  		modew = ifmr.ifm_current;
  		strlcpy(net_media, get_media_subtype_string(modew),

From: Martin Husemann <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42436 CVS commit: src/distrib/utils/sysinst
Date: Wed, 13 Jan 2010 07:48:58 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Jan 13 07:48:58 UTC 2010

 Modified Files:
 	src/distrib/utils/sysinst: net.c

 Log Message:
 Use the proper structs for ioctls to fetch network configuration.
 Might fix PR 42436.


 To generate a diff of this commit:
 cvs rdiff -u -r1.123 -r1.124 src/distrib/utils/sysinst/net.c

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

From: Ignatios Souvatzis <is@netbsd.org>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org, dholland@eecs.harvard.edu, is@NetBSD.org
Subject: Re: install/42436
Date: Wed, 13 Jan 2010 13:00:31 +0100

 On Tue, Jan 12, 2010 at 09:03:01PM +0100, Martin Husemann wrote:
 > Since the sockaddr changes struct ifreq and struct ifmediareq are no longer
 > "compatible" in the strange kind of way this code assumed. (The crash happens
 > dereferencing sa_in, which is NULL, in the code below after the first ioctl.)
 > 
 > Proof of concept patch below (not even compile tested, but you get the idea).
 > If nobody beats me to it, I'll test and commit tomorrow.

 compiles on -rnetbsd-5 after s,ift,ifr, and works.

 Regards,
 	-is

State-Changed-From-To: open->pending-pullups
State-Changed-By: martin@NetBSD.org
State-Changed-When: Wed, 13 Jan 2010 13:44:40 +0000
State-Changed-Why:
fixed in current, waiting for [pullup-5 #1242]


From: Manuel Bouyer <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42436 CVS commit: [netbsd-5] src/distrib/utils/sysinst
Date: Sat, 16 Jan 2010 17:43:34 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sat Jan 16 17:43:34 UTC 2010

 Modified Files:
 	src/distrib/utils/sysinst [netbsd-5]: net.c

 Log Message:
 Pull up following revision(s) (requested by martin in ticket #1242):
 	distrib/utils/sysinst/net.c: revision 1.124
 Use the proper structs for ioctls to fetch network configuration.
 Might fix PR 42436.


 To generate a diff of this commit:
 cvs rdiff -u -r1.117.8.2 -r1.117.8.3 src/distrib/utils/sysinst/net.c

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

Responsible-Changed-From-To: install-manager->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Sat, 16 Jan 2010 18:47:46 +0000
Responsible-Changed-Why:
I handled it


State-Changed-From-To: pending-pullups->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sat, 16 Jan 2010 18:47:46 +0000
State-Changed-Why:
pullups complete


>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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.