From patchwork Wed Jan 15 05:47:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13939850 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 9C124C02185 for ; Wed, 15 Jan 2025 05:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 347BB280003; Wed, 15 Jan 2025 00:48:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F71D6B0098; Wed, 15 Jan 2025 00:48:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C92B6B0095; Wed, 15 Jan 2025 00:48:55 -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 F13226B0095 for ; Wed, 15 Jan 2025 00:48:54 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 55DFF455A4 for ; Wed, 15 Jan 2025 05:48:54 +0000 (UTC) X-FDA: 83008607388.27.5AD30E7 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf19.hostedemail.com (Postfix) with ESMTP id 5E6221A0005 for ; Wed, 15 Jan 2025 05:48:52 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=zQaaIfDB; dmarc=none; spf=pass (imf19.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=1736920132; 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=sHzEFJeIZDo3f5k/3U0rvOC8rXQluzySCipEOCSBJIE=; b=IVPbZDiSvPTOeSvhoQ9UocYWqpFwDcYGRBRdGK8wGb+70DJxOo7NlmiB1++n4I8vKVKCm/ 9mDMOQJOQGlUJb/MdtnI2kcT9wCBCegZJfDcXcq7emBdN2lV92ArPIlEucjgEKxvndXj5z Nh9vrIISXWWziRrIF/Kvc/nRzQFkbLE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736920132; a=rsa-sha256; cv=none; b=eqkKzL40CzUPbmANGgeifhy8iHZ9p+bIwcbvscyjoeQoseqexGvEk67Z7ZShjNZBSlOe9/ COvkbTbltAc5JGb4dbfIQeDGeqT7Afx5+2kQzdtFE+5MBQAyMYuF/CeGe92BRgl0HMXwzi e5WDhGBxt8YYKl2wPyFHc+rHtYF7oeo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=zQaaIfDB; dmarc=none; spf=pass (imf19.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-2163bd70069so115030405ad.0 for ; Tue, 14 Jan 2025 21:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736920131; x=1737524931; 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=sHzEFJeIZDo3f5k/3U0rvOC8rXQluzySCipEOCSBJIE=; b=zQaaIfDBO81l0F2bFicIC+QbhjJRVF4G1m8HjRkLkro0URgH33mZJdZgQwQs2EVk// jS/5TZkXZqlQgXDDI0amsfhlhuW/vV06dWfVBuKYvtnlAEoYrd56KVeM7idM1t/tsxYg x69VSBvKCAww8H2zd9XI0XYc+K4Ww3AjSgOCc0lnqBDmrrl44Ce4TUDf+aiRSVefmIzk qaIHUFKMcYPtxpe+uHVVU6iamPJ5cMNaSj+6y1tIk05X2Cg1Fh9dCbxKx4dm0VuRbPwb GjbImt6dKpWduOeHS77dv9UbFR0L/gYTNddXWSDJ7scFuyuWUOftSGmhH7upId2H76tX V6Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736920131; x=1737524931; 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=sHzEFJeIZDo3f5k/3U0rvOC8rXQluzySCipEOCSBJIE=; b=u6pgj4QQmBnPhwDtpoQHvHv4r9pGOdpn0+i42l/Z3zIehieqb8i4+j6xaJE/Ae9LbA 7zssBP/b1/3dM48MP563wYOKUhE6gPqLi/90oF3a083u8P+X+wH1O+lzsYZcYJp1d63X n6Jl8y1pHSo5hrcL1Gl/1L7TTCNY2PZXVLcpPpn52U7wH3sqUtg85RVjPCjawAOTBNoi 6EGAmZ8jmAFiYesQKITEj0/I+LD496mRhFxlei+odaRa60vGhxFWvBy2n/anNxKH1y+R iKPQ10M+Kg204ciR3+4LLFODJYNiiTTdXEYAYQ+2evXq6kPosioFgkfEFbffmQatHnRT 0/2w== X-Gm-Message-State: AOJu0YwbizN2+m8Zgys3QHcQG8AUA1kjiU9k68wYFYBBX9kZ1Gr7Qk0R OeKTuJyKZqGxddFDGHOlethHejdGpJN6+gV28NNZOZyTPV00lXZq79BD+nqdDJo= X-Gm-Gg: ASbGncvxKEshbzU7fkyMXGPyTkFEIY++Ra2TFTB26Xsh5cn9EtRX0x2+trJ2r/W2kU1 hdMTMkJqzKZMw2FFeHARdwUfPGVOntXC1duC1J9U+dF76re3Qje7WvdfaWL9hLQpAB/t3mWqoim G1OQregFPnMuLvNb46a8Fq/2nalb8ul2QBJPRYO+ja/95Fcle/vs/7ivFZhYCvXf+Cv1EuJKV9B hKzwgpTZYlywhhwDwtJh9ykxxZ04q+pG9vQWHHZThOcpHAwDQCnazVkVh8= X-Google-Smtp-Source: AGHT+IE4WOueDadHkE/pTRlVlFsVpAiJG9FV/RBFhyadWkGkb4TxZaWQPSECPYbRg96If6idldoCOw== X-Received: by 2002:a05:6a00:9a3:b0:725:eacf:cfdb with SMTP id d2e1a72fcca58-72d22033ef6mr42478714b3a.24.1736920131167; Tue, 14 Jan 2025 21:48:51 -0800 (PST) Received: from localhost ([157.82.203.37]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-72d8bda6e9asm691573b3a.51.2025.01.14.21.48.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jan 2025 21:48:50 -0800 (PST) From: Akihiko Odaki Date: Wed, 15 Jan 2025 14:47:59 +0900 Subject: [PATCH v5 2/6] binfmt_elf: Use note name macros MIME-Version: 1.0 Message-Id: <20250115-elf-v5-2-0f9e55bbb2fc@daynix.com> References: <20250115-elf-v5-0-0f9e55bbb2fc@daynix.com> In-Reply-To: <20250115-elf-v5-0-0f9e55bbb2fc@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-Stat-Signature: 43tuiazxj3bxmu378jaydtdzgwotfgrm X-Rspamd-Queue-Id: 5E6221A0005 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1736920132-948355 X-HE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bIXakr+cEA5dfnnuBBpX0oj9GqA7mg9STXLF4mRnYgbonyju8UbCIW9LpwyE0VWK6UjuqLIp4TCJyi4kIHyOy+3gzTxN6UQqqR6O9PLQ/Uoseo7ZZyCzy5HlMndjO7sYecQzc91L/g9PnZINP4qDYJjpmwdb6iU1Hx2Kx/AgQVGjonL72zLAwLP/uSQ7OarEs98zh+QAZ9qw0Or8MdvoI/ij6KdCwl+9S8ABsyrLkJ41upLCvsNqol2RBqpJ/3oHZaAJtseFMc1l7sWVSRRLUE5sFXHGDwY12uqcbKz7uzsUpDEHUnd/JjMGPe8DcGTp1NQxShG/mjXvXZxRwAhh34+Va9p5cTl0rlQntV901xSRcpW4qUeb9UZ2yPgg== 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 Reviewed-by: Dave Martin --- 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 */