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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8902FE77188 for ; Wed, 8 Jan 2025 04:34:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20F486B0082; Tue, 7 Jan 2025 23:34:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BF6C6B0083; Tue, 7 Jan 2025 23:34:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05EF26B0088; Tue, 7 Jan 2025 23:34:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DC7DB6B0082 for ; Tue, 7 Jan 2025 23:34:34 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8A7671C8127 for ; Wed, 8 Jan 2025 04:34:34 +0000 (UTC) X-FDA: 82983018468.26.27458C1 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf25.hostedemail.com (Postfix) with ESMTP id 79282A0009 for ; Wed, 8 Jan 2025 04:34:32 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=RvLC7W1q; dmarc=none; spf=pass (imf25.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=akihiko.odaki@daynix.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736310872; a=rsa-sha256; cv=none; b=qqTUcb+yke8GBAasJ40XqdfVqDaiKrVS2d/YMTorlRyjjIjlQ1Y/1OYi9WvjWROmYEY0Bk Jmr5D0MhVQJ5/KUBRzqY7krRuvYHJFGhwWiQPqgQ+ctrd1z2bC/mR+qk7bNn0Au1r0UCUX crl25QNP3+I3mT0YZtMTeBllI3MAMtU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=daynix-com.20230601.gappssmtp.com header.s=20230601 header.b=RvLC7W1q; dmarc=none; spf=pass (imf25.hostedemail.com: domain of akihiko.odaki@daynix.com designates 209.85.216.51 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=1736310872; 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=l5qyePdTQsadGlhhkm88UTLOJyB05IwMsFPhm2KKy5k=; b=WB+wj3QjINkNYDzC7/f/v3e+Vnlqz9ZmgG9mwlCxoHyTRYoJqVKDncoH9g8mpI8hRA9STp 54QvmeYOQjQ68D0gW66+XbOLqZq3Q/Qp+z3wt4MYrkwLw0Y7inLz3g+gZvkULU19zabGCx 8zIE3JhYqFU696SHSSlQfwmBeqciPfw= Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2efe25558ddso18418155a91.2 for ; Tue, 07 Jan 2025 20:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1736310871; x=1736915671; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=l5qyePdTQsadGlhhkm88UTLOJyB05IwMsFPhm2KKy5k=; b=RvLC7W1qdCLHmnaLPNyonEn/dm3ADXrDpqWAh8SqhJ1IoaX2dgGfnKg6ENOwxY0GFZ r8CGNT53Uy1b8/ih11Pb5U2jQb2Zz9+SGfYAlOOo/MRb3nrYYfIGnsKRO46rMcAOnmGa UO5LQeTZSYdsFqckbxdQeO3lrAjg8QR8kDvtyVOGqyBD9pRmX/5vFGR215Ul+c6Ozdze 2CiFvtdU9NLttcYQe0/WVZDoyg52GAu4X/X2HXVnM+rh6E52lfJhT+BTMKIcL6KisUN5 iXWXDjjQ0J8RFt6NZTVVw/aJ4rkjGswDvTtwldLWNwbaQWEw2SzM1HA2PtjS6UMm+r1m wjBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736310871; x=1736915671; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l5qyePdTQsadGlhhkm88UTLOJyB05IwMsFPhm2KKy5k=; b=tqH6bApCh3ttZbCgaPx5HEzd/Pw+6jzQE/FpttVPIFMVLVVukdH2Yg7kf6tl6oJFfg CXQJ2G0WeGGs3H1jeGcW13BZ0BObebFX8Mr7wfK30yZ4YVZ98aCZTjGb2CqxeDRYRc1q lT+63hfk0IDln44uoEjugpQZjoO8sh+9p1oE3F/i4IFskPjbLQl8t5b/Fz66dF2NDQIx mu8R9oKtGCmIB/qwcgyyXNhOF944tAHyDnzOWx54z7EZ2eG82jxDMBGAUdSLM4n50Bev VGyM16ilKjUGNDCrVhG9D0nib58zRuEpg7ChnPybTEd6Z7cvm7MGgz+P87vJQzLGgND0 t02w== X-Forwarded-Encrypted: i=1; AJvYcCUOt3M6iB6CbsrB+7I/Q4rSaCO7qiF7uuXYZomvCIT0lZt3LpY8tTr6VMZKQgUE59fYquMR0uJdhQ==@kvack.org X-Gm-Message-State: AOJu0Yyg7gQZamKcoNPcjtdDF7K960SDRvu6LphKZPIjadhRR5Oji9k6 yJrFJNaxJIXniEUz23KqvGIR4uT9Zch8Awd0saRz+ES1wj5I88oyJW/lGKxdk/s= X-Gm-Gg: ASbGncvI2GrZgitgPL35ZXJO8q+bWNttxV3362WfSan6ii4I/3XGY83PgvZd+F2mhlU 1NjVsh3tvOgF+qkGRHwN9w1pKu0gMuyp9f90EyFAQpEjJtBhM1z5SjECI07P/wyYv7nkkYiMcGK JKpc6S5kXKSSdP7Oe1YL0Xw9voNI6PSx9pTEI7c6ifEiKIB4ARByzRcucYBQsSqC5g+wtJ7uatd BbdMMuOCzgCGDBDA5+xXMwCAs9magZaeQSj5+JhE0q57ubZDTGMeM3USjVhwOjTRYo= X-Google-Smtp-Source: AGHT+IGQRKZLowOpLDJxDKDC4Zdlnk/imeV0cILJj+G12S7tUJ9/SfK9Sf0wRtST8EIlv//HMUuIqA== X-Received: by 2002:a17:90b:3bc4:b0:2f4:43ce:dcea with SMTP id 98e67ed59e1d1-2f548f1edafmr2196020a91.25.1736310871016; Tue, 07 Jan 2025 20:34:31 -0800 (PST) Received: from [157.82.203.37] ([157.82.203.37]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f54a34d91bsm448853a91.32.2025.01.07.20.34.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 20:34:30 -0800 (PST) Message-ID: <2c6f2c95-b2fc-46e0-91ce-1b9f14b28d3d@daynix.com> Date: Wed, 8 Jan 2025 13:34:24 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/6] binfmt_elf: Use note name macros To: Dave Martin Cc: Eric Biederman , Kees Cook , Catalin Marinas , Mark Brown , Baoquan He , Vivek Goyal , Dave Young , 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 References: <20250107-elf-v3-0-99cb505b1ab2@daynix.com> <20250107-elf-v3-2-99cb505b1ab2@daynix.com> Content-Language: en-US From: Akihiko Odaki In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 79282A0009 X-Stat-Signature: cz4frxx8ai3hubbwjozoxesk1uxxdc51 X-HE-Tag: 1736310872-703024 X-HE-Meta: U2FsdGVkX1/IyXtp3WRQUOwlLm2TVRqa78xl5TIXAM4q0ojrxzHQTemXje3h9kygDNlKGqNcNpP08qc4RP4gBD6ntrFuQGwj2jdC2Zq9gIuZVCFFl4hItRBVQS2QqxSsjk+yL0ESNbeNkNtvFwjO51Oz0SW0TkIuAUy0WpUDzBZQo9xBLgOQY6Uo4SCLxfPOCV/Resm2xH9mlKKLfD2NswnT+ryofv87tLE/STNgclLdXEmaJAcMXAlddRtO5mMD8eDjN+8oR4w+A5KyacGGe9O3UXfEn9vFTvncSzRiycfE0Eji43U6mSY57RD6CbK/yM7jIL204jMEEy0HGepL8nlCKlf9dtZJP8yICSeXST0NP+FrnxEOLMPVcdq/8wOACus6aHFATobenBVf0DDZ6joz234CHoIH5b5QR2YWc31BlT+It52phPxF6RaG6+mKIoirzsciqs/L9W2N7eTK6NqPrG5s8n3zg0SzeEVuZFQAW6xLC2yihSiomXFGEa4kGz6uBYPY212P3EzcjxVUOpg+jhB5ppyealZ6/pcn+lEl7FmwhqPww7Dyuw7CMJEVb/iuM9bzzkmrne2J9l+x/j48pnQ3fkLz2Ucf2SZxFJF+dJgMg91Z6Sr7IenBTWgRcCGUJZZKULzWezU6geDxbTPqlKJWvL8iebDYOPGJAOSpGK8WZtkbNsd3DsWjEbaLUWoKHfvOFZvJfNXXXsZOy+4RFh0HEnJI8P6H25zLRYs3uefRbOdqHCKObwALu24OnIFmvhSsU7ZvbG375CL37ouqUOKhuJTchhfDzhdJO6SXoAVSktE/9h38EslUZWEQf4LCrqB+LneWMNT8He74DJ60m+DFzo7LZ2XJZ4Aa9iigObXjBcxmZhY06mdSz6hYb6TN36BYd0UvmjFG0YLqbs+Er0hRZHAVv/J5XXp7qWLulyVAZmTqs4hPUkxqn4SsdO98tIYprXrLmtGmr/M tjfHlAxm MyD46P8DK+HkeWDK1FnpEfKl1mfe2adEv1/YYP4TiE/4QlcI5C5nAepmt14Z5OvA4tYB3PLHkoF0Wmy9cxoWnR6iesyriXXUX6kuY+0ojSEEdujgTZ4/p2bq9cMTzI1rvf2d073RZK2fWQPXaxrKEPDVMR+FBtCJbDh6R7poQY9OWwM4v6h7RmcAToJcOSjI5klaxplrkhJKNOfti43nKkf7C2em23w0niWvoa3ZE1NZwGeBao+F8a6Al8W+qQlclwloybTcEmi5tiCihO4adT4wnZOf0ItPzcvGTOD1EhWgDEeXlyPkYhs7FHmFeQpkSkOtfAp32ciFUx7DE59ayseqfit98ZQD3yiFlca5/sjBu7b7fZdzb5ViB1P6SzX6kfReRkoOYouMmBNxOhkGc5e2MujSGluBTB0AuofqTyp8iz5T+jXejQYGy4SgONNLU+9K/+6idQZLCMcuBMYY/HbpiFYYPw9VJHdmf6wsPUPYkkDA= 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: On 2025/01/08 1:18, Dave Martin wrote: > On Tue, Jan 07, 2025 at 09:45:53PM +0900, Akihiko Odaki wrote: >> Use note name macros to match with the userspace's expectation. > > Also (and more importantly) get rid of duplicated knowledge about the > mapping of note types to note names, so that elf.h is the authoritative > source of this information? > >> >> 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 > > [...] > >> @@ -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 */ > > Looking at this code, it appears that the right name is explicitly > taken from elf.h for a few specific notes, but for those that are > specified by the arch code (e.g., in struct user_regset entries) the > name is still guessed locally: > > static int fill_thread_core_info(...) { > > ... > > fill_note(&t->notes[note_iter], is_fpreg ? "CORE" : "LINUX", > note_type, ret, data); > > > It would be preferable to clean this up if we want elf.h to be the > authoritative source for the names. If we want elf.h to be the authoritative source, yes, but I like the current form as it ensures nobody adds a note with a name different from "LINUX" and it is also simpler. There is a trade-off so I'd like to keep the current form unless anyone has a strong preference for one option. Regards, Akihiko Odaki > > It would be possible to add a .core_note_name entry in struct > user_regset, and define a helper macro to populate the note type and > name, something like the following: > > struct user_regset { > ... > unsigned int core_note_type; > + unsigned int core_note_name; > }; > > #define USER_REGSET_NOTE_TYPE(type) \ > .core_note_type = NT_ ## type, \ > .core_note_name = NN_ ## name, > > ...and then replace every .core_note_type assignment with an invocation > of this macro. A quick git grep should easily find all the affected > cases. > > > Alternatively, as discussed in the last review round, a helper could > be defined to get the name for a note type: > > const char *elf_note_name(int Elf32_Word n_type) > { > switch (n_type) { > case NT_PRSTATUS: return NN_PRSTATUS; > case NT_PRFPREG: return NN_PRFPREG; > /* ...and all the rest..., then: */ > > default: > WARN(); > return "LINUX"; > } > } > > This avoids the caller having to specify the name explicitly, but only > works if all the n_type values are unique for the note types that Linux > knows about (currently true). > > Experimenting with this shows that GCC 11.4.0 (for example) doesn't do > a very good job with this switch, though, and it requires building > knowledge about irrelevant arch-specific note types into every kernel. > I think that extending struct user_regset is probably the better > approach -- though other people may disagree. > > Cheers > ---Dave