From patchwork Sat Jan 11 05:48:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13935789 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 94CDFE7719A for ; Sat, 11 Jan 2025 05:49:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29AB16B0085; Sat, 11 Jan 2025 00:49:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24AB06B00A0; Sat, 11 Jan 2025 00:49:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EBA26B00A1; Sat, 11 Jan 2025 00:49:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E56896B0085 for ; Sat, 11 Jan 2025 00:49:11 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ACA3DA10D0 for ; Sat, 11 Jan 2025 05:49:11 +0000 (UTC) X-FDA: 82994092902.30.3ED09C1 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf06.hostedemail.com (Postfix) with ESMTP id C031518000A for ; Sat, 11 Jan 2025 05:49:09 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=ifRf8JjC; spf=pass (imf06.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.172 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=1736574549; 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=To6WceQOVEAdrv9VIwdrgLUfIkfIZojfYpt2+tcFAZE=; b=zCOWptfKM/cpRgAeLleAjbApjvhqUBFnInP6Qiz9ik2L75M5WzSlIk98/G/QLZqZrE5rZ6 tXjs5AM2DXiVIAGtAnhKcwX0f5HfXSbp5IvxXBFaiutHBAKwWcKIV25BEHxBmcv+gj82N6 w2lIU6Zc/WWXFwTM2H6fE8LXrMYAo+4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736574549; a=rsa-sha256; cv=none; b=52Fgrkv+ILsgkQcyAMP580l1PCmyu4IBkquG5rwxQFVTfhcbrZP+9IiyyHWvex0kwHcsb3 /DAA5xX8QWGcQa168m4wnOyulxNsWqg1I/fWhVOT57lKmliNY0W+USB6i4f0DRir7GCjZG iMvG0GowJLFdGQYaZTs/MAk6Yxym3YY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=ifRf8JjC; spf=pass (imf06.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com; dmarc=none Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-21669fd5c7cso47190375ad.3 for ; Fri, 10 Jan 2025 21:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736574548; x=1737179348; 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=To6WceQOVEAdrv9VIwdrgLUfIkfIZojfYpt2+tcFAZE=; b=ifRf8JjC3kzgoQoadoSKMNtHTBL9npoSiMN/uT8q92tadHqBc3BAPoZHo/Ihb/hC/J MdFn253TH3XX7SBRt7OHn4vj6EX46xuy484HVMlJ0620BSGMEu3Q3tvQYmwulQpGbs2M XhQoabP86WjMt1VwA1tDXQfZkDDvm3xrKInI4ZeE2FrFLTy+nJBq3kqSgjRKy6HOj89N To7X8xvHLrS2dyoOOO2GkvS1uhevb9ezKQ6Gtxl0FpnjNng7LHBSsaEVPLXyYAO0Jv6a QWUISe+NMPf8LgiGKnlbzynAVNaWW3bg2RJiK0/9Yxaozh6xxWY7LDNjTdLKOV/6S+B2 H+1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736574548; x=1737179348; 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=To6WceQOVEAdrv9VIwdrgLUfIkfIZojfYpt2+tcFAZE=; b=Yq+O0VRAbUDHw0F+SYBsjYIFVTx1u070iFpRj5Uc/VklTS0i/Cxaxpm8o5QPZ0IiL8 swuPMdD8WRvfLwK+9T5kUkC4Gs5SrVQF2cGGYwTwqhZtkMS/YWAQ0WFHkCDUffloculm WyOn322nMvYqd+64ufuVgIX3RPIb/g8bMQD3GLW2w6lq3pNEQG4Q9czRdB81R96xlzg1 diVWYaF2ai3+552tWU+srJv9Y3yhfFD9xFsyEQpP7Q/jjIF+iuTJzI25ZtnJoQxnOPjC U0Axnrz+r+G4Qlcan0FGu/KOPz3XmDngjtHu+d/i2KjKaSxSzc0tvxbC505VE3TgjxW2 qvLg== X-Gm-Message-State: AOJu0Yw07O6GSug0MSDcWDaiRj7+bZNQY7fv8ygnIwLrmJnnZ9dXGhpF 5KXPzOSeclYQws88t0rgIwq76TZ/VkRaTDvV4TBStJvboZxmxUCFizlJWun0Nu4= X-Gm-Gg: ASbGncs3QsJOUDNzR9lKGdVasNm/sjqwUm6T+0tWpFWXssL1aX3E0qFR/7HCbDKzNp9 FIlxplWS3cwNTPiuZdTDCJKtj8f1THHk4eV+9O4Kqa0Y5b2bJ+nat19vuYC6cqNXeebThuQySSK qMKMgczKOXss9BHP5zLt9Mg8WunPSjeZ1A/y15+KRTnePISpEqMgESfvTy5b6Y0E6lXLwbNsXMC 2T6TL8p4ZrXFQz9kYE9Y3NIJH71OX8RCnE9MNTRFmjTFuCSm6orC2H4f0A= X-Google-Smtp-Source: AGHT+IHn65rwbd4gKdhst/GRdULarDOSLx1cuK1RthFbVp937QpJuhXkw/qwAunKCMjt+dsCYzpTGw== X-Received: by 2002:a17:902:ecc7:b0:216:760c:3879 with SMTP id d9443c01a7336-21a83fdf2d0mr185892965ad.46.1736574548582; Fri, 10 Jan 2025 21:49:08 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-21a9f22d293sm21144365ad.185.2025.01.10.21.49.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2025 21:49:08 -0800 (PST) From: Akihiko Odaki Date: Sat, 11 Jan 2025 14:48:45 +0900 Subject: [PATCH v4 2/6] binfmt_elf: Use note name macros MIME-Version: 1.0 Message-Id: <20250111-elf-v4-2-b3841fa0dcd9@daynix.com> References: <20250111-elf-v4-0-b3841fa0dcd9@daynix.com> In-Reply-To: <20250111-elf-v4-0-b3841fa0dcd9@daynix.com> To: Eric Biederman , Kees Cook , Catalin Marinas , Mark Brown , Dave Martin , Baoquan He , Vivek Goyal , Dave Young , LEROY Christophe 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-Server: rspam10 X-Rspamd-Queue-Id: C031518000A X-Stat-Signature: f9am6eri6toqajzzwo1fomyxzzayf3bj X-Rspam-User: X-HE-Tag: 1736574549-921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QcvrQsqh+65tsBdIvLMvm7OySwHThtD1gyCT+ySTWQ95MB3YGQTi0A+hHE9DH5IlT6UzZ/3LqYmvYwt1PpjFF/JCwHhH+o3jBHvq6mtGMSvhWQn29DEf0j7JmgYnjRn27HZjf4dsxYVVR/yPZdbCeV7hje/NDOCcWd8U0I6UeEdhy70fcHnJPk/aVG+ivFM6nEIOj3Q2KyREACjYCZdEC00ulW37st7QiWowrYH/04I629IQ7w7Il5QO7Zn/O+9kSruZpnt5NuHT0eSKAaxxIubQF+nKLLITMtWbFyWkeY6C1g4QqETOETSnuKLEFXsdH6HhnbV4O17mA61yNzzUydBrhMeVg0Aw 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/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 */