Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755242AbcLUFXz (ORCPT ); Wed, 21 Dec 2016 00:23:55 -0500 Received: from ozlabs.org ([103.22.144.67]:43007 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751638AbcLUFXv (ORCPT ); Wed, 21 Dec 2016 00:23:51 -0500 From: Rusty Russell To: "Luis R. Rodriguez" Cc: Filipe Manana , "Paul E. McKenney" , "linux-doc\@vger.kernel.org" , rgoldwyn@suse.com, hare , Jonathan Corbet , Linus Torvalds , linux-kselftest@vger.kernel.org, Andrew Morton , Dan Williams , Aaron Tomlin , rwright@hpe.com, Heinrich Schuchardt , Michal Marek , martin.wilck@suse.com, Jeff Mahoney , Ingo Molnar , Petr Mladek , Dmitry Torokhov , Guenter Roeck , "Eric W. Biederman" , shuah@kernel.org, DSterba@suse.com, Kees Cook , Josh Poimboeuf , Arnaldo Carvalho de Melo , Miroslav Benes , NeilBrown , "linux-kernel\@vger.kernel.o rg" , David Miller , Jessica Yu , Subash Abhinov Kasiviswanathan , Julia Lawall Subject: Re: [RFC 10/10] kmod: add a sanity check on module loading In-Reply-To: References: <20161208184801.1689-1-mcgrof@kernel.org> <20161208194930.2816-1-mcgrof@kernel.org> <87k2b2kpdt.fsf@rustcorp.com.au> <20161216083123.GF13946@wotan.suse.de> <87zijvjjm1.fsf@rustcorp.com.au> <87fuljjua3.fsf@rustcorp.com.au> User-Agent: Notmuch/0.22.1 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Wed, 21 Dec 2016 12:51:21 +1030 Message-ID: <87a8bqja3i.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1035 Lines: 30 "Luis R. Rodriguez" writes: > OK -- if userspace messes up again it may be a bit hard to prove > unless we have a validation debug thing in place, would such a thing > in debug form be reasonable ? That makes perfect sense. Untested hack: diff --git a/fs/filesystems.c b/fs/filesystems.c index c5618db110be..e5c90e80c7d3 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c @@ -275,9 +275,10 @@ struct file_system_type *get_fs_type(const char *name) int len = dot ? dot - name : strlen(name); fs = __get_fs_type(name, len); - if (!fs && (request_module("fs-%.*s", len, name) == 0)) + if (!fs && (request_module("fs-%.*s", len, name) == 0)) { fs = __get_fs_type(name, len); - + WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name); + } if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) { put_filesystem(fs); fs = NULL; Maybe a similar hack for try_then_request_module(), but many places seem to open-code request_module() so it's not as trivial... Cheers, Rusty.