From patchwork Tue Jan 7 12:45:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13928841 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 39FA3E77198 for ; Tue, 7 Jan 2025 12:48:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB2806B00AE; Tue, 7 Jan 2025 07:48:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B62006B00B0; Tue, 7 Jan 2025 07:48:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DAB96B00B3; Tue, 7 Jan 2025 07:48:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7CE406B00AE for ; Tue, 7 Jan 2025 07:48:09 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EEEFFA08F4 for ; Tue, 7 Jan 2025 12:48:08 +0000 (UTC) X-FDA: 82980633456.30.5BF586E Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf12.hostedemail.com (Postfix) with ESMTP id 10DD74000E for ; Tue, 7 Jan 2025 12:48:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=sdjBFVfx; dmarc=none; spf=pass (imf12.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.44 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=1736254087; 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=qkYnNKDg8wve3Vy7Ocsymb3HOIzjHQ+wDfOyO6gyj9v8NDqUzUuWqfjUiM/UbCK/kePm0E 5CGmGK1BeAWhdo6np9PJ8/QCF5/YJH0VruEghkZDMDg4rpXWpIYSAksPcwEoP9cv+2p9mY TPgED4+dMZHFU9Zr/gWxafEjxhDqN4k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736254087; a=rsa-sha256; cv=none; b=uM4JMG5cNLHS8XG8LRdjjW/qmILwFnXRbYyIBwt2zlrlkZfrlfB1Vedh3JWtIoVyXl2zSt FRa527FGmdK4lZbFm9ORSItqpvYC7zHB8AUn0+lsuanB6yCx4UCeN2hhKgH/LHYgMTSwKq 7kOY/ODwFXBUnIqbIxxhqGvLPA5MHEI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=sdjBFVfx; dmarc=none; spf=pass (imf12.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2f43d17b0e3so23006414a91.0 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=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=sdjBFVfxocb0nKAYdUfMqrpY303G8Hu7AYJKUJM82t5oXMjdNbfxG/Nj3vo4N83kpN dBM2EpgJA7/mTLJjAkLVCOoynXHArDmBBj2wy6hjnlSxHKkv99XS4jRc0FbbA02ZXO5S St5/8gMe0vYSjqjIYmlS5p/FjZhVg4/XDXe2PxshgWeOwl4fzVSGB6CB2yubg5tdoG1f CWfsg5gcANSsYRqmwQcBBcWLHN+DKnTd/Qcbk2vPbsULhKXDE+TK4Vox1TxYXz7QrqaC IQSU2yPundNGIuoWJTz8TkW3F6b5CcCcRodaDrcBAPnbPrNUEWMh7pyDS5iYc/HAHh8Q JtUg== 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=EUsP134UOKHnZJrsKyncCiDUFF0WgSkNx0AU3JJ2xbdiCwVTLv5ZoHVwKHU5X9SPqG tL6iOrfMHbmBG5ByOLnMRTQNcaAN3HMYuu2PQolyXF1oc4MO8PkwKyBmbTNYgbYrGVFC OJJgBQAKo4ANcuaorkPLs7jemqQywKIJ5ggKOLyOzAwW4ap8meqHzmiNgjK1HEzmJGYy 9ELMTax4irxfm3dDqskHT37Ndbw3v5jScKuaYHLgWcrlWylWoT1ll+70XdtBAGp8DS81 2BSZFe3ov5fTdQblYuJr1AOm/46gDQHw6FAyz/IvNZxZLFs66eu8Qoz0bMYqtfxW3fNZ IcwA== X-Gm-Message-State: AOJu0YxSu0UbAsc7MeuAHJ5eEZk68SZyxYJRC1qchqYFqzxev9BfAjEI Rsc0U+RIZeTDIpUTzuy9fsFMVEo9CIjLNcALTg6XjWpMKcPCyaqYy4thE8eLdHw= X-Gm-Gg: ASbGncsBO07WjqQj/MG1gbadzRixLjLdHdw7+Ri75fTKmbdl/EDCsQ+a7n2v6jhFlq8 qkGMlThxhIq27nxvMkkdEcPwb7bNxu1idpq2dcxLfVQ0uzi2Ydkc7i4Y8Fp0mOnnkj4wrtcJACS BojkIVP8Hrckl+sgHoXPAhUw5gyXFg18Ll2PBp8s9uIvH6JpD6TxZJIrpdhc6FqJE25wxnqfkBm g68x5ygDW3K2+2aTI9hwGWbqc/t6CepKu1zhyhnasmQQhYngznwgvsreEo= 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 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-Stat-Signature: 6hiaank6j9jccmu49ns4gc5af31ohwpk X-Rspamd-Queue-Id: 10DD74000E X-Rspam-User: X-Rspamd-Server: rspam01 X-HE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9u2iQWxdjh7KCr1HhOs6w/XbVgxZOqTqEtKDoyvwyAA6Il8g+IgPwTezgcwlaen10gKR5T9z7oKokHexTPO4VMr7G52+B2d6v90D56yvqqHq8YcSoJXAUQi4BYO/BZsaDBXh9qODH45qTQ3D9q1EZ6JXHqC7MTUxC3ZSdbVZpWfhQcZJDy0TEhnUXo8HhU1jfKvwuPRas2fluBZqWETVyJ/ghxuPt3xJurL5h9B9Jq9qj2R05tQy/79EgNclJfHm1sxh2usoGYDF5Hon+BRlJQT/1lRWha7LBcvj1imxP3rAFcEydgCAlTW1Rn8WMDG9qhNdvL+z1+7O02tO4CN0+Zwi96yyQ8DxJ9IZv49 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 */