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 0B29DE77188 for ; Mon, 6 Jan 2025 16:48:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EC2D6B0082; Mon, 6 Jan 2025 11:48:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 49BDE6B0083; Mon, 6 Jan 2025 11:48:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 363306B0088; Mon, 6 Jan 2025 11:48:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 155B36B0082 for ; Mon, 6 Jan 2025 11:48:12 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C37D81A1492 for ; Mon, 6 Jan 2025 16:48:11 +0000 (UTC) X-FDA: 82977609582.21.F111BFB Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf01.hostedemail.com (Postfix) with ESMTP id 2FAF340015 for ; Mon, 6 Jan 2025 16:48:10 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IsijK6UW; spf=pass (imf01.hostedemail.com: domain of kees@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736182090; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FyJ5AfCFZjEgs/ThYKbNaUoqxERTMbozAAc583jmNxY=; b=ebG4U0Kb6/aFeMkW2e21cdUil0rC+GeZiel31paD+N0gorxQATeyB5Kopri70ZrJ+Xk+g1 9+agS7XBV7gDOHJfVVqpYeyEo0X+gN5LToJgyEPqmruDyb9bxObfEpJwI6spaJn2+1RYDU tGpUJHN6kM2mdWDK5Q3u9vqV3fQUP8Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736182090; a=rsa-sha256; cv=none; b=foYEK5Ho0zK5bw5c+3FYvOUBHpjnsrHHkOLCcrOQt1/sLJLx7H0QSuyLPI5aFlSU8tx0mX MXqnGj0tu9n58T70j83bcjSi2WdDuV0FCwZqYSpwqnZEGM6A3MWb0x0oTgJmOiSRg8YCu4 IdClptar+7Ws1hqQZrVtwbEm8uioHsc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IsijK6UW; spf=pass (imf01.hostedemail.com: domain of kees@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 6FB71A41B22; Mon, 6 Jan 2025 16:46:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDDD3C4CED2; Mon, 6 Jan 2025 16:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736182089; bh=HEO2MLf1VHgRzbREgQgzMwKlNqe5Agqt4kRQTnCkfOk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IsijK6UWM2KPMQJBfvl+vFx8bFrxXhTGRtzqTu1U2GAZFVUO1R/FJBcV18ZANjRcC 79g4z7UqwfAkLa7S41BW2+teSCP+ZIYOvvDEzSZxcH+vLnCV/J2IoXM4jk3IvKDLBf zu++zuSzxQgAhJ0KmjLlPp2Vi/5h2VIe3LtNVEImtJ8t3KXkVu4FqE/Z27xA7sS2et CYtIgvEMF2tm20TeugiUA6L8m3n4Lsfuo/Hdenv4NP7hoLTCSys9LUdUKAACMYF4iP CfYhKGTpqBSWtli/1njZ/oNSHQS6ghcSospxSMXFD/xqHxEc/H/I31p0f17xEtsQsT SCLecFPd/gdgA== Date: Mon, 6 Jan 2025 08:48:05 -0800 From: Kees Cook To: Akihiko Odaki Cc: Eric Biederman , Catalin Marinas , Mark Brown , Dave Martin , 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, devel@daynix.com Subject: Re: [PATCH v2 1/5] elf: Define note name macros Message-ID: <202501060830.B735C3A@keescook> References: <20250104-elf-v2-0-77dc2e06db4e@daynix.com> <20250104-elf-v2-1-77dc2e06db4e@daynix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250104-elf-v2-1-77dc2e06db4e@daynix.com> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2FAF340015 X-Stat-Signature: gwbxdircm365iw9cju5hbaqa6fkpp4ft X-Rspam-User: X-HE-Tag: 1736182089-563856 X-HE-Meta: U2FsdGVkX1+1Us6cNNXjSPzM4H+2Qc2q06pPMxKzRKgSJe/rC7fGdBZp08/Up1cRXWpZFThv3fv8uavx83i6sr3J3d3R/O6dE1w4rYgHkmmLPsMOh0n4QGzBAvN0z4rhUpfIDLkjKM3V0ywguk6NwK8wZ9ZtEr5+D3t5HXhTV4Qliylga9EpcxdaI8QUFlOpc+Lhl9cHBI+PW8nMnUR2KsJoDv7EhX6uXqTCR+3nt3jxNIy4i8T+c9afPjs0DMc3oAhcOyVMwYYmnFFtxO3w8h3k9qmpvZy6iyxXmIFgwNuv4PSm3dEIS+c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5sYNABiXN+AnKkQ= 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 Sat, Jan 04, 2025 at 11:38:34PM +0900, Akihiko Odaki wrote: > elf.h had a comment saying: > > Notes used in ET_CORE. Architectures export some of the arch register > > sets using the corresponding note types via the PTRACE_GETREGSET and > > PTRACE_SETREGSET requests. > > The note name for these types is "LINUX", except NT_PRFPREG that is > > named "CORE". > > However, NT_PRSTATUS is also named "CORE". It is also unclear what > "these types" refers to. > > To fix these problems, define a name for each note type. The added > definitions are macros so the kernel and userspace can directly refer to > them. While ELF is specified in the Tool Interface Standard[1], the core dump format doesn't have an official specification. It does follow a lot of agreed rules, though, and the "note name" is intended to help coredump consumers distinguish between "common" things ("CORE") and Linux-specific things ("LINUX"). I think this should be explicitly spelled out in the UAPI header, even if we have "mistakes" for this mapping. I'm not convinced we need these macros, though: everything is "LINUX" expect the common types. And the GNU types are "GNU". There are only 7 types under the "CORE" name. :) For the macros, I'd much prefer NN_CORE, NN_LINUX, and NN_GNU. If you really want to be able to examine the name from the type, then yeah, I guess we need something like the macros you have, but I'd much prefer also adding a macro like Dave suggested[2], and then replace the fill_note() with a macro that can unwrap it: fill_note(note, NT_SIGINFO, size..., data...); The repetition of NN_type, NT_type doesn't feel robust if we have a programmatic mapping: only the "type" is needed to determine both, so why supply both? -Kees [1] https://refspecs.linuxfoundation.org/elf/elf.pdf [2] https://lore.kernel.org/lkml/Z3vuBTiQvnRvv9DQ@e133380.arm.com/ -- Kees Cook