From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 045CE1DFE4 for ; Thu, 26 Sep 2024 00:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727308859; cv=none; b=dAybs0U+g1aZQdcUk6+gcLssaFx9Tt60ss3nEw4S7D0PQF6/DXj6Ea29Jh7EPCOzfIKN1eJE3L7t2y2QxwB4Qk+HGce3VVHFJwlokguSMNOiKVnMXr+l0lOrShDn+2OGtN1jBDNpkFcbzFNfVWKW5ip4ocLUMyVcWMHEoW6BRoU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727308859; c=relaxed/simple; bh=BRlZIBO2y/xAVIRFSMfbTOWt4y/TMHCA4wppJ2Xy5Xw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UpYZO6OA6bKP08HCSY9v4iY4Aij5KBK77ki049rhBDK4WbxuKgk4++JnXGHF4rQlZGDfRb+gzCf3UIrFhMU9Wa6h27vRor+A4fYZVD8tZTeZ/NWxbzr9BKQZ4g5KuYkwcBft8fJ9oi0HYlXqfxYvAvXC1zxyQcg+RY+sM4ycaNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=faHDMdSv; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="faHDMdSv" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2077b48cb09so82505ad.0 for ; Wed, 25 Sep 2024 17:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727308857; x=1727913657; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=cPuMIPtkFUqqXprChJbKt7gTP4JuGanqczP3oBY5vrw=; b=faHDMdSvbX8rqqyfay0OhfYhvUMXi193BkGEo8FEYdNM94AleaUsNar64tqQSmjWS2 iwq4kI93R+4iTc8cb3XKyEEw1WwosTeeImZFvIQZB8nL7OJ7gfoY4L+l6RVG/cZ3DqM1 IidRJMKuV9P5w2/NvZSLMIKil6wURI30fezkXjOrDKcslJUQbzOBHyTWWo0JlZjmvAN2 XLK4jJU/nSgjvTs6al8UHiKTJjQUWsbMj0RVfCyxtzfydeCzhNwJwtsGqhQNz/CfTAGJ rZN9Jt2Yurxr6pfLezelNVYaXeQgLhAGXbvQzFf3W3IZPHLUBoFwcE4W1d80ZASOG3Gg 92HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727308857; x=1727913657; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cPuMIPtkFUqqXprChJbKt7gTP4JuGanqczP3oBY5vrw=; b=OyF5npV6iR2UZH/2Rptnp30pGzihi//v68ZqNZZmFaQgUBIitxGQED1YCoZpvWC10B qX4rqrunkbQIs0GxTVwnHli1T4HmKyPbc5hMdKiIk4X43stlyGwpEW3xGI6wgc0ucUeT viNhX0MAk2sU65aKHjyZoMtTtc5Oy1t3DyExfL41AIsTAlgeAZJ2nxHsJwsG9z03x+hb E7IAItlI4chk0NRaRBSwTRYW4a0cvzhyOEBo/WuPvwcwd6mGigzTnwoQXMs9PgDQk5o6 KjbzGxomLkLsgD6dKVtPs0O0Ytce7GMKZW6Gmni3uwbRCX9hoqcuvmrQn7jz/6gjFvmw 0vvg== X-Forwarded-Encrypted: i=1; AJvYcCUmeA2q3Mtttm+HgMdvKWB5+sG0jv4smiA1z0YF1x9OamGu0GloDh41RhDAr9j45l1ls4D7iCwXhKrDNVg=@vger.kernel.org X-Gm-Message-State: AOJu0YzoEPJsRHCfcNif2Qu41SUe9TGO3Uqfn+/YEQ5j3+TVz6vVkinQ vCgSbKNVzglA1ffisYV+M6UVFw3bui8eSFrqQYwy0GCME+KXr02a5ZP92XMTVw== X-Google-Smtp-Source: AGHT+IFhjnkWy3FRA/CwSvG5CGnMdRcwTo96YK+0WkkTkGo3zIVuPlKKZn2oyrmo/1I+PT8z7lwKjA== X-Received: by 2002:a17:902:d506:b0:20b:b52:3f7c with SMTP id d9443c01a7336-20b1b47470emr1341395ad.18.1727308856775; Wed, 25 Sep 2024 17:00:56 -0700 (PDT) Received: from google.com (164.135.233.35.bc.googleusercontent.com. [35.233.135.164]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20af17e1806sm28912165ad.166.2024.09.25.17.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 17:00:56 -0700 (PDT) Date: Thu, 26 Sep 2024 00:00:53 +0000 From: Sami Tolvanen To: Alice Ryhl Cc: Kees Cook , Nathan Chancellor , Miguel Ojeda , Masahiro Yamada , Gatlin Newhouse , Peter Zijlstra , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev, linux-kbuild@vger.kernel.org, kernel test robot Subject: Re: [PATCH] cfi: encode cfi normalized integers + kasan/gcov bug in Kconfig Message-ID: <20240926000053.GA3188344@google.com> References: <20240925-cfi-norm-kasan-fix-v1-1-0328985cdf33@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240925-cfi-norm-kasan-fix-v1-1-0328985cdf33@google.com> Hi Alice, On Wed, Sep 25, 2024 at 08:10:18AM +0000, Alice Ryhl wrote: > An alternative solution is to inspect a binary created by clang or rustc > to see whether the faulty CFI tags are in the binary. This would be a > precise check, but it would involve hard-coding the *hashed* version of > the CFI tag. This is because there's no way to get clang or rustc to > output the unhased version of the CFI tag. Relying on the precise > hashing algorithm using by CFI seems too fragile, so I have not pursued > this option. I suppose there would be no need to hardcode hashes in the test, it's enough to verify that the hashes for the compiler-emitted functions change when integer normalization is enabled. Still, I agree that this doesn't sound worth it in this case. > diff --git a/arch/Kconfig b/arch/Kconfig > index ee58df8b1080..b8066bf43153 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -829,7 +829,7 @@ config CFI_CLANG > config CFI_ICALL_NORMALIZE_INTEGERS > bool "Normalize CFI tags for integers" > depends on CFI_CLANG > - depends on $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers) > + depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS > help > This option normalizes the CFI tags for integer types so that all > integer types of the same size and signedness receive the same CFI > @@ -842,6 +842,22 @@ config CFI_ICALL_NORMALIZE_INTEGERS > > This option is necessary for using CFI with Rust. If unsure, say N. > > +config HAVE_CFI_ICALL_NORMALIZE_INTEGERS > + def_bool !GCOV_KERNEL && !KASAN > + depends on CFI_CLANG > + depends on $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers) This looks reasonable to me. Thanks for the fix! Reviewed-by: Sami Tolvanen Sami