From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 936FFE77198 for ; Tue, 7 Jan 2025 12:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=To6WceQOVEAdrv9VIwdrgLUfIkfIZojfYpt2+tcFAZE=; b=NwPdF/Sf+I4cZM10SrztgBZ86s wMSY5e/PlYAxcl63lO/kokFUOd7J4U53im78oYLaxzsXe95uVNFJ8Wo1i4jbYjb0wOYsGkFL//7Qo Avd0xuHGwSf1q1f7TM9DXOUAW+XgEefTFQehS+TTkeX9IpWCitFFe5jK/du6eIMShSPW9nhp4tl/5 tjIN/bQKfXAB4dljizizhD9KDS+slkodCFYB9LSQ3WUVtVjSLO9+85c1EoJUbbkCCtIJw78dRk6HY ePLURTNJUhhOduLPEjoy7Tslm0fiW/bvuYQDCIEXSmXK3CD829NKbe/LOtO/BAom0STKOGTEjjtGc +NXolapA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tV90z-00000004phq-0spw; Tue, 07 Jan 2025 12:48:57 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tV90A-00000004pMO-2khI for kexec@lists.infradead.org; Tue, 07 Jan 2025 12:48:10 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2eeb4d643a5so22989893a91.3 for ; Tue, 07 Jan 2025 04:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736254086; x=1736858886; darn=lists.infradead.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=HbACcbSsN4UifQs+bqTDt3eFsHC1+i3cPCs/o71m4EfySBuYinJfOIt7mUCf2bVR0T GhbMdHWkKq1kCqJxzmwUf+gV9cwyRcP4oSH9QToAbKb/W6VuXpok/FMM4mLG8BrJKB8I MqVyElc6WSFDHgs41iYbYwQH+lMnKxM2lqlyXHV1sCMWiSVSKXoR6hO/1z/AR5tOppCC +2gf1QbqN+W4aPBQDUQh3vD89YyaqMxnj8gSRDZWYS7Y4fPc6BnddXgpuxRmiTseWgA7 Cy4Xkk9m94VXsdsMr6B8ll/HqB8BA4k5Da9sMwtGOtGAs8wKMFnU/QAuXeVVS3gqUbA4 1/Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736254086; x=1736858886; 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=wVGc9uJwiYX32PD242xIlQ/bSKm5X8j4RsPn9vJRuqYiEnbtGfsYIWSZC8ItdOAwa/ uC2MrAjjyIuUSJi0ea6vGGUe/Cild7O+fhcyaM2yTlhMpCz4VqgPMUcD1ECKF5Gk4/u/ n1tuxTFfGOFM2tc6vmmC4jRlvjOPsUuGo9Xepj5Cz9dzFQisRMUM9VcOHScNfZp6dBlT oZ3fR40wcSZ1FWKx2Q/dIFqn7JnDhcWqwzndop9aPxC54b7d2j8OKW8in+BiDiRt0dH9 dFzqwLPWPd0GkNB/gXwi1WeuMlLXX/wJub2buMdTfXA1tcvng15lyHw9jrFVxvg5E747 dJxA== X-Forwarded-Encrypted: i=1; AJvYcCVL/SU0/C+RE9/5znuBjkuvS8lYqzCU5FzcOwds+0OTRxkkrGSRUWjNfOL57emVa2KTNDGOQg==@lists.infradead.org X-Gm-Message-State: AOJu0Yxr2PAoYaHlYknvMMeInFA5xmzPP5RdFLMz5zyhJ5OHrMAqV92f vVEZuttZlS1jhjR8jG2FWQOnQcQrT18cTr47r1wuJWqd83DssqnzfBuHMEC8GOs= X-Gm-Gg: ASbGncvySaKICsB95+BCPnJBKjaRgHEjjpeg2UWYX4i7aMI8Nc5heWVHmqQGXD89nyG xVNu4US3Jd/9ctlnuaXdoFocj3tl5EAw3F8VUPB441cjaNhjRmmGsd+ZZyJfJxaz1sz76fripvg LDQkNpfkImSWy7CbwPMuiaZ2+HgQvwOA9ttgt02vfgexaWOIFIDZxpGhMjtSD/C12R2wnpBeKxo GL9ez7HPl5U4m+mY3D1djFV2AtKo7OVh3yZHqpQwgOL/y2r133KPU/HemQ= X-Google-Smtp-Source: AGHT+IHmQrtd6DArE28HS9MI+ljcSHS0URGz6WZZfYPdopYVfnKvqXeHpkFOcVWEZed1yb1h138/0Q== X-Received: by 2002:a05:6a00:22c2:b0:725:ef4b:de33 with SMTP id d2e1a72fcca58-72abdbe4de8mr79321688b3a.0.1736254085564; Tue, 07 Jan 2025 04:48:05 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-72aad90b338sm33355957b3a.174.2025.01.07.04.48.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 04:48:05 -0800 (PST) From: Akihiko Odaki Date: Tue, 07 Jan 2025 21:45:53 +0900 Subject: [PATCH v3 2/6] binfmt_elf: Use note name macros MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250107-elf-v3-2-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_044806_700743_A52CE794 X-CRM114-Status: GOOD ( 12.51 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org 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 */ -- 2.47.1