From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A88C3B8D68 for ; Sat, 13 Dec 2025 01:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765589072; cv=none; b=EKTgdZndWwJFYoHA72au+7oab7Ewtr4+AGIZPF7InuxELe8peJKHkIj8J7x9lD8LWKcZaXoM9KjZjVD6Qa+FWYMUcU5d31dbdDY7KasdLiCtCE67RPG8Onfc8mXuESBaXjYiCZKQSUAbXuI+TWwHOAXTXQW8GhR+E9NW70PJLNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765589072; c=relaxed/simple; bh=EfrRLbN7siAIW5Lk2yum2xDuvB6AvSX/kywDeMY0f84=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VQXdALo0Em36zefgI+vB+Ytzhv28OwsCzqmD0+3vAeTlOpVXMmCBZm/G3zZBWdgCUNkhuIdVpdqYT2Q9sBCbw2EN2AYLnCKraRtLC7LlwA3xYqbmQ+SJzVLN2c/vW9FwMx1w8eoUcoNo1CjiwO3Ns1nfCPO+DmcEcrKWmSoTQDA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ul02A4xb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ul02A4xb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C202C4CEF1; Sat, 13 Dec 2025 01:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765589071; bh=EfrRLbN7siAIW5Lk2yum2xDuvB6AvSX/kywDeMY0f84=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ul02A4xbWtH/1Vbe3HHLVi6kk4ZnCcM8E6NBilvIMKoOwKjGOUWbCNFP/gdlMCXKL /oFv1n6dQIdvETjyfrGxhsvZq2a9Poxs/ZwQVA+qjSR5ix09v2RpPz6FUw4BdIDJkG ZBHtLJlXMyhFT4RWHbUr2YkH31M91IaxeYfURxbHLIz1g/KyhTFQl+v9UwrihmIz2X 4TkqJGM5jxuBoyGbV/+1h9YZB4b+EDRWBH6xoGigus5cLk6+DcyAA30YankfK4zMQ3 W9VF2AL0o7IjFq+ZWzdhszfuTeONkcqtfdcwBmx2gJ8wx3BURwY7HOHcojO8CiaA2U VrEQT+j3WTlKQ== Date: Fri, 12 Dec 2025 17:24:31 -0800 From: Kees Cook To: Andrew Pinski Cc: Qing Zhao , Uros Bizjak , Joseph Myers , Richard Biener , Jeff Law , Andrew Pinski , Jakub Jelinek , Martin Uecker , Peter Zijlstra , Ard Biesheuvel , Jan Hubicka , Richard Earnshaw , Richard Sandiford , Marcus Shawcroft , Kyrylo Tkachov , Kito Cheng , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Dan Li , Sami Tolvanen , Ramon de C Valle , Joao Moreira , Nathan Chancellor , Bill Wendling , "Osterlund, Sebastian" , "Constable, Scott D" , gcc-patches@gcc.gnu.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v9 1/7] typeinfo: Introduce KCFI typeinfo mangling API Message-ID: <202512121709.F5617B17D@keescook> References: <20251210022025.harder.803-kees@kernel.org> <20251210022035.331892-1-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Dec 12, 2025 at 03:07:51PM -0800, Andrew Pinski wrote: > On Tue, Dec 9, 2025 at 6:27 PM Kees Cook wrote: > [...] > > +uint32_t > > +typeinfo_get_hash (tree type) > > +{ > > + gcc_assert (type != NULL_TREE); > > + uint32_t hash_state = 2166136261U; /* FNV-1a 32-bit offset basis. */ > > + > > + mangle_type (type, nullptr, &hash_state); > > + return hash_state; > > +} > > It might make sense to do a few self_test here instead of (in addition > to) having a testcase. > This way the testing is done earlier. I tried to do this back in v2 and could not make it work. See [1] for more details on what I found, but basically I don't have access to the parser itself in the selftests, so I couldn't build end-to-end testing of arbitrary C (testing node types isn't really a sufficient test in my view). I could to basic type tests, but it would be redundant to what I ended up with in dg, and I didn't want to split up the testing. If I'm missing some other way to do this, I'd be happy to give it a shot! -Kees [1] https://lore.kernel.org/linux-hardening/20250905002418.464643-1-kees@kernel.org/ -- Kees Cook