From patchwork Sat Jan 4 14:38:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13926269 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 8C44EE77188 for ; Sat, 4 Jan 2025 14:38:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C2AF6B0093; Sat, 4 Jan 2025 09:38:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 173FE6B0095; Sat, 4 Jan 2025 09:38:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03B6E6B0096; Sat, 4 Jan 2025 09:38:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D3DFB6B0093 for ; Sat, 4 Jan 2025 09:38:58 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 84AF8AFFB0 for ; Sat, 4 Jan 2025 14:38:58 +0000 (UTC) X-FDA: 82970026356.11.8409445 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf13.hostedemail.com (Postfix) with ESMTP id A34682000A for ; Sat, 4 Jan 2025 14:38:56 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=hUhl6nNY; dmarc=none; spf=pass (imf13.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736001536; 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=isBOK5EkoVzx0+60SYTBYbzag/ZGKna5MSZ560y293s=; b=0qlnoc84xiUS8oB28v2jU7XTA44KXfyu/ze+ltdP7o/3WJulT7CVo838SeM+G2lYx4rvYV hrWjTRX4woSmhRxkCKQ9QWmlga4T6odQZoV/s/Y5LoCQTFj1e4PJaZC7aEQQTkVdn+k3Dc PCPqspwyem4skMx220J5j9AoC+/T19k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736001536; a=rsa-sha256; cv=none; b=ShmMrE6sUBOlTLoWt2rhAdd7QK8EA1mFRuTNCNbs9Fb/61VkmCo8pTzlTNvzAHMonabfnS z+R56IczY8vxZYB66r8sFC0/DWM8FUAKxbpJoJfiAVDqu4exVIY+YLhfnPVjJysXyRDMiN 8nfOrK7/7+PiDENQKmpalpQ972YNk2k= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=hUhl6nNY; dmarc=none; spf=pass (imf13.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-21649a7bcdcso178992165ad.1 for ; Sat, 04 Jan 2025 06:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736001535; x=1736606335; 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=isBOK5EkoVzx0+60SYTBYbzag/ZGKna5MSZ560y293s=; b=hUhl6nNY1xYnEJf4nUI3V3HsYccq++4U400HoJ9GxzLlVpw3jZGKtrXngdNwKSWmcj UzE2sUrQxnQLcI3cOk6Fgr3nktYCa14chzBFWXA6rycnII8VrrFFqBtcgu/X8yT+3u4e oIMdbmJWocWpJ5vSafyrmS2SN/WyHFv3VgJJ03oIzW9RRdvkJ8PIAYYGDQVu4E8UA1bj kqOGJlWT41H5bRAbR3nECpFRG5O/X+GWmOOL5qezfRveDvmTBY/6UvvuY8dpDOkRcva2 NdMbdSnqVSErDsMwnnlfHsA1jYQ3UxlBYYDRvKWDTCLD2vkwA5CkQEB0DzFYzL9+IysQ nYBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736001535; x=1736606335; 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=isBOK5EkoVzx0+60SYTBYbzag/ZGKna5MSZ560y293s=; b=KEnD2FSS5hNZCGKes0Asf1CSJBohcBDiVln7TqtsZRCRR9vmpYfFudeWb57G8DCgdc hvc6Ib0kCEZgygIwGSoongrF7AOtAQFPJJZtV1UieAEhaP7ESENkLjXU0aObomm6ob5C WyZDQpo+SRTyOGWeRpWLqtK9YSVkbPj1o5GGMra7tuLdKFCNz2MYzFyBHg3vK1UyszWW S1nxlm5mP75Zq3+eKsmMCP7mBtDyX92srFz9Pk/wLKlWTT5RiRsibePJyioUrXYILx+t HhQFUJmBk4NRQlKWqsumBX42fkyPurJrTbsU++QV/B8mheqGpWSELbTswxycmCw1O4pH 2Bqw== X-Gm-Message-State: AOJu0Yz9MstGIUGPbBRiyUBv6s70oNdNGhBrkCTIBguMIjtfnpDLc4t8 2LRsbo4s9sap1hNBJcDTwRJ8HZP6tZDCfkFEfv9Vx0mArYDFPgbbjfF7t73zZp0= X-Gm-Gg: ASbGnct7UgtBOIZD3dYo/WtFlx+6ePlNnSoqSkGOt7zAx3G316sFTgad3SxFI9EX1pB wkAh60CDtKJJtpWqyM941T+pEtMaiDmUh0IRvYMBiUPRmvPrAnQK+Ht1PzhavBu3ewD+w5QE6qx DPvX4NdS2uUGIy71M1fJk7eQwrFrwuWauZcCFdURlpZyqOF/mkrgA/3VB+NaRg6Y+mMnsYCVprr PzXwZ6uYe8r8hYKJuPq4l2suQa3+F0ZlS+H29hfWDKv+32JHVpHhdOya04v4Lw= X-Google-Smtp-Source: AGHT+IF6CIwlIeIPYhIfDdGvLEKVBUHmWt4TSRbGoWTRRPhul/Ngc0MsMOD2Yw2Im8h1VnwURPE7+A== X-Received: by 2002:a05:6a00:44cb:b0:725:1d37:ebff with SMTP id d2e1a72fcca58-72abe0960c6mr74590582b3a.22.1736001535492; Sat, 04 Jan 2025 06:38:55 -0800 (PST) Received: from localhost ([2400:4050:b783:b00:4952:3c52:120a:27e9]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-8427ab7830asm25799890a12.0.2025.01.04.06.38.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 04 Jan 2025 06:38:55 -0800 (PST) From: Akihiko Odaki Date: Sat, 04 Jan 2025 23:38:35 +0900 Subject: [PATCH v2 2/5] binfmt_elf: Use note name macros MIME-Version: 1.0 Message-Id: <20250104-elf-v2-2-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-Stat-Signature: zbii6yq9n6p137ekf4rnqpdwccka6axh X-Rspamd-Queue-Id: A34682000A X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736001536-864361 X-HE-Meta: U2Fsd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IYmsPBjH1Y+psLO+Q1Ge5vO0Z5pK5JWL3pxiVfwfCIu2Thpij0a6vKujaEtkfEtD2B+dOlTN4KfILRVpQsvQCvNKJCjEIPzTRYEfRyHlGPlChp4RJpzPB7wFuUCC0fBsxteyTUH+fPSsK+HV1bfQg5YwNyGiGZlOHbx0LtuA337KEadenDqOcSjO+LUQwRYGfQH4x0lNLCY4i58JdJj2Y2NU4/mkaSWhiRZXnNGJDgex8h8L7kcsdJUU673P0h9KbC5SWkpcwbNI/F4wu1FEyqc/oUWEAAHqCpnQ8Ip9cC0AGc+QN+TXlZIPWOJvl+F1NKlbl1xo9JW5Tvy0H6cd3E6iti8Q== 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/binfmt_elf.c | 21 ++++++++++----------- fs/binfmt_elf_fdpic.c | 8 ++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 106f0e8af177..5b4a92e5e508 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -762,8 +762,7 @@ static int parse_elf_property(const char *data, size_t *off, size_t datasz, } #define NOTE_DATA_SZ SZ_1K -#define GNU_PROPERTY_TYPE_0_NAME "GNU" -#define NOTE_NAME_SZ (sizeof(GNU_PROPERTY_TYPE_0_NAME)) +#define NOTE_NAME_SZ (sizeof(NN_GNU_PROPERTY_TYPE_0)) static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr, struct arch_elf_state *arch) @@ -800,7 +799,7 @@ static int parse_elf_properties(struct file *f, const struct elf_phdr *phdr, if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 || note.nhdr.n_namesz != NOTE_NAME_SZ || strncmp(note.data + sizeof(note.nhdr), - GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr))) + NN_GNU_PROPERTY_TYPE_0, n - sizeof(note.nhdr))) return -ENOEXEC; off = round_up(sizeof(note.nhdr) + NOTE_NAME_SZ, @@ -1603,14 +1602,14 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm) do i += 2; while (auxv[i - 2] != AT_NULL); - fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv); + fill_note(note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv); } static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata, const kernel_siginfo_t *siginfo) { copy_siginfo_to_external(csigdata, siginfo); - fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata); + fill_note(note, NN_SIGINFO, NT_SIGINFO, sizeof(*csigdata), csigdata); } /* @@ -1706,7 +1705,7 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm } size = name_curpos - (char *)data; - fill_note(note, "CORE", NT_FILE, size, data); + fill_note(note, NN_FILE, NT_FILE, size, data); return 0; } @@ -1767,7 +1766,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, regset_get(t->task, &view->regsets[0], sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, PRSTATUS_SIZE, &t->prstatus); info->size += notesize(&t->notes[0]); @@ -1801,7 +1800,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, if (is_fpreg) SET_PR_FPVALID(&t->prstatus); - fill_note(&t->notes[note_iter], is_fpreg ? "CORE" : "LINUX", + fill_note(&t->notes[note_iter], is_fpreg ? NN_PRFPREG : "LINUX", note_type, ret, data); info->size += notesize(&t->notes[note_iter]); @@ -1821,7 +1820,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, fill_prstatus(&t->prstatus.common, p, signr); elf_core_copy_task_regs(p, &t->prstatus.pr_reg); - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus), &(t->prstatus)); info->size += notesize(&t->notes[0]); @@ -1832,7 +1831,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, } t->prstatus.pr_fpvalid = 1; - fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(*fpu), fpu); + fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(*fpu), fpu); info->size += notesize(&t->notes[1]); return 1; @@ -1852,7 +1851,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); if (!psinfo) return 0; - fill_note(&info->psinfo, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); + fill_note(&info->psinfo, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo); #ifdef CORE_DUMP_USE_REGSET view = task_user_regset_view(dump_task); diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index f1a7c4875c4a..96bd9d2f23d7 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1397,7 +1397,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_ regset_get(p, &view->regsets[0], sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, sizeof(t->prstatus), + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, sizeof(t->prstatus), &t->prstatus); t->num_notes++; *sz += notesize(&t->notes[0]); @@ -1415,7 +1415,7 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_ } if (t->prstatus.pr_fpvalid) { - fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(t->fpu), + fill_note(&t->notes[1], NN_PRFPREG, NT_PRFPREG, sizeof(t->fpu), &t->fpu); t->num_notes++; *sz += notesize(&t->notes[1]); @@ -1530,7 +1530,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) */ fill_psinfo(psinfo, current->group_leader, current->mm); - fill_note(&psinfo_note, "CORE", NT_PRPSINFO, sizeof(*psinfo), psinfo); + fill_note(&psinfo_note, NN_PRPSINFO, NT_PRPSINFO, sizeof(*psinfo), psinfo); thread_status_size += notesize(&psinfo_note); auxv = (elf_addr_t *) current->mm->saved_auxv; @@ -1538,7 +1538,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) do i += 2; while (auxv[i - 2] != AT_NULL); - fill_note(&auxv_note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv); + fill_note(&auxv_note, NN_AUXV, NT_AUXV, i * sizeof(elf_addr_t), auxv); thread_status_size += notesize(&auxv_note); offset = sizeof(*elf); /* ELF header */