From owner-freebsd-current@FreeBSD.ORG Fri Mar 15 23:50:07 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B6E8FA19 for ; Fri, 15 Mar 2013 23:50:07 +0000 (UTC) (envelope-from gvdl@juniper.net) Received: from exprod7og124.obsmtp.com (exprod7og124.obsmtp.com [64.18.2.26]) by mx1.freebsd.org (Postfix) with ESMTP id 5F2596BE for ; Fri, 15 Mar 2013 23:50:07 +0000 (UTC) Received: from P-EMHUB02-HQ.jnpr.net ([66.129.224.36]) (using TLSv1) by exprod7ob124.postini.com ([64.18.6.12]) with SMTP ID DSNKUUOzqfrjKSAg6D7OfSv7Du7khjCUAeU1@postini.com; Fri, 15 Mar 2013 16:50:07 PDT Received: from P-CLDFE02-HQ.jnpr.net (172.24.192.60) by P-EMHUB02-HQ.jnpr.net (172.24.192.36) with Microsoft SMTP Server (TLS) id 8.3.213.0; Fri, 15 Mar 2013 16:46:23 -0700 Received: from o365mail.juniper.net (207.17.137.149) by o365mail.juniper.net (172.24.192.60) with Microsoft SMTP Server id 14.1.355.2; Fri, 15 Mar 2013 16:46:22 -0700 Received: from am1outboundpool.messaging.microsoft.com (213.199.154.204) by o365mail.juniper.net (207.17.137.149) with Microsoft SMTP Server (TLS) id 14.1.355.2; Fri, 15 Mar 2013 16:48:52 -0700 Received: from mail20-am1-R.bigfish.com (10.3.201.225) by AM1EHSOBE023.bigfish.com (10.3.207.145) with Microsoft SMTP Server id 14.1.225.23; Fri, 15 Mar 2013 23:46:20 +0000 Received: from mail20-am1 (localhost [127.0.0.1]) by mail20-am1-R.bigfish.com (Postfix) with ESMTP id BCE11A0187 for ; Fri, 15 Mar 2013 23:46:20 +0000 (UTC) X-Forefront-Antispam-Report: CIP:157.56.242.197; KIP:(null); UIP:(null); (null); H:BL2PRD0512HT001.namprd05.prod.outlook.com; R:internal; EFV:INT X-SpamScore: 0 X-BigFish: PS0(zzc85fhzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz17326ah8275dhz2dh2a8h668h839hd25he5bhf0ah1288h12a5h12bdh137ah139eh1441h14ddh1504h1537h162dh1631h1662h1758h1898h18e1h1946h19b5h19ceh1ad9h1b0ah1b2bh1155h) Received: from mail20-am1 (localhost.localdomain [127.0.0.1]) by mail20-am1 (MessageSwitch) id 1363391178647619_22626; Fri, 15 Mar 2013 23:46:18 +0000 (UTC) Received: from AM1EHSMHS005.bigfish.com (unknown [10.3.201.250]) by mail20-am1.bigfish.com (Postfix) with ESMTP id 92443300071 for ; Fri, 15 Mar 2013 23:46:18 +0000 (UTC) Received: from BL2PRD0512HT001.namprd05.prod.outlook.com (157.56.242.197) by AM1EHSMHS005.bigfish.com (10.3.207.105) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 15 Mar 2013 23:46:17 +0000 Received: from gvdl-mbp15.jnpr.net (66.129.224.52) by pod51010.outlook.com (10.255.233.34) with Microsoft SMTP Server (TLS) id 14.16.275.6; Fri, 15 Mar 2013 23:46:16 +0000 From: Godfrey Van der Linden Subject: kmod linking is very strange Message-ID: Date: Fri, 15 Mar 2013 16:46:13 -0700 To: MIME-Version: 1.0 (Mac OS X Mail 6.1 \(1498\)) X-Mailer: Apple Mail (2.1498) X-Originating-IP: [66.129.224.52] X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%12219$Dn%FREEBSD.ORG$RO%2$TLS%5$FQDN%onpremiseedge-1018244.customer.frontbridge.com$TlsDn%o365mail.juniper.net X-Mailman-Approved-At: Sat, 16 Mar 2013 01:18:51 +0000 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2013 23:50:07 -0000 G'day, All. First post so please be gentle ;-). Are the barracudas here? Summary: Module link-elf will link against static symbols and will fail if the = kernel is not compiled with DDB or the required MODULE_DEPEND has been = stripped of local symbols, see nm -g miibus.ko. I propose that we add a = sysctl & associated boot arg that only allows kmod loading against = externally visible symbols. Then in 11 we can enable this flag by = default. In Detail: Due to another bug in sys/conf/kmod.mk, = (http://www.freebsd.org/cgi/query-pr.cgi?pr=3D177008, contains a patch) = the miibus.ko exports no symbols. I.e. symbols are 'static'.=20 sys/kern/link-elf.c:link_elf_lookup_symbol() is the culprit. After = determining that an external symbol can't be found, it does the = following. /* If we have not found it, look at the full table (if loaded) = */ if (ef->symtab =3D=3D ef->ddbsymtab) return (ENOENT); /* Exhaustive search */ for (i =3D 0, symp =3D ef->ddbsymtab; i < ef->ddbsymcnt; i++, = symp++) { strp =3D ef->ddbstrtab + symp->st_name; if (strcmp(name, strp) =3D=3D 0) { if (symp->st_shndx !=3D SHN_UNDEF || (symp->st_value !=3D 0 && ELF_ST_TYPE(symp->st_info) =3D=3D = STT_FUNC)) { *sym =3D (c_linker_sym_t) symp; return (0); } return (ENOENT); } } This code walks the ddbsymtab looking for any symbol, including locals. Any kernel that is not built with DDB or any MODULE_DEPEND dependency = .ko that is stripped will break module loading. Godfrey van der Linden=