From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CAFAC43217 for ; Wed, 9 Mar 2022 20:27:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D7EF8D0002; Wed, 9 Mar 2022 15:27:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 985F28D0001; Wed, 9 Mar 2022 15:27:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 826F48D0002; Wed, 9 Mar 2022 15:27:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 755D38D0001 for ; Wed, 9 Mar 2022 15:27:19 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 141F0181CE292 for ; Wed, 9 Mar 2022 20:27:19 +0000 (UTC) X-FDA: 79225982598.17.E7BC68B Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by imf25.hostedemail.com (Postfix) with ESMTP id 741C8A0002 for ; Wed, 9 Mar 2022 20:27:18 +0000 (UTC) Received: from in01.mta.xmission.com ([166.70.13.51]:56056) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nS2tw-009Dt1-10; Wed, 09 Mar 2022 13:27:16 -0700 Received: from ip68-227-174-4.om.om.cox.net ([68.227.174.4]:34650 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nS2tu-0017uJ-LN; Wed, 09 Mar 2022 13:27:15 -0700 From: "Eric W. Biederman" To: Kees Cook Cc: Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Viro , Denys Vlasenko , Vlastimil Babka , "Liam R . Howlett" , Jann Horn , linux-mm@kvack.org References: <20220131153740.2396974-1-willy@infradead.org> <871r0nriy4.fsf@email.froward.int.ebiederm.org> <877dafq3bw.fsf@email.froward.int.ebiederm.org> <87bkzroica.fsf_-_@email.froward.int.ebiederm.org> <87h788fdaw.fsf_-_@email.froward.int.ebiederm.org> <202203081342.1924AD9@keescook> <877d93dr8p.fsf@email.froward.int.ebiederm.org> <202203090830.7E971BD6C@keescook> Date: Wed, 09 Mar 2022 14:27:07 -0600 In-Reply-To: <202203090830.7E971BD6C@keescook> (Kees Cook's message of "Wed, 9 Mar 2022 08:32:14 -0800") Message-ID: <8735jqdg84.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1nS2tu-0017uJ-LN;;;mid=<8735jqdg84.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.174.4;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18ML1Zu0i2Zn9zxbmCt2bn3iMf4MsVJYIQ= X-SA-Exim-Connect-IP: 68.227.174.4 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [GIT PULL] Fix fill_files_note X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 741C8A0002 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=xmission.com; spf=pass (imf25.hostedemail.com: domain of ebiederm@xmission.com designates 166.70.13.231 as permitted sender) smtp.mailfrom=ebiederm@xmission.com X-Stat-Signature: 6xbaetxg6r436ds8etdyoi3t9iwwwisw X-HE-Tag: 1646857638-749060 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Kees Cook writes: > On Wed, Mar 09, 2022 at 10:29:10AM -0600, Eric W. Biederman wrote: >> Kees Cook writes: >> >> > On Tue, Mar 08, 2022 at 01:35:03PM -0600, Eric W. Biederman wrote: >> >> >> >> Kees, >> >> >> >> Please pull the coredump-vma-snapshot-fix branch from the git tree: >> >> >> >> git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git coredump-vma-snapshot-fix >> >> >> >> HEAD: 390031c942116d4733310f0684beb8db19885fe6 coredump: Use the vma snapshot in fill_files_note >> >> >> >> Matthew Wilcox has reported that a missing mmap_lock in file_files_note, >> >> which could cause trouble. >> >> >> >> Refactor the code and clean it up so that the vma snapshot makes >> >> it to fill_files_note, and then use the vma snapshot in fill_files_note. >> >> >> >> Eric W. Biederman (5): >> >> coredump: Move definition of struct coredump_params into coredump.h >> >> coredump: Snapshot the vmas in do_coredump >> >> coredump: Remove the WARN_ON in dump_vma_snapshot >> >> coredump/elf: Pass coredump_params into fill_note_info >> >> coredump: Use the vma snapshot in fill_files_note >> >> >> >> fs/binfmt_elf.c | 66 ++++++++++++++++++++++-------------------------- >> >> fs/binfmt_elf_fdpic.c | 18 +++++-------- >> >> fs/binfmt_flat.c | 1 + >> >> fs/coredump.c | 59 ++++++++++++++++++++++++++++--------------- >> >> include/linux/binfmts.h | 13 +--------- >> >> include/linux/coredump.h | 20 ++++++++++++--- >> >> 6 files changed, 93 insertions(+), 84 deletions(-) >> >> >> >> --- >> >> >> >> Kees I realized I needed to rebase this on Jann Horn's commit >> >> 84158b7f6a06 ("coredump: Also dump first pages of non-executable ELF >> >> libraries"). Unfortunately before I got that done I got distracted and >> >> these changes have been sitting in limbo for most of the development >> >> cycle. Since you are running a tree that is including changes like this >> >> including Jann's can you please pull these changes into your tree. >> > >> > Sure! Can you make a signed tag for this pull? >> >> Not yet. >> >> Hopefully I will get the time to set that up soon, but I am not at all >> setup to do signed tags at this point. > > Okay, cool. Since I'd already review these before, I've pulled and it > should be in -next now. > >> [...] >> Thanks. That looks like a good place to start. > > I will try to clean up that work-flow and stuff it into my kernel-tools > repo. It turns out I missed a crazy corner case of binfmt_flat, when coredumps are disabled. This fixes a compile error that was reported. git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git coredump-vma-snapshot-fix-for-v5.18 HEAD: f833116ad2c3eabf9c739946170e07825cca67ed coredump: Don't compile flat_core_dump when coredumps are disabled Can you include this as well. Thank you, Eric This is the entire patch. From: "Eric W. Biederman" Date: Wed, 9 Mar 2022 10:37:07 -0600 Subject: [PATCH] coredump: Don't compile flat_core_dump when coredumps are disabled Recently the kernel test robot reported: > In file included from include/linux/kernel.h:29, > from fs/binfmt_flat.c:21: > fs/binfmt_flat.c: In function 'flat_core_dump': > >> fs/binfmt_flat.c:121:50: error: invalid use of undefined type 'struct coredump_params' > 121 | current->comm, current->pid, cprm->siginfo->si_signo); > | ^~ > include/linux/printk.h:418:33: note: in definition of macro 'printk_index_wrap' > 418 | _p_func(_fmt, ##__VA_ARGS__); \ > | ^~~~~~~~~~~ > include/linux/printk.h:499:9: note: in expansion of macro 'printk' > 499 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) > | ^~~~~~ > fs/binfmt_flat.c:120:9: note: in expansion of macro 'pr_warn' > 120 | pr_warn("Process %s:%d received signr %d and should have core dumped\n", > | ^~~~~~~ > At top level: > fs/binfmt_flat.c:118:12: warning: 'flat_core_dump' defined but not used [-Wunused-function] > 118 | static int flat_core_dump(struct coredump_params *cprm) > | ^~~~~~~~~~~~~~ The little dinky do nothing function flat_core_dump has always been compiled unconditionally. With my change to move coredump_params into coredump.h coredump_params reasonably becomes unavailable when coredump support is not compiled in. Fix this old issue by simply not compiling flat_core_dump when coredump support is not supported. Fixes: a99a3e2efaf1 ("coredump: Move definition of struct coredump_params into coredump.h") Reported-by: kernel test robot Signed-off-by: "Eric W. Biederman" --- fs/binfmt_flat.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 208cdce16de1..626898150011 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -98,7 +98,9 @@ static int load_flat_shared_library(int id, struct lib_info *p); #endif static int load_flat_binary(struct linux_binprm *); +#ifdef CONFIG_COREDUMP static int flat_core_dump(struct coredump_params *cprm); +#endif static struct linux_binfmt flat_format = { .module = THIS_MODULE, @@ -115,12 +117,14 @@ static struct linux_binfmt flat_format = { * Currently only a stub-function. */ +#ifdef CONFIG_COREDUMP static int flat_core_dump(struct coredump_params *cprm) { pr_warn("Process %s:%d received signr %d and should have core dumped\n", current->comm, current->pid, cprm->siginfo->si_signo); return 1; } +#endif /****************************************************************************/ /* -- 2.29.2