From patchwork Sat Jan 4 14:38:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13926271 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 E0D16E77188 for ; Sat, 4 Jan 2025 14:39:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DE096B0099; Sat, 4 Jan 2025 09:39:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 78EA26B009A; Sat, 4 Jan 2025 09:39:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6587B6B009B; Sat, 4 Jan 2025 09:39:12 -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 47F946B0099 for ; Sat, 4 Jan 2025 09:39:12 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0480480D7F for ; Sat, 4 Jan 2025 14:39:11 +0000 (UTC) X-FDA: 82970026944.15.465BB85 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf08.hostedemail.com (Postfix) with ESMTP id 1C6CB160005 for ; Sat, 4 Jan 2025 14:39:09 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=Vv8K+tfa; spf=pass (imf08.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736001550; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SYIrxPsAVLm9525H8KmJlUUcKlEHI39WEeyICf7u0AY=; b=KqmeKqRxAhFTf2vS4C/MDw+N1akKVoyA6489agcXCK7KvsRJVQhWYWeEwNk3LwtjG2M6rJ i1DJ5n+i9fcxTM7s9k5RPhduXThbAARCxv+DZHot6wvxYk9EFtWMw3n6EYMcEG5V6Ezxe8 eJp5bRTcddZa9STGc34cREot8fwRtT8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=Vv8K+tfa; spf=pass (imf08.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736001550; a=rsa-sha256; cv=none; b=kswgmgGyjAj29wdZTRWRRfMm+Ez67Wpi0XiSwsyYbY0DYeBW5PUYRb2NUxhHXWf4M6NOot VsS52bVgewHNkSoqRjs7R2+jEV5EVETTtV/iv9OK9GW5O0nrMf++ucTq3RpvBDB9us4iX8 X32rQfrefB6p+p0gXc8wE2O1skxfT2Q= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2166651f752so214487705ad.3 for ; Sat, 04 Jan 2025 06:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736001549; x=1736606349; darn=kvack.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=SYIrxPsAVLm9525H8KmJlUUcKlEHI39WEeyICf7u0AY=; b=Vv8K+tfaWSUD7O7ks6CCRVOceqnAqQ1Du+X5QGv6QceAbP3k0uwjydReVGOtHhQdir MX9F6SxbStL1wVrGBdo1lfojEnxi3xZS3SPqqrA1cJD33mFmYqiuxlBslN97T9NdW73Z L9xTKtChdM8M3P/FDMSZlDy75c23b9R4fHfC2NPWpzy1YTZ/3SUIribVSPFyXGplZP01 94GIYXagwaU40lUquw2VwyeZ6P6alnLMXpB+gLWkuidjYrP826Kx+e+KmRmoc0vJgB6T qxMBHthxCSKBVBRA/uRH9KX/+vA3JKmZ39P/SXcuuYJIuPXxKwFZkeltKNoDLfnwvrL8 pcQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736001549; x=1736606349; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SYIrxPsAVLm9525H8KmJlUUcKlEHI39WEeyICf7u0AY=; b=dd/yehougqMLuPwP7b54pZdEmxg9AhHHt7vDe+kJbPp/JLRJVj/MqtX5uJt++E0gN7 Ro13ZR9aNco2zpFRaQCGmYT/M38PRAbQrBgWENSK+cDp3i3Iz7jrNXjvzg8upiNpAA0O l9qAug9dgmAH3tj7jD3B30dBPObS2mQEjIbTjQSFvEfARGNF8Y/7fNc7ZMqpOb1WCJfI siSIwrPTU/n6wk+IhQsn6LiQ2XvghKs6pu68nXNAGZoOu57Qf5seRr8Osi7JZva2V3GL mT0wbfbwZ76xkXNfy0bMc2vXEdX5lZSwcJL1VTFv8uoFtUxgxtd1NJbYIFQmnCUjL+tY 0HXQ== X-Gm-Message-State: AOJu0YzR2ifpbH8Mi15168gpXFg+VDGnLf0m/b3ulUvbKkioqr4hJmmA AxfHZnoDc5AdcehPFIQWuc2BoNGuHCQWJ59T3aUvv3J0SVvOKN0zxBVtnq5ehkg= X-Gm-Gg: ASbGncsxt/KU7RCxPNo6BeUyB1LPV15AqTkCE4OWFhhH3jRe060LJMygPOShfi9ULEP FBUastmcTnJeQFwsP7W/s93T3LNUWoy8L1khrqdishE2xoa8z0OmpUtqzeiFqazX8Sr2WkTmnp5 fFyJcxeAhHijXbNlKqQhduc38DZ9TTwp7a2hlFUtEITRSjevJMFyQAtLffaqonqr4i59ali9Mxu xLzB6KM/4njBSqEK60Cuw7ZdDt7dtdSkVNGrZqNmqqnXVvjaxoik3+iAdWOXQY= X-Google-Smtp-Source: AGHT+IEy84cJ3h5ytJvCxSHHyFyZN9d/gzxb3RlphGjioGS1LvEPzNOYZA2OsynrQSHDV4AjG+98tg== X-Received: by 2002:a17:902:db0f:b0:215:4362:bc76 with SMTP id d9443c01a7336-219e6f29827mr814402335ad.54.1736001548953; Sat, 04 Jan 2025 06:39:08 -0800 (PST) Received: from localhost ([2400:4050:b783:b00:4952:3c52:120a:27e9]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-219dc963103sm262510765ad.52.2025.01.04.06.39.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 04 Jan 2025 06:39:08 -0800 (PST) From: Akihiko Odaki Date: Sat, 04 Jan 2025 23:38:37 +0900 Subject: [PATCH v2 4/5] crash: Use note name macros MIME-Version: 1.0 Message-Id: <20250104-elf-v2-4-77dc2e06db4e@daynix.com> References: <20250104-elf-v2-0-77dc2e06db4e@daynix.com> In-Reply-To: <20250104-elf-v2-0-77dc2e06db4e@daynix.com> To: Eric Biederman , Kees Cook , Catalin Marinas , Mark Brown , Dave Martin , Baoquan He , Vivek Goyal , Dave Young Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kexec@lists.infradead.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 X-Rspamd-Queue-Id: 1C6CB160005 X-Stat-Signature: 3urzk7mf6ot7fei6bk7jzt11igozs9yy X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736001549-761011 X-HE-Meta: U2FsdGVkX1/Qjau/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Gt1yXKOs9da0p6cdlRN6bAClsVsZJ/7AA5BSRUD+7Bw3j4qlXaqF+WZktnga3WO7ZkIfTZcarSZ9X4EYXRicG/fWuEqk2crupwsmkTjo5HQF1NAwJYmVzOIa6MRd6jVMgqXuXtyFqcrQgcEAB+eYEuKmacYpawFF5o+6Uj0N0dzk4ZF0fXwdmR4n2JtvhPd99bFlXxBlf+5FIrrYKI3MpcmZ2TwNaXIbbDtp2lS8VcSAHnP5zBAaMYlwQwgXgjH/u95AFfd1iK2FB8Wa8 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: List-Subscribe: List-Unsubscribe: Use note name macros to match with the userspace's expectation. Signed-off-by: Akihiko Odaki --- fs/proc/kcore.c | 12 ++++++------ include/linux/vmcore_info.h | 2 +- kernel/crash_core.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index e376f48c4b8b..e5612313b8b4 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -34,8 +34,6 @@ #include #include "internal.h" -#define CORE_STR "CORE" - #ifndef ELF_CORE_EFLAGS #define ELF_CORE_EFLAGS 0 #endif @@ -119,7 +117,9 @@ static size_t get_kcore_size(int *nphdr, size_t *phdrs_len, size_t *notes_len, *phdrs_len = *nphdr * sizeof(struct elf_phdr); *notes_len = (4 * sizeof(struct elf_note) + - 3 * ALIGN(sizeof(CORE_STR), 4) + + ALIGN(sizeof(NN_PRSTATUS), 4) + + ALIGN(sizeof(NN_PRPSINFO), 4) + + ALIGN(sizeof(NN_TASKSTRUCT), 4) + VMCOREINFO_NOTE_NAME_BYTES + ALIGN(sizeof(struct elf_prstatus), 4) + ALIGN(sizeof(struct elf_prpsinfo), 4) + @@ -444,11 +444,11 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct iov_iter *iter) goto out; } - append_kcore_note(notes, &i, CORE_STR, NT_PRSTATUS, &prstatus, + append_kcore_note(notes, &i, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); - append_kcore_note(notes, &i, CORE_STR, NT_PRPSINFO, &prpsinfo, + append_kcore_note(notes, &i, NN_PRPSINFO, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo)); - append_kcore_note(notes, &i, CORE_STR, NT_TASKSTRUCT, current, + append_kcore_note(notes, &i, NN_TASKSTRUCT, NT_TASKSTRUCT, current, arch_task_struct_size); /* * vmcoreinfo_size is mostly constant after init time, but it diff --git a/include/linux/vmcore_info.h b/include/linux/vmcore_info.h index e1dec1a6a749..1672801fd98c 100644 --- a/include/linux/vmcore_info.h +++ b/include/linux/vmcore_info.h @@ -8,7 +8,7 @@ #define CRASH_CORE_NOTE_NAME "CORE" #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) -#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4) +#define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(NN_PRSTATUS), 4) #define CRASH_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4) /* diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 078fe5bc5a74..335b8425dd4b 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -436,7 +436,7 @@ void crash_save_cpu(struct pt_regs *regs, int cpu) memset(&prstatus, 0, sizeof(prstatus)); prstatus.common.pr_pid = current->pid; elf_core_copy_regs(&prstatus.pr_reg, regs); - buf = append_elf_note(buf, KEXEC_CORE_NOTE_NAME, NT_PRSTATUS, + buf = append_elf_note(buf, NN_PRSTATUS, NT_PRSTATUS, &prstatus, sizeof(prstatus)); final_note(buf); }