NetBSD Problem Report #39424

From njoly@lanfeust.sis.pasteur.fr  Thu Aug 28 12:22:50 2008
Return-Path: <njoly@lanfeust.sis.pasteur.fr>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 99EB163B8A9
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 28 Aug 2008 12:22:50 +0000 (UTC)
Message-Id: <20080828122248.A8C7A6B489@lanfeust.sis.pasteur.fr>
Date: Thu, 28 Aug 2008 14:22:48 +0200 (CEST)
From: njoly@pasteur.fr
Reply-To: njoly@pasteur.fr
To: gnats-bugs@gnats.NetBSD.org
Subject: SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32
X-Send-Pr-Version: 3.95

>Number:         39424
>Category:       kern
>Synopsis:       SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 28 12:25:00 +0000 2008
>Closed-Date:    Thu Dec 10 15:09:41 +0000 2009
>Last-Modified:  Thu Dec 10 15:09:41 +0000 2009
>Originator:     Nicolas Joly
>Release:        NetBSD 4.99.72
>Organization:
Biological Software and Databanks.
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 4.99.72 NetBSD 4.99.72 (LANFEUST) #13: Thu Aug 28 14:05:46 CEST 2008 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
I discovered that SIOCGIFFLAGS ioctl(2) from NetBSD 4.0, does not work on
-current under compat netbsd32., using the following testcase :

njoly@lanfeust [netbsd/ioctl]> cat siocgifflags.c

#include <arpa/inet.h>
#include <net/if.h>

#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
  int res, fd;
  struct ifreq ifr;

  fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (fd == -1)
    err(1, "socket failed");

  sprintf(ifr.ifr_name, "lo0");
  res = ioctl(fd, SIOCGIFFLAGS, &ifr);
  if (res == -1)
    err(1, "ioctl failed");

  printf("%s: 0x%x\n", ifr.ifr_name, (ifr.ifr_flags & 0xffff));

  res = close(fd);
  if (res == -1)
    err(1, "close failed");

  return 0; }

When compiled on a 4.0 machine, it fails to give a correct value.

njoly@lanfeust [netbsd/ioctl]> file siocgifflags 
siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 4.0, dynamically linked (uses shared libs), not stripped
njoly@lanfeust [netbsd/ioctl]> ./siocgifflags 
lo0: 0xdb54
njoly@lanfeust [netbsd/ioctl]> ifconfig lo0 | grep flags
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648

In the mean time, a -current binary works ...

njoly@lanfeust [~]> file siocgifflags 
siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for NetBSD 4.99.64, dynamically linked (uses shared libs), not stripped
njoly@lanfeust [~]> ./siocgifflags 
lo0: 0x8049
njoly@lanfeust [~]> ifconfig lo0 | grep flags
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648

>How-To-Repeat:
Run the provided testcase, compiled on a 4.0 machine, under compat netbsd32.
>Fix:
n/a

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: dsl@NetBSD.org
State-Changed-When: Fri, 04 Dec 2009 20:51:54 +0000
State-Changed-Why:
Fixed before netbsd 5, not really ever going to be fixed in netbsd 4


From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, netbsd-bugs@netbsd.org,
    gnats-admin@netbsd.org, dsl@NetBSD.org, njoly@pasteur.fr
Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32)
Date: Sat, 05 Dec 2009 08:23:04 +1100

    Synopsis: SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32

    State-Changed-From-To: open->closed
    State-Changed-By: dsl@NetBSD.org
    State-Changed-When: Fri, 04 Dec 2009 20:51:54 +0000
    State-Changed-Why:
    Fixed before netbsd 5, not really ever going to be fixed in netbsd 4


 that's ok... this wasn't a bug in netbsd-4.  :-)


 .mrg.

State-Changed-From-To: closed->open
State-Changed-By: dsl@NetBSD.org
State-Changed-When: Fri, 04 Dec 2009 21:25:39 +0000
State-Changed-Why:
I misunderstood to bug :-)


From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, netbsd-bugs@netbsd.org,
    gnats-admin@netbsd.org, dsl@NetBSD.org, njoly@pasteur.fr,
    christos@netbsd.org
Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32)
Date: Sat, 05 Dec 2009 08:41:42 +1100

 my guess is that this commit is the problem:

 	http://mail-index.netbsd.org/source-changes/2007/05/29/msg186117.html

 it changed the size of struct ifreq, pushing the ifru_flags flags further
 into memory by sizeof(struct sockaddr_storage).

 christos?  the comment says it should be backwrds compatible.


 .mrg.

From: Nicolas Joly <njoly@pasteur.fr>
To: matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
	netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, dsl@NetBSD.org,
	njoly@pasteur.fr, christos@netbsd.org
Subject: Re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32)
Date: Sat, 5 Dec 2009 10:52:47 +0100

 On Sat, Dec 05, 2009 at 08:41:42AM +1100, matthew green wrote:
 > 
 > my guess is that this commit is the problem:
 > 
 > 	http://mail-index.netbsd.org/source-changes/2007/05/29/msg186117.html
 > 
 > it changed the size of struct ifreq, pushing the ifru_flags flags further
 > into memory by sizeof(struct sockaddr_storage).
 > 
 > christos?  the comment says it should be backwrds compatible.

 I do see the problem with compat linux32 which rely on compat netbsd32
 for such ioctls (OSIOCGIFFLAGS).

 njoly@nicodeme [linux/ioctls]> ifconfig -au |& grep flags
 wm0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33648

 njoly@nicodeme [linux/ioctls]> file siocgifflags
 siocgifflags: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not stripped
 njoly@nicodeme [linux/ioctls]> ./siocgifflags 
 wm0 0x8843
 lo0 0x8049

 njoly@nicodeme [linux/ioctls]> file siocgifflags
 siocgifflags: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not stripped
 njoly@nicodeme [linux/ioctls]> ./siocgifflags 
 wm0 0x3000
 lo0 0x3000

 -- 
 Nicolas Joly

 Biological Software and Databanks.
 Institut Pasteur, Paris.

From: christos@zoulas.com (Christos Zoulas)
To: matthew green <mrg@eterna.com.au>, gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, netbsd-bugs@netbsd.org, 
	gnats-admin@netbsd.org, dsl@NetBSD.org, njoly@pasteur.fr
Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32)
Date: Sat, 5 Dec 2009 12:07:00 -0500

 On Dec 5,  8:41am, mrg@eterna.com.au (matthew green) wrote:
 -- Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work unde

 | 
 | my guess is that this commit is the problem:
 | 
 | 	http://mail-index.netbsd.org/source-changes/2007/05/29/msg186117.html
 | 
 | it changed the size of struct ifreq, pushing the ifru_flags flags further
 | into memory by sizeof(struct sockaddr_storage).
 | 
 | christos?  the comment says it should be backwrds compatible.

 Yes, the code is supposed to be backwards compatible by checking the type/size
 of the ioctl and emulating it.

 christos

From: matthew green <mrg@eterna.com.au>
To: christos@zoulas.com (Christos Zoulas)
Cc: kern-bug-people@netbsd.org, netbsd-bugs@netbsd.org,
    gnats-admin@netbsd.org, dsl@NetBSD.org, njoly@pasteur.fr,
    gnats-bugs@NetBSD.org
Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work under compat netbsd32)
Date: Sun, 06 Dec 2009 07:15:19 +1100

    On Dec 5,  8:41am, mrg@eterna.com.au (matthew green) wrote:
    -- Subject: re: kern/39424 (SIOCGIFFLAGS ioctl(2) from 4.0 does not work unde

    | 
    | my guess is that this commit is the problem:
    | 
    | 	http://mail-index.netbsd.org/source-changes/2007/05/29/msg186117.html
    | 
    | it changed the size of struct ifreq, pushing the ifru_flags flags further
    | into memory by sizeof(struct sockaddr_storage).
    | 
    | christos?  the comment says it should be backwrds compatible.

    Yes, the code is supposed to be backwards compatible by checking the type/size
    of the ioctl and emulating it.

 i don't see any references to "oifreq" in sys/compat/netbsd32.

 can you have a look at this please?


 .mrg.

From: Nicolas Joly <njoly@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39424 CVS commit: src/sys/compat/netbsd32
Date: Thu, 10 Dec 2009 14:58:28 +0000

 Module Name:	src
 Committed By:	njoly
 Date:		Thu Dec 10 14:58:28 UTC 2009

 Modified Files:
 	src/sys/compat/netbsd32: netbsd32_ioctl.c

 Log Message:
 Make netbsd32_from_{ifreq,oifreq}() copy the whole structure, not only
 the interface name. Finally fix my own PR/39424.

 ok by christos.


 To generate a diff of this commit:
 cvs rdiff -u -r1.43 -r1.44 src/sys/compat/netbsd32/netbsd32_ioctl.c

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

State-Changed-From-To: open->closed
State-Changed-By: njoly@NetBSD.org
State-Changed-When: Thu, 10 Dec 2009 15:09:41 +0000
State-Changed-Why:
Fixed, with christos help.


>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.