NetBSD Problem Report #51598
From paul@whooppee.com Thu Nov 3 22:12:56 2016
Return-Path: <paul@whooppee.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 00B6C7A169
for <gnats-bugs@gnats.NetBSD.org>; Thu, 3 Nov 2016 22:12:55 +0000 (UTC)
Message-Id: <20161103221252.8F76316E60@speedy.whooppee.com>
Date: Fri, 4 Nov 2016 06:12:52 +0800 (PHT)
From: paul@whooppee.com
Reply-To: paul@whooppee.com
To: gnats-bugs@NetBSD.org
Subject: compat code gets pulled into non-compat kernels
X-Send-Pr-Version: 3.95
>Number: 51598
>Category: kern
>Synopsis: (networking) compat code is pulled into non-compat kernels
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pgoyette
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Nov 03 22:15:00 +0000 2016
>Closed-Date: Sat Nov 05 23:37:20 +0000 2016
>Last-Modified: Sat Nov 05 23:37:20 +0000 2016
>Originator: Paul Goyette
>Release: NetBSD 7.99.36
>Organization:
+------------------+--------------------------+------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+
>Environment:
System: NetBSD speedy.whooppee.com 7.99.36 NetBSD 7.99.36 (SPEEDY 2016-09-09 11:36:24) #0: Fri Sep 9 20:18:34 PHT 2016 paul@speedy.whooppee.com:/build/netbsd-local/obj/amd64/sys/arch/amd64/compile/SPEEDY amd64
Architecture: x86_64
Machine: amd64
>Description:
The functions compat_cvtcmd() and compat_ifioctl() are defined in source
file sys/compat/common/if_43.c and included in the libcompat library. In
sys/net/if.c there are calls to each of these routines which do not depend
on any version-specific COMPAT_xx option. Indeed, these calls are
conditional only on OIFREQ, which appears to be unconditionally #define in
sys/sys/socket.h.
As a result, the compat code gets pulled into all kernels by the linker (so
it can resolve the symbol references). Thus it is not possible to include
if_43.c in the spearately-loaded compat module (which is where it most
likely belongs), since loading such a module would result in redefinition
of the routines.
>How-To-Repeat:
Move if_43.c out of sys/compat/common/Makefile and into Makefile/sysio, and
build a modular kernel, removing all occurrences of COMPAT_[0-9][0-9] from
the configuration file. Boot, and try to 'modload compat'
>Fix:
Ideally, these two functions would be invoked by indirect pointers rather
than direct function call. Then, the default kernel builds could provide
no-op stubs in if.c, and the compat_modcmd(MODULE_CMD_INIT, ...) code
could replace the pointers to reference the if_43 replacements. (Of course,
the MODULE_CMD_FINI code should restore the original values when the module
is unloaded.)
>Release-Note:
>Audit-Trail:
From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51598 CVS commit: src/sys/compat/common
Date: Thu, 3 Nov 2016 22:23:04 +0000
Module Name: src
Committed By: pgoyette
Date: Thu Nov 3 22:23:04 UTC 2016
Modified Files:
src/sys/compat/common: Makefile Makefile.sysio
Log Message:
Move if_43.c out of Makefile.sysio and into the main Makefile.
The former location gets included in both libcompat and the compat
module, leading to redefined symbols when the module is loaded. By
moving it to the main Makefile, it gets included only in libcompat.
XXX This still isn't an ideal solution, but it will suffice until
XXX PR kern/51598 is addressed.
To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/compat/common/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/compat/common/Makefile.sysio
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Responsible-Changed-From-To: kern-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Sat, 05 Nov 2016 02:41:12 +0000
Responsible-Changed-Why:
I'm working on it.
From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51598 CVS commit: src/sys
Date: Sat, 5 Nov 2016 23:30:22 +0000
Module Name: src
Committed By: pgoyette
Date: Sat Nov 5 23:30:22 UTC 2016
Modified Files:
src/sys/compat/common: Makefile Makefile.sysio compat_mod.c if_43.c
src/sys/net: if.c
Added Files:
src/sys/compat/common: if_43.h
Log Message:
Move if_43.c back into the shared Makefile.sysio where it really
belongs.
Update the code to invoke the two routines compat_cvtcmd() and
compat_ifioctl() through indirect pointers. Initialize those
pointers in sys/net/if.c and update them in the compat module's
initialization code.
Addresses the issue pointed out in PR kern/51598
To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/compat/common/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.23 -r1.24 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.12 -r1.13 src/sys/compat/common/if_43.c
cvs rdiff -u -r0 -r1.1 src/sys/compat/common/if_43.h
cvs rdiff -u -r1.360 -r1.361 src/sys/net/if.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: pgoyette@NetBSD.org
State-Changed-When: Sat, 05 Nov 2016 23:37:20 +0000
State-Changed-Why:
I fixed the problem.
>Unformatted:
(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-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.