From patchwork Tue Jan 7 12:45:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13928843 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 2A724E77197 for ; Tue, 7 Jan 2025 12:48:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC8936B00C1; Tue, 7 Jan 2025 07:48:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A7AD56B00C2; Tue, 7 Jan 2025 07:48:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F03D6B00C3; Tue, 7 Jan 2025 07:48:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6CC9A6B00C1 for ; Tue, 7 Jan 2025 07:48:22 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id ED922C090D for ; Tue, 7 Jan 2025 12:48:21 +0000 (UTC) X-FDA: 82980634002.24.1B7F1AC Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf05.hostedemail.com (Postfix) with ESMTP id 16AA110000C for ; Tue, 7 Jan 2025 12:48:19 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=NFzo5349; spf=pass (imf05.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.45 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=1736254100; 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=d5w0df8A0RGvduNGo/n7gECMAUl7ttjM0kfw51R7kHo=; b=240nxaodxQbSJe7TKN01/5ovXjaCZBDysDNw1Cg8fCGRTIvhj9SVpfVAJ7Udotv+AC45SG wxCn2yVh36SqYqgtOC2SNoeSqCCL8BY5xwgPgv48C+bwpXxS8jCAzzuFWsS6mLkJGqGxj/ JKZ8S26Wst5c+In4VzEF0bmhrRgHIi0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736254100; a=rsa-sha256; cv=none; b=B7o++EFUbQjrg0W5d/M2W7gEy3Ez8+T3b2AD8KzQIFsYr/D3FXGVhwjPnDp1y3WaC8JzNN hfRawfIRvq/0bKLfo0Flbgohre2aDPvRbtNDm+tUI2zzA0ho6V9fXVtR17S81ilEO0Zmm2 FWCtT7BWUXeF5v14XG4tfM5lC0Jp6F0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=NFzo5349; spf=pass (imf05.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2ee74291415so18414667a91.3 for ; Tue, 07 Jan 2025 04:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736254099; x=1736858899; 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=d5w0df8A0RGvduNGo/n7gECMAUl7ttjM0kfw51R7kHo=; b=NFzo5349mPD9tX+wqas+OyQOSBNnhB32wADsUxIwNMvjzj+Yg2QZUdoc8sJn1JjRAe bberyv+eaKds22FiiVAMgVoH0G26NpqyduO5yNW/eIqPXAPKoK3xS7FNNzT97l65qnAc eNfV/UpQ8K9/1umszTShnTJrOCcNfk0pXVkf13C5gpBLR3U14RyGZC8gkAgkl3yV5rOs hIHlqPb0wwqXJr4h2Vdq3TxZiU1B8toiHlU2zF7hVWosj6T2q4CEKwdy3JjwHwHcxAZC 2UlYiH/p1hgCi47PLjka5EdiofY6inGXAXT9C9gU4VbcfKEU5hDQtG+kvs/7Yb0sAnSA klGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736254099; x=1736858899; 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=d5w0df8A0RGvduNGo/n7gECMAUl7ttjM0kfw51R7kHo=; b=vBLKz3hHUzopdLXf4e/hl+O82pKePhY053CsentX41VkcegQ1NprR46SqQrUwp/M7H ioagcl87jxAjbNHJFLG/GFae/g9mqUuGxgcUn66kXPervINey3bxB2bY1SA+dSnNj1Xi mDuJe2ShZWbQx7AgsjS04l8kuAOLPI6DlfLPqKaZ7QXO0uquOmCgwZlZ5cV9cpVPriTm D0jpWtxU0AoQqkxq8ZwDO6DWokm85V3n0+ZlMjnM6uyagC3anZ1JoGXH1Kw7oI3l0nDX /onWnhTYy+2XjROYzmgPc9jkJ+102nYEQgmpC8Q0QpKc08fpPna/jD0r3K+eZBonmr3q SZZA== X-Gm-Message-State: AOJu0YzUVdnfpFdzbxoxyq57PBEFKALc70Lu+KrdHtwFeFNiOQdquy+v eazLaZwyN9T2LWECgUgB+j3B6L55y6HoY6et7kikbqaSVKHV0ICXuPpZ9IS9vGY= X-Gm-Gg: ASbGncuOjgXYtEIkC48Sm32J1ooYpHMAkSgjR5H4RKSuqiAsbPR9p+Qp39/A5+2FhTJ 9G/AKupFUUv6qfwWZoWcTGLgAL+voWK5BW8IHOQIH2nGDqmV1QDXkdEZmxScamFzjkTLrIEFYpH e3FFkusC8KCPzryNhmjWx9kdBCzYWdFR+mVcP26zjVnXzg53BLksFFftHJVMM1HmT7ua/aMtusq p/v3euVFLNjUhIu9a2wkHbBJwNFtGlBkpWQS3kR/eN4woYT4gbjIxpJBBU= X-Google-Smtp-Source: AGHT+IF4unLvSG3ozl/K+xZg50qJ9RhkOXYw+z5VR9QTjd55CxK7F8LQeDMLqnNt5CS4t8mxmL2QoA== X-Received: by 2002:a17:90b:534b:b0:2ee:a127:ba96 with SMTP id 98e67ed59e1d1-2f452ec6d35mr81063623a91.23.1736254098937; Tue, 07 Jan 2025 04:48:18 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2f2ee06dd46sm41574100a91.36.2025.01.07.04.48.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 04:48:18 -0800 (PST) From: Akihiko Odaki Date: Tue, 07 Jan 2025 21:45:55 +0900 Subject: [PATCH v3 4/6] crash: Use note name macros MIME-Version: 1.0 Message-Id: <20250107-elf-v3-4-99cb505b1ab2@daynix.com> References: <20250107-elf-v3-0-99cb505b1ab2@daynix.com> In-Reply-To: <20250107-elf-v3-0-99cb505b1ab2@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, binutils@sourceware.org, devel@daynix.com, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 X-Rspamd-Queue-Id: 16AA110000C X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: sacme41hc9edtoq5fbbok5rceyo1zdn1 X-HE-Tag: 1736254099-583254 X-HE-Meta: U2FsdGVkX1/ifg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bQvQyHlrUj1GL4U4Qk9EPhbG0lU00FLEi0ptHiHQYB3aze5cH7tGyqEAXl+Tvs7VzTneoaaZzlU7TFDYvbGq/QSm2wbLV+xwBhA/MG3dRVzWEE+ettUfklLwncc4W5JiueqQBcS4Vauu3DgzbvQqijfgL/Mxap1BUrqnwoy0VSDiiibPj5nr6GFZUqPI6iJjlPce551jjqsLeITrQZB+eTKm0goIuT6XVfX4J0hr1GKXaXa7sQLuF5vuk64Oo4= 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 Acked-by: Baoquan He --- 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); }