NetBSD Problem Report #48161

From Wolfgang.Stukenbrock@nagler-company.com  Thu Aug 29 11:37:33 2013
Return-Path: <Wolfgang.Stukenbrock@nagler-company.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D666271B56
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 29 Aug 2013 11:37:33 +0000 (UTC)
Message-Id: <20130829113723.0A679123B93@test-s0.nagler-company.com>
Date: Thu, 29 Aug 2013 13:37:22 +0200 (CEST)
From: Wolfgang.Stukenbrock@nagler-company.com
Reply-To: Wolfgang.Stukenbrock@nagler-company.com
To: gnats-bugs@gnats.NetBSD.org
Subject: kern-config with NFS-server and without NFS-client fails to work correctly
X-Send-Pr-Version: 3.95

>Number:         48161
>Category:       kern
>Synopsis:       kern-config with NFS-server and without NFS-client fails to work correctly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 29 11:40:00 +0000 2013
>Closed-Date:    Tue Jun 28 22:45:21 +0000 2016
>Last-Modified:  Tue Jun 28 22:45:21 +0000 2016
>Originator:     Dr. Wolfgang Stukenbrock
>Release:        NetBSD 6.1
>Organization:
Dr. Nagler & Company GmbH
>Environment:


System: NetBSD s047 6.1 NetBSD 6.1 (NSW-S047) #2: Thu Aug 29 11:42:05 CEST 2013  root@s047:/usr/src/sys/arch/amd64/compile/NSW-S047 amd64
Architecture: x86_64
Machine: amd64
>Description:
	There are two ways to build a kernel taht uses NFS:
	- user MODULAR framework to load the NFS parts
	- kompile NFS-stuff into kernel
	The first case is OK as it is: NFS-client code alway needed, because server part resues some routines.
	If someone is useing dynamic module loading, the security constrains for such a system are low to medium.
	If there is a need for a hihg-secure system, dynamic loading should be avoided and only the required
	parts should be compiled into the kernel.
	As far as good.
	It is possible to do this with NetBSD. It is possible to setup an Server that should act as NFS-server but
	may never access other systems as NFS-client. ("options NFSSERVER" set, but no "file-system NFS")
	Such a kernel will compile correctly but then fails to initialize the NFS-server part.
	The problem is the code reuse of some NFS-client-routines - e.g. nfs_init() as far as I've seen.
	For the first version of NFS in the kernel, the NFS-server-module must add NFS-client-code as dependency,
	but in for the second case thsi may not be done.
	remark: currently there is a comment for a workaround in sys/kern/kern_module.c function module_do_buildin()
		to support this case - dependency of module is missing, but the module has linked into the kernel.
	Accedently such a module is present in the kernel and would be able to do it's job, but due to the missing
	dependency the initialisation is skipped and therefore the systemcall-function for sys_nfssvc() in this case
	is not injected into the table - sys_nomodule() function is still there.
	This results e.g. in an error while starting mountd that detects no NFS-server-support in the kernel.
>How-To-Repeat:
	Setup an kernel with "options NFSSERVER" but without NFS client code. (MODULAR support may be present
	or not - this changes nothing.) The resulting kernel has the code in it, but it is not usable.
>Fix:
	The problem is that we need to distinguish between a build inside a kernel and for a build as module.
	Up to now there is no CPP definition to do this.
	The following patch adds a new preprocesser definition DO_MODULE_BUILD that will be set during every
	module compilation and the nfsserver-module setup will differenciate between module and normal kernel
	build.
	This patch solves the problem in a way that other modules may use this definition in the future too.

	Perhaps it would make sence to modify the MODULE() macro in case of normal kernel build to ignore the last
	parameter instead of changeing nfs_serv.c, because a kernel will fail to link if a "real" dependency is missing.
	It doesn't make lot of sence to check dependencies at run-time, that have already been enforced at link-time.

patch for src/sys/modules/Makefile.inc:
--- Makefile.inc        2013/08/29 10:13:38     1.1
+++ Makefile.inc        2013/08/29 10:13:57
@@ -1,7 +1,7 @@
 #      $NetBSD: Makefile.inc,v 1.6 2011/09/11 18:38:02 mbalmer Exp $

 S!=            cd ${.PARSEDIR}/..;pwd
-CPPFLAGS+=     -I${NETBSDSRCDIR}/common/include
+CPPFLAGS+=     -I${NETBSDSRCDIR}/common/include -DDO_MODULE_BUILD
 USE_FORT=      no
 WARNS?=                3


patch for src/sys/nfs/nfs_serv.c:
--- nfs_serv.c  2013/08/29 10:12:24     1.1
+++ nfs_serv.c  2013/08/29 10:12:55
@@ -86,7 +86,11 @@
 #include <nfs/nfsm_subs.h>
 #include <nfs/nfs_var.h>

+#ifdef DO_MODULE_BUILD
 MODULE(MODULE_CLASS_MISC, nfsserver, "nfs");
+#else
+MODULE(MODULE_CLASS_MISC, nfsserver, NULL);
+#endif

 /* Global vars */
 extern u_int32_t nfs_xdrneg1;

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/48161: kern-config with NFS-server and without NFS-client fails to work correctly
Date: Thu, 29 Aug 2013 13:57:05 +0200

 On Thu, Aug 29, 2013 at 11:40:00AM +0000, Wolfgang.Stukenbrock@nagler-company.com wrote:
 > 	Up to now there is no CPP definition to do this.

 Isn't _MODULE usable for that?

 Martin

From: Wolfgang Stukenbrock <wolfgang.stukenbrock@nagler-company.com>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/48161: kern-config with NFS-server and without NFS-client fails to work correctly
Date: Thu, 29 Aug 2013 17:24:29 +0200

 Hi,

 if there is a definition already set, than that one can be used, but 
 I've found nothing that is set in the makefiles.
 But I may have overlooked this.

 Where is _MODULE set?
 I've found only sys/rump/makefile.rump while haveing a quick look over 
 the sources. And that would be wrong.

 best regards

 W. Stukenbrock

 Martin Husemann wrote:

 > The following reply was made to PR kern/48161; it has been noted by GNATS.
 > 
 > From: Martin Husemann <martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: kern/48161: kern-config with NFS-server and without NFS-client fails to work correctly
 > Date: Thu, 29 Aug 2013 13:57:05 +0200
 > 
 >  On Thu, Aug 29, 2013 at 11:40:00AM +0000, Wolfgang.Stukenbrock@nagler-company.com wrote:
 >  > 	Up to now there is no CPP definition to do this.
 >  
 >  Isn't _MODULE usable for that?
 >  
 >  Martin
 >  
 > 
 > 


From: Martin Husemann <martin@duskware.de>
To: Wolfgang Stukenbrock <wolfgang.stukenbrock@nagler-company.com>
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/48161: kern-config with NFS-server and without NFS-client fails to work correctly
Date: Thu, 29 Aug 2013 17:28:29 +0200

 On Thu, Aug 29, 2013 at 05:24:29PM +0200, Wolfgang Stukenbrock wrote:
 > Where is _MODULE set?

 bsd.kmodule.mk

 Martin

From: Wolfgang Stukenbrock <wolfgang.stukenbrock@nagler-company.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/48161: kern-config with NFS-server and without NFS-client fails to work correctly
Date: Fri, 30 Aug 2013 09:29:58 +0200

 Hi again,

 OK. I've searched only in /src/sys .... - sorry

 _MODULE is usable for the purpose addresses in this PR.

 remark: Useing _MODULE avoids a potential problem with the new 
 definition that is not set in rump-build - I haven't tested that before 
 because rump is "outside of my scope" ....

 So my modification of src/sys/modules/Makefile.inc is obsolete and in 
 src/sys/nfs/nfs_serv.c _MODULE should be used instead of my new variable 
 DO_MODULE_BUILD.
 I've validated this by building the kernel and the modules (with a 
 modified module name "XXXXnfs". The string is not in the kernel but in 
 the generated module. Again rump untested, but it should be OK now.

 best regards

 W. Stukenbrock

 Martin Husemann wrote:

 > On Thu, Aug 29, 2013 at 05:24:29PM +0200, Wolfgang Stukenbrock wrote:
 > 
 >>Where is _MODULE set?
 >>
 > 
 > bsd.kmodule.mk
 > 
 > Martin
 > 


State-Changed-From-To: open->feedback
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 28 Jun 2016 06:20:02 +0000
State-Changed-Why:
Solution was provided to originator, and seems to have worked.  Asking for
confirmation.  We should close this PR unless there is still a further
problem that needs to be solved.


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/48161 (kern-config with NFS-server and without NFS-client
 fails to work correctly)
Date: Tue, 28 Jun 2016 16:34:42 +0000

 On Tue, Jun 28, 2016 at 06:20:02AM +0000, pgoyette@NetBSD.org wrote:
  > Solution was provided to originator, and seems to have worked.  Asking for
  > confirmation.  We should close this PR unless there is still a further
  > problem that needs to be solved.

 AFAICR this was fixed.

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: feedback->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 28 Jun 2016 22:45:21 +0000
State-Changed-Why:
Seems to have been fixed.


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