From nobody@FreeBSD.org  Thu Jul 18 16:15:33 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5533B37B401
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Jul 2002 16:15:33 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id DB80E43E58
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Jul 2002 16:15:32 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g6INFWOT050725
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Jul 2002 16:15:32 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g6INFWB8050724;
	Thu, 18 Jul 2002 16:15:32 -0700 (PDT)
Message-Id: <200207182315.g6INFWB8050724@www.freebsd.org>
Date: Thu, 18 Jul 2002 16:15:32 -0700 (PDT)
From: Bill Baumann <bbaumann@isilon.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Inconsistency between net/if.c and struct arpcom alignment in awi, lnc, pdq, and ray ethernet drivers
X-Send-Pr-Version: www-1.0

>Number:         40745
>Category:       kern
>Synopsis:       Inconsistency between net/if.c and struct arpcom alignment in awi, lnc, pdq, and ray ethernet drivers
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 18 16:20:01 PDT 2002
>Closed-Date:    Tue Sep 13 23:05:09 GMT 2005
>Last-Modified:  Tue Sep 13 23:05:09 GMT 2005
>Originator:     Bill Baumann
>Release:        5.0-CURRENT
>Organization:
Isilon
>Environment:
>Description:
In net/if.c in a couple of places, the ethernet address is needed. This
is stored in the arpcom structure.  A couple lines of code in if.c require struct arpcom be at the very begining of device softc structures.  Nearly all drivers observe this.  However, several do not.

net/if.c routines if_findindex() and if_setlladdr() gain access to the
ethernet address via the following expression:

        ((struct arpcom *)ifp->if_softc)->ac_enaddr

The above code assumes that the if_softc pointer is equivalent to an
struct arpcom pointer.  The awi, ray, lnc and pdq drivers have other
fields at the beginning of their softc structures.  Attempts to set the
ethernet address of these devices should cause corruption.
>How-To-Repeat:

>Fix:
Two possible changes -- 

Change if.c to use the following instead:
        ((struct arpcom *)ifp)->ac_enaddr

Or change the arpcom structure alignment in all four drivers.

In a discussion on freebsd-net@FreeBSD.ORG, the consensus was that
arpcom should be at the beginning of softc.  Apparently, page 77 of Stevens' TCP/IP Illustrated Volume 2 documents this.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Tue Jun 15 20:45:49 GMT 2004 
Responsible-Changed-Why:  
I'll take this *right now* 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40745 
State-Changed-From-To: open->patched 
State-Changed-By: bms 
State-Changed-When: Tue Jun 15 21:14:56 GMT 2004 
State-Changed-Why:  
fixed by rev 1.191 of if.c 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40745 
State-Changed-From-To: patched->closed 
State-Changed-By: linimon 
State-Changed-When: Tue Sep 13 22:58:59 GMT 2005 
State-Changed-Why:  
Fixed long ago in RELENG_5_BP. 

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