Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp814945ybh; Wed, 11 Mar 2020 11:22:18 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsoBLJt+qPqHT8CdA0+1oVpT9LKGUwN56QkowDQknnsh2V3/8Gmld2AJHCfcwbjO7pULefw X-Received: by 2002:a9d:247:: with SMTP id 65mr3411527otb.364.1583950938025; Wed, 11 Mar 2020 11:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583950938; cv=none; d=google.com; s=arc-20160816; b=dek+4JnEl3aPbUR8rDY/bzP0FDjHBgG2QKr5kSdHKT8/aGLQkQrtRDBUqAXjsd/3Eo YjaNVkOhEGirO3r3mCTHJWQSXFhLWBPj++BzruOQiOzGGQgbkOQz6PSD1M69p7TTRgDG 9YZrDtaZGyUK+Yk9nVkz5dWEbzqT3jFQY6dqy3hyU7LBJDL5obBFfxnvQsFuPfBebKJP TSO8R6ZkY5MZYfUbZOKQxO6gf0gpfXjT70cwEb3vwFkKRY9eAW/Ymu7Wqkd3MVU1BBq8 +PVp8ZihZn0HcMJNh6nXNzraik8qH6YTdqfDgvOUCVbgKP78v0MPus5/2CaNrZKQpBKS wXhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=V795/Felc5D1c8yaRU9dnxNhGpeCzFHOz0fM2+9HHLw=; b=cJP/f/kdcRpndWZa4MN/aVcS+LSWjFpNBfK2n8Sf7Y0JhPDDuWdSJmjnaWxWz3X8hK 0B8s4w+twDq5dbSXbuxlgdkhA0WVr9ILPYcuG/dTzJLrguqgE1ExJxGWLzWBBEWGjc4N vUIKGFQXs+bvrSh2z62K8Krm8qttZS48C6bWcLT65spA5chZUcaJJtEf/tG4Nv7UC/1b hzy7mjSc4JaprAsMLhgg6WZWM2T/FlGo6NF/XscM58rqAHeuc2pfmcqGJXE+Nr0uJ+4U T2nWuHyGoeLEcgkRdSSHOJ8zoVJ7AesfDiyWBj5JFOBcU1VdkVT58g7lIquryHcAxljK bI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pNyDx7AI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si1425976oie.164.2020.03.11.11.22.05; Wed, 11 Mar 2020 11:22:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pNyDx7AI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730801AbgCKSVd (ORCPT + 99 others); Wed, 11 Mar 2020 14:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:34566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730677AbgCKSVd (ORCPT ); Wed, 11 Mar 2020 14:21:33 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 756F52072F; Wed, 11 Mar 2020 18:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583950892; bh=EMTCcOIumdt7jEeudStF/nDyAUTZ9+64dBQJKN/EsCs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pNyDx7AIzb6Z8gnHZtLGHSTGfrLVHI7ISZtKRl/W/4N8aHSNsMMXhVQI9aIVRZY65 UcSfexfQDroVVkYxjUgMgIGK1V7Z3DbBBpIc3HAI53WDUznw14tsPtXfl0UPquNv7+ sXwWK+yCO5HduWIprk+5ucTWMRPSxpApl4VnAO/0= Date: Wed, 11 Mar 2020 11:21:30 -0700 From: Eric Biggers To: Luis Chamberlain Cc: NeilBrown , Josh Triplett , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org, Alexei Starovoitov , Andrew Morton , Greg Kroah-Hartman , Jeff Vander Stoep , Jessica Yu , Kees Cook Subject: Re: [PATCH] kmod: make request_module() return an error when autoloading is disabled Message-ID: <20200311182130.GA41227@sol.localdomain> References: <20200310223731.126894-1-ebiggers@kernel.org> <20200311043221.GK11244@42.do-not-panic.com> <20200311052620.GD46757@gmail.com> <20200311063130.GL11244@42.do-not-panic.com> <20200311173545.GA20006@gmail.com> <20200311180002.GN11244@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311180002.GN11244@42.do-not-panic.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 06:00:02PM +0000, Luis Chamberlain wrote: > On Wed, Mar 11, 2020 at 10:35:45AM -0700, Eric Biggers wrote: > > On Wed, Mar 11, 2020 at 06:31:30AM +0000, Luis Chamberlain wrote: > > > On Tue, Mar 10, 2020 at 10:26:20PM -0700, Eric Biggers wrote: > > > > On Wed, Mar 11, 2020 at 04:32:21AM +0000, Luis Chamberlain wrote: > > > > > On Tue, Mar 10, 2020 at 03:37:31PM -0700, Eric Biggers wrote: > > > > > > From: Eric Biggers > > > > > > > > > > > > It's long been possible to disable kernel module autoloading completely > > > > > > by setting /proc/sys/kernel/modprobe to the empty string. This can be > > > > > > preferable > > > > > > > > > > preferable but ... not documented. Or was this documented or recommended > > > > > somewhere? > > > > > > > > > > > to setting it to a nonexistent file since it avoids the > > > > > > overhead of an attempted execve(), avoids potential deadlocks, and > > > > > > avoids the call to security_kernel_module_request() and thus on > > > > > > SELinux-based systems eliminates the need to write SELinux rules to > > > > > > dontaudit module_request. > > > > > > > > Not that I know of, though I didn't look too hard. proc(5) mentions > > > > /proc/sys/kernel/modprobe but doesn't mention the empty string case. > > > > > > > > In any case, it's been supported for a long time, and it's useful for the > > > > reasons I mentioned. > > > > > > Sure. I think then its important to document it as such then, or perhaps > > > make a kconfig option which sets this to empty and document it on the > > > kconfig entry. > > > > I'll send a man-pages patch to document it in proc(5). > > > > Most users, including the one I have in mind, should just be able to run > > 'echo > /proc/sys/kernel/modprobe' early in the boot process. So I don't think > > the need for a kconfig option to control the default value has been clearly > > demonstrated yet. You're certainly welcome to send a patch for it if you > > believe it would be useful, though. > > When doing a rewrite of some of this code I did wonder who would use > this and clear it out. A kconfig entry would remove any doubt over its > use and would allow one to skip the userspace / early init requirement > to empty it out, therefore actually being safer because you are not > racing against modules being loaded. > > Is avoiding the race more suitable for your needs than echo'ing early on boot? > Maybe. It would avoid the chance of races, but I haven't seen any yet. Also, our userspace has to support old kernels, so we still need the 'echo > /proc/sys/kernel/modprobe' anyway. If that turns out to be good enough, then it makes things easier for everyone. If setting the default at build time turns out to be needed, then sure in that case I'll send a patch that adds a kconfig option to do that. But I'm first trying to use the existing kernel functionality. Also, a kconfig option isn't really a substitute for documenting this existing sysctl. We still need to document it properly in proc(5) and Documentation/admin-guide/sysctl/kernel.rst. - Eric