From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 12 16:09:47 2018 Received: (at 30604) by debbugs.gnu.org; 12 Mar 2018 20:09:47 +0000 Received: from localhost ([127.0.0.1]:57550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evTlT-00026l-GT for submit@debbugs.gnu.org; Mon, 12 Mar 2018 16:09:47 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:34672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evTlS-00026d-4X for 30604@debbugs.gnu.org; Mon, 12 Mar 2018 16:09:46 -0400 Received: from localhost (178.113.188.221.wireless.dyn.drei.com [178.113.188.221]) by dd26836.kasserver.com (Postfix) with ESMTPSA id F0A0A3360163; Mon, 12 Mar 2018 21:09:44 +0100 (CET) Date: Mon, 12 Mar 2018 21:09:36 +0100 From: Danny Milosavljevic To: Ludovic =?ISO-8859-1?Q?Court=E8s?= Subject: Re: [bug#30604] [PATCH v10 5/6] linux-initrd: Provide our own 'modprobe' program. Message-ID: <20180312210936.7f89a29c@scratchpost.org> In-Reply-To: <20180312123918.22645-5-ludo@gnu.org> References: <87ina1qxic.fsf@gnu.org> <20180312123918.22645-1-ludo@gnu.org> <20180312123918.22645-5-ludo@gnu.org> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/+QfwEzIV806Sp6Lwi4U+ueu"; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 30604 Cc: 30604@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --Sig_/+QfwEzIV806Sp6Lwi4U+ueu Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Ludo, On Mon, 12 Mar 2018 13:39:17 +0100 Ludovic Court=C3=A8s wrote: > + (when modprobe > + ;; Tell the kernel to invoke MODPROBE. > + (call-with-output-file "/proc/sys/kernel/modprobe" > + (lambda (port) > + (display modprobe port)))) > + > (display "loading kernel modules...\n") There's a race because Linux could just start loading modules immediately before boot-system even starts / executed far enough. That was why earlier I kept /sbin/modprobe as the name (it's the default Linux uses) and made sure that the file /sbin/modprobe is already in the initrd (as opposed to created by boot-system). The race didn't happen to me yet (and I doubt that Linux has modules fine-grained enough that that's a problem in practise) - but I would prefer it not to be possible. WDYT? > + (define aliases > + ;; The list of aliases we are asked to load. > + (filter-map (match-lambda > + (('argument . alias) alias) > + (_ #f)) > + options)) Without "-a", it's not supposed to be a list of aliases. It's supposed to = be one alias and the remainder are parameters supposed to be passed to that kernel module. (I didn't know that before). When Linux invokes /sbin/modprobe, it doesn't pass "-a" but it doesn't pass any module parameters either - it just passes one module alias. For clarity and in order that we don't have weird problems later (trying to load a module named "verbose=3D1" or something :) ), let's just accept one = alias for now. >+(define* (modprobe-program linux-module-directory #:key >+ (guile %guile-static-stripped)) [...] > + (call-with-output-file "/dev/kmsg" > + (lambda (port) > + (format port "modprobe[~a]: aliases ~s; modules ~s; args= ~s~%" > + (getpid) aliases modules (program-arguments)))) Hmm, logging is nice! But with /dev/kmsg one write(2) syscall needs to pass the entire message. What do you think about additionally calling setvbuf with 1024 ? Because: kernel/printk/printk.c: #define LOG_LINE_MAX (1024 - PREFIX_MAX) > + (when (< (length modules) (length aliases)) > + (error "alias resolution failed" aliases)) The original modprobe loads as many modules as it can and possibly sets an (always the same) error flag (and continues loading the other modules). Then modprobe's exit status is that error flag. This is moot because we shouldn't accept more than one alias - see above. > + (write-module-alias-database #$output)))) One of the devnames created statically is the one for btrfs, so not writing= or using devnames is not going to end well. If it did work without it I'd be even more on guard :) (I'd also copy the modules.builtin (from Linux). Also, what happens if we load a module which has as dependency a builtin? Will we try to load the builtin as a .ko file and fail the entire thing?) > + ;; We may need to lazy-load modules. The initrd installs a Nitpick: "kernel modules" (to clarify). --Sig_/+QfwEzIV806Sp6Lwi4U+ueu Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlqm3oAACgkQ5xo1VCww uqVxHQf/SAsE6KJ/6f6BdakZaXlVHzpjRCqHAsBqgjysduzvcrFV8UCjlL+oHwbx wSTlb3pX/UlqNI6URpKE2lAvroThzv4nrohwxTlIHCUM/Y1eYanCrT0F6v6Qwg6z fr+AF1KUyJHeLU7I0vgu+Sl2KWEJwRvQkUCPoF4UnpkQnwreJFatjBa5jkJeRPYP GRQe2vfBmOQUQetL2JjeqvOJ6FSfKV51A//8HoJFHpVgkktBD1mADHR4yiB+CWuD 9BiPndNOCm8FgF5szqQK+htdfm15kMF9yapqCVib12xZzUEji6zXPSN201q3V0uY O0fbTWR4qYQL/2nlcZU+Tm/RMPfs5g== =D7DW -----END PGP SIGNATURE----- --Sig_/+QfwEzIV806Sp6Lwi4U+ueu--