From nobody Thu Feb 12 23:02:49 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 226631C9B62 for ; Sat, 4 Jan 2025 14:38:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736001537; cv=none; b=fEcSaCFTCInKTKv28+qx0a1R3j0zijUA7mZlV/p2RFICmCJsayyfKjzfwnWucV4ATvufhZsog6tuqQoMlgSDN7OlC/8EIk09dEh9MXLmXusKb1lutHoLZJm+Fu57UGz7xu9febOFc6f7+aSKZlG8OwE1V3vz2RA5k6a3RFm7Af0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736001537; c=relaxed/simple; bh=/OUUxnpcfLbabaS+hxM83Ay0fmFB4YJ/y1+nmO20Xrg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qMJ7y17ImTIEPBKaLFSKUO8/aO/H3tB/hcnUtRNAXO0h8gZ5Gs7fVnLClOxUGgRt0Ea/vYydOL3goECA195IxkSYuljZ1TK83kMXPZq6U7IB8hLFxSCf3VCgv3CsOW9Ihoib0nVQ16TqbctMVsKxm6/CZvHHPd9ZcmNH5E3IaKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com; spf=pass smtp.mailfrom=daynix.com; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b=jWWapQid; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=daynix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=daynix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.b="jWWapQid" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21649a7bcdcso178992155ad.1 for ; Sat, 04 Jan 2025 06:38:55 -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=vger.kernel.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=jWWapQid+i3g538DHEcM0xAO8/0lhWkYiGvF0QrH9u/ds7npr53ZDlazdB/rA7wGiJ V7I2BLLJV9i0ebUDFLhZ0rrkfQ3JCEkoyy/N1Ld2ZH9AJQnkPWLXl/8e5q5PgOykUXS9 hbZXUJ/glNTsh9rrszUP7Pf2rar1T/36rqzJyrPflEGHvrKDcYLJtEC0OfXNmE4E0AOo 2cBjW4LVZpNDLZ5bmsvKQ8qjx8kBa0v2DlYRXOtPP0JSWHtvzaTUioJiW8Uwj+3LtZ5O 86GUWCjDNtHIkvx1WZ6o22+WCEzHzeUa2B1YGlgJw5VQW0Pdip82ymfUOCppvtZF3EDJ 6x9A== 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=BmcgEm2dxoujKlFQqFaFCgIzWTJW2MTJ2uE/LwZYZSuMz0uZKrpmrypBOgT7j/jeSo BWbUdH8jDVJWYKwiv833J+tX/EK5AA/UhUOafGajUIyjziZpfiUKJ7NaKfzpfXRnAKjn a+OBnMC573FvvMfGSllDUmbIkrctBQ3XO7kDYR89/JREo6pYulAjD7SWTr5LyPdJAIxc iMZj04YOT/+db5PMLzSX8jOMn/BVry0kO+f18SOIokIrXim7hdDvMegVXInB9Or4pf7q KOXp/+SHK+sH9MvwbD7dI9j46T7k/5wFYmF76xc6LQNvGBkQpwhEVY4LOnzW7JOf3x1/ ZelQ== X-Forwarded-Encrypted: i=1; AJvYcCVBtkm0/xMo99RwrRt3rylGODmvmY7cBnXpP2hwVQrYAQRfj8k8ulzpg1YP4ODVYukgSzT8LYmo5nzTDyg=@vger.kernel.org X-Gm-Message-State: AOJu0YzkbHbaju0aGtD86Y350Aswmi02XfxN+XNNao5axYPNjL2Ck2G3 av3RDJJppL/AMeVRPBkN2NfV6LBBQr+mVjg+Hp8JN064Xv3lzRaDPco/GwbEHXo= X-Gm-Gg: ASbGncvo7sklByYR5yGC/3FA4ZPiYipLUIwEI+f6azD5NL8f/gt+N1DwjxCvS9Fy4KN x5yZ/oL9+tieQCkO2GgiQgVeWUfZIesJVrcjAA6z91VGoLhrpeTssb2EQeca6vMZqd6Gn8TcXRZ 34CKTQHr0KHUxgkOdxR5sexj3rfIP1xWNTa8LjjX9yvF6WAXjl65j5VJnPjvoUf0xl5eKoFlI0e 1I55Tm1i2buUSJfOwi862ieU4eUHo/c7UnXNmxfE5Dlhiqa2fnzzNGDbBRJ5yc= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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, } =20 #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)) =20 static int parse_elf_properties(struct file *f, const struct elf_phdr *phd= r, struct arch_elf_state *arch) @@ -800,7 +799,7 @@ static int parse_elf_properties(struct file *f, const s= truct elf_phdr *phdr, if (note.nhdr.n_type !=3D NT_GNU_PROPERTY_TYPE_0 || note.nhdr.n_namesz !=3D 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; =20 off =3D 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 +=3D 2; while (auxv[i - 2] !=3D 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); } =20 static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csi= gdata, 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); } =20 /* @@ -1706,7 +1705,7 @@ static int fill_files_note(struct memelfnote *note, s= truct coredump_params *cprm } =20 size =3D name_curpos - (char *)data; - fill_note(note, "CORE", NT_FILE, size, data); + fill_note(note, NN_FILE, NT_FILE, size, data); return 0; } =20 @@ -1767,7 +1766,7 @@ static int fill_thread_core_info(struct elf_thread_co= re_info *t, regset_get(t->task, &view->regsets[0], sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); =20 - fill_note(&t->notes[0], "CORE", NT_PRSTATUS, + fill_note(&t->notes[0], NN_PRSTATUS, NT_PRSTATUS, PRSTATUS_SIZE, &t->prstatus); info->size +=3D notesize(&t->notes[0]); =20 @@ -1801,7 +1800,7 @@ static int fill_thread_core_info(struct elf_thread_co= re_info *t, if (is_fpreg) SET_PR_FPVALID(&t->prstatus); =20 - 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); =20 info->size +=3D notesize(&t->notes[note_iter]); @@ -1821,7 +1820,7 @@ static int fill_thread_core_info(struct elf_thread_co= re_info *t, fill_prstatus(&t->prstatus.common, p, signr); elf_core_copy_task_regs(p, &t->prstatus.pr_reg); =20 - 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 +=3D notesize(&t->notes[0]); =20 @@ -1832,7 +1831,7 @@ static int fill_thread_core_info(struct elf_thread_co= re_info *t, } =20 t->prstatus.pr_fpvalid =3D 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 +=3D notesize(&t->notes[1]); =20 return 1; @@ -1852,7 +1851,7 @@ static int fill_note_info(struct elfhdr *elf, int phd= rs, psinfo =3D 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), psinf= o); =20 #ifdef CORE_DUMP_USE_REGSET view =3D 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_stat= us(long signr, struct task_ regset_get(p, &view->regsets[0], sizeof(t->prstatus.pr_reg), &t->prstatus.pr_reg); =20 - 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 +=3D notesize(&t->notes[0]); @@ -1415,7 +1415,7 @@ static struct elf_thread_status *elf_dump_thread_stat= us(long signr, struct task_ } =20 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 +=3D notesize(&t->notes[1]); @@ -1530,7 +1530,7 @@ static int elf_fdpic_core_dump(struct coredump_params= *cprm) */ =20 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 +=3D notesize(&psinfo_note); =20 auxv =3D (elf_addr_t *) current->mm->saved_auxv; @@ -1538,7 +1538,7 @@ static int elf_fdpic_core_dump(struct coredump_params= *cprm) do i +=3D 2; while (auxv[i - 2] !=3D 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 +=3D notesize(&auxv_note); =20 offset =3D sizeof(*elf); /* ELF header */ --=20 2.47.1