From patchwork Thu Dec 22 18:12:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13080207 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 AF267C4332F for ; Thu, 22 Dec 2022 18:13:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBD07900002; Thu, 22 Dec 2022 13:13:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E6DC5940007; Thu, 22 Dec 2022 13:13:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D354B900004; Thu, 22 Dec 2022 13:13:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C6D69900002 for ; Thu, 22 Dec 2022 13:13:02 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7D0FA160A42 for ; Thu, 22 Dec 2022 18:13:02 +0000 (UTC) X-FDA: 80270738604.19.04A6A21 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 015624000B for ; Thu, 22 Dec 2022 18:13:00 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671732781; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rLTMox62yK021JaPGYOnWD8ApyDRY7ao1ae8UjcZizA=; b=aMQcSdLNGhH7IZOh9Y6I1Q7jeBLUcTjcVVqI4xr2gjgl1qlWdSgBSQjD06Q0jaYTvH3lZS 1iu/VwsRwySGCGW8jHpBDC3C++c0ZS/9Ce/yAUnzDSO+q3H34gpRQtBFtTpM6QN2qXliGo aeQj3OdHV3XQLAW4CZ8hPbzLx3uWams= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf04.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671732781; a=rsa-sha256; cv=none; b=KdcxxG+Ojsuv7/Cew1/XXUm4dS4c5zaxbL2ImbkkgUCiLlhjSBatSZ2faUnWQnn/mhvfeV tcOKSkPOXJAHp4o6dOEQpHDUurLIfx+SLbNj022jyoZYeyWu0KDVJKqEsIO7SXjiVnp6wJ Jtr2RQP6wznl7WgHXlc4CYNpTMubJhk= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1657A61D0C; Thu, 22 Dec 2022 18:13:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10DECC433EF; Thu, 22 Dec 2022 18:12:57 +0000 (UTC) From: Catalin Marinas To: Will Deacon , Seth Jenkins Cc: Eric Biederman , Kees Cook , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: [PATCH 2/3] elfcore: Add a cprm parameter to elf_core_extra_{phdrs,data_size} Date: Thu, 22 Dec 2022 18:12:50 +0000 Message-Id: <20221222181251.1345752-3-catalin.marinas@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221222181251.1345752-1-catalin.marinas@arm.com> References: <20221222181251.1345752-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 015624000B X-Stat-Signature: p5p3xhacz4kuuwiudtg3uszffext4oz4 X-Rspam-User: X-HE-Tag: 1671732780-975268 X-HE-Meta: U2FsdGVkX19Q22of0T1qhICO1sDO7xmVFqTtXYRTx1dnIwxYOaIFH8m6TYocah1WjZpL+rGn7GSPXVvEeADZ5bJUfzY+Q1NAMeOULi6GE0DmVXQ5rZJnBrO+NVOudafNgNODcLZ+zmQ5xaPmmpOwhw9HEUi6IwKan+APlpLuTx5bTuRhqyN0ZMa8CEqQX/wgUtxG54h47rzxhrMuKregd/MTQVH3jHWdcU/xQQKUISk5GiJv0GBWiX8GkaQmuYZqWeDS0J4gvsrINytdlZjBTxkW9imXKzBzQDfFeNwiACCu3mcG2Q0xyQM7JGq+arkm/wvJ3V4xL8SFDXi1G8CX5foyRXEOJAn5iy8Y62kNsSsP/vlZyjJjOVPXcFsZx+ViFVh7kuE8G9F/KIhI3meNtGsYR+xjyfHTabGXDwfn7kR+Kse6Y41fpBa+F0utYfJw0TAc5OwD1uKbQvrLrDRfgtW5n7j41lIcrZm1JT/tDYdN1iaorxN60I/+V8DfSkcpT0fZqdjuSe5ousCJ2RdkcTzcx+cyP2omEzUT4IMxOYOvAyUlNt6r9pp4p5i13Xb2SuTS9fOlYf5+BJ7FLg3PVme/lRb4FXl8Kewu1sAzG0bgkSRJrST3UeYLmEiEd63LiKn/HVl/Q2Us8QuPLtG793GEendyCS5HnRenYv8+TajRk2UvB+2JSItEG+fzapZTgqplSOYvakxCo0ICLDn/r5/b8IPxXBVKHTBGaEx2MgX8rYMjAHiUiP99XGdYZvuFNskb+kqHSMfJscRD4mVWQ4Ztoe47BDMGRvx6wIlr4nmwzy+ApT3ZXTms0AYlPPE/XnNxi82FVz8BkYVQT7NWFIzCwnlC/JIkotCLHV6O28Vi3A9Uj1d8Z7p0RTn0Tdt5wwwSpdLwZuRg0YgtTSHmbFJWGCKSrWHFowUVYq6wCzz73nqPlT5ufmXKTJll/M2/426fde45BUK4g/8pTMW Jfbvat4y Qp+5cRp5w9EVkjePv7bP9SvNtWLn2UC0KJwW+11fd/r88uuy0Z8WtxWAnL4NgKEStQ97SKzpAIXJF2px8cWH64zgAtIkcykfh0D8Jlk+LduDGErtSLaZy0L43AFj161rGSnAFumxMecK1IOMMV44oFeGNIuuUWj1ow/JMj4jLygBHZpOuEjJX7yldobRCXLBrSWPyIitYPhWv80hUE3X6nju6XbFpERDTzyOBUkmxeQa6kFIb+HDPMQ56UA== 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: A subsequent fix for arm64 will use this parameter to parse the vma information from the snapshot created by dump_vma_snapshot() rather than traversing the vma list without the mmap_lock. Fixes: 6dd8b1a0b6cb ("arm64: mte: Dump the MTE tags in the core file") Cc: # 5.18.x Signed-off-by: Catalin Marinas Reported-by: Seth Jenkins Suggested-by: Seth Jenkins Cc: Will Deacon Cc: Eric Biederman Cc: Kees Cook Acked-by: Kees Cook --- arch/arm64/kernel/elfcore.c | 4 ++-- arch/ia64/kernel/elfcore.c | 4 ++-- arch/x86/um/elfcore.c | 4 ++-- fs/binfmt_elf.c | 4 ++-- fs/binfmt_elf_fdpic.c | 4 ++-- include/linux/elfcore.h | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kernel/elfcore.c b/arch/arm64/kernel/elfcore.c index 4e3f84799669..b2388f15223e 100644 --- a/arch/arm64/kernel/elfcore.c +++ b/arch/arm64/kernel/elfcore.c @@ -76,7 +76,7 @@ static int mte_dump_tag_range(struct coredump_params *cprm, return ret; } -Elf_Half elf_core_extra_phdrs(void) +Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm) { struct vm_area_struct *vma; int vma_count = 0; @@ -113,7 +113,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) return 1; } -size_t elf_core_extra_data_size(void) +size_t elf_core_extra_data_size(struct coredump_params *cprm) { struct vm_area_struct *vma; size_t data_size = 0; diff --git a/arch/ia64/kernel/elfcore.c b/arch/ia64/kernel/elfcore.c index 94680521fbf9..8895df121540 100644 --- a/arch/ia64/kernel/elfcore.c +++ b/arch/ia64/kernel/elfcore.c @@ -7,7 +7,7 @@ #include -Elf64_Half elf_core_extra_phdrs(void) +Elf64_Half elf_core_extra_phdrs(struct coredump_params *cprm) { return GATE_EHDR->e_phnum; } @@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm) return 1; } -size_t elf_core_extra_data_size(void) +size_t elf_core_extra_data_size(struct coredump_params *cprm) { const struct elf_phdr *const gate_phdrs = (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); diff --git a/arch/x86/um/elfcore.c b/arch/x86/um/elfcore.c index 48a3eb09d951..650cdbbdaf45 100644 --- a/arch/x86/um/elfcore.c +++ b/arch/x86/um/elfcore.c @@ -7,7 +7,7 @@ #include -Elf32_Half elf_core_extra_phdrs(void) +Elf32_Half elf_core_extra_phdrs(struct coredump_params *cprm) { return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0; } @@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm) return 1; } -size_t elf_core_extra_data_size(void) +size_t elf_core_extra_data_size(struct coredump_params *cprm) { if ( vsyscall_ehdr ) { const struct elfhdr *const ehdrp = diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 6a11025e5850..444302afc673 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -2209,7 +2209,7 @@ static int elf_core_dump(struct coredump_params *cprm) * The number of segs are recored into ELF header as 16bit value. * Please check DEFAULT_MAX_MAP_COUNT definition when you modify here. */ - segs = cprm->vma_count + elf_core_extra_phdrs(); + segs = cprm->vma_count + elf_core_extra_phdrs(cprm); /* for notes section */ segs++; @@ -2249,7 +2249,7 @@ static int elf_core_dump(struct coredump_params *cprm) dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); offset += cprm->vma_data_size; - offset += elf_core_extra_data_size(); + offset += elf_core_extra_data_size(cprm); e_shoff = offset; if (e_phnum == PN_XNUM) { diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 08d0c8797828..2855f19ae3af 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1508,7 +1508,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) tmp->next = thread_list; thread_list = tmp; - segs = cprm->vma_count + elf_core_extra_phdrs(); + segs = cprm->vma_count + elf_core_extra_phdrs(cprm); /* for notes section */ segs++; @@ -1554,7 +1554,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); offset += cprm->vma_data_size; - offset += elf_core_extra_data_size(); + offset += elf_core_extra_data_size(cprm); e_shoff = offset; if (e_phnum == PN_XNUM) { diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h index 346a8b56cdc8..79e26b18bf0e 100644 --- a/include/linux/elfcore.h +++ b/include/linux/elfcore.h @@ -114,14 +114,14 @@ static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_reg * Dumping its extra ELF program headers includes all the other information * a debugger needs to easily find how the gate DSO was being used. */ -extern Elf_Half elf_core_extra_phdrs(void); +extern Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm); extern int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset); extern int elf_core_write_extra_data(struct coredump_params *cprm); -extern size_t elf_core_extra_data_size(void); +extern size_t elf_core_extra_data_size(struct coredump_params *cprm); #else -static inline Elf_Half elf_core_extra_phdrs(void) +static inline Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm) { return 0; } @@ -136,7 +136,7 @@ static inline int elf_core_write_extra_data(struct coredump_params *cprm) return 1; } -static inline size_t elf_core_extra_data_size(void) +static inline size_t elf_core_extra_data_size(struct coredump_params *cprm) { return 0; }