Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp969136rwe; Fri, 14 Apr 2023 12:11:04 -0700 (PDT) X-Google-Smtp-Source: AKy350Zl5TZB+UxsLFsd3tKQkNaDxxghtFi7uhp+gprC//lrFXrJ1uEzXCs9/W1n67YeexPfe1FK X-Received: by 2002:a05:6a20:2591:b0:ed:ec5b:cf8a with SMTP id k17-20020a056a20259100b000edec5bcf8amr3851810pzd.15.1681499463790; Fri, 14 Apr 2023 12:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681499463; cv=none; d=google.com; s=arc-20160816; b=u0POmdhzwkQ0piiUOl/D7QdSRN9lUccoW4YyyL+zzww2Q+xHZg5eq+vkhUzLwUHmDb 0zaf3VPdHzOpesFyBAsriix42ja0/jep65SWpt6D9iraLLeXXouRIgX3y7SdoEnW/kYv UETjc8RAoP+fUF0ZP+NIcWu2uAtN3CQmAhCRzI3tQLIcaPLlGjpFtmr8Ub0mYsuldU6B iyN4bAW/sA2NJ6/szzpDcIDoArzMfKvK7Ms+l9MIorpnrNFJclHw3TiccMHoOkQIZ/Qp T0Vo26iZk1MhbAS4rY7e89SYXCHQfVX875M7g4HWkIlWohQIEyDJkFl7oFanhmGbgy13 fs4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=G8SvSIlTZSEKBVP1VHKzBYghgNS+3SNFw7w5pBhPymw=; b=jZhSu+3Qxm9DovBn8Uxkmpg7dMePTeCYxSi1wPHRCvvm/+7G/q/1z54yLKkpTiajun vYswIhixevLSbC4XHMK4fhVRgdP572cNSDUNhr2NkgRjVzJP9G06FAmiTrskyidRXFbG oPB70QCbAmpAxCbtzQgoHuNS1S8IOy5dmKmLhbKomn1ees4vLsV0z45IsSUD0eIMz9sU kNMXdtbvIpoYkUKHDbqLXcVq1ozpBQaGw/mRaZtQnpksvk4TKpaJRc0tPd+nfw1ufh6w Ant+pHfBplk5CtiBAfwHFgiwruTdG/BpMXSunwvH0CkVle4kQL8fc6swYzHJ3EmXWeaS gFDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="d7NqpW/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 143-20020a630795000000b00513185220f0si5463839pgh.709.2023.04.14.12.10.52; Fri, 14 Apr 2023 12:11:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="d7NqpW/j"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229864AbjDNTJG (ORCPT + 99 others); Fri, 14 Apr 2023 15:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjDNTJF (ORCPT ); Fri, 14 Apr 2023 15:09:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23343F5; Fri, 14 Apr 2023 12:09:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B26C864941; Fri, 14 Apr 2023 19:09:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FDBBC433EF; Fri, 14 Apr 2023 19:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681499343; bh=8+ul74ZOMPCS9hfly4Btg1dktvKcVkcKPgQLuyGVrSc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d7NqpW/juNRjpXma8oVlbDfAIehEEZ1EhICsU4T4QzgIg9YAqWTqr3zCyrkth0awX pah4hp2eVg06zve9pJ8HqJA8hJnXNdz9tlKqsZLDOLg4w7SMceK07jeTLGOfgg1Vdf nglfKUf5VZDs8Zn/achnWXYxrhKlhqk9Wh7WcsExotAz2OeASTQwVe2mivL1P6KFiA b+8OgM066vExi1h+E/9BjAY4Eo7gNMBsBolG1GBJ9ep3NG/PY2jW9cTF0ie1rVLfGi Tol3SAq1do87ctDPOo8GMIN3gjeer6X2Q7YIeACAPmDWzDE5yBOyZ8on77qLn/NVua UmuRaO4JIOPtA== Date: Fri, 14 Apr 2023 12:09:00 -0700 From: Nathan Chancellor To: Arnd Bergmann Cc: Arnd Bergmann , Andrey Ryabinin , Masahiro Yamada , Nick Desaulniers , Marco Elver , Nicolas Schier , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Tom Rix , Andrew Morton , Michael Ellerman , Peter Zijlstra , linux-kbuild@vger.kernel.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14 Message-ID: <20230414190900.GA1277152@dev-arch.thelio-3990X> References: <20230414082943.1341757-1-arnd@kernel.org> <20230414162605.GA2161385@dev-arch.thelio-3990X> <24ebf857-b70d-4d94-8870-e41b91649dd1@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24ebf857-b70d-4d94-8870-e41b91649dd1@app.fastmail.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 14, 2023 at 08:53:49PM +0200, Arnd Bergmann wrote: > On Fri, Apr 14, 2023, at 18:26, Nathan Chancellor wrote: > > On Fri, Apr 14, 2023 at 10:29:27AM +0200, Arnd Bergmann wrote: > >> From: Arnd Bergmann > >> > >> Unknown -mllvm options don't cause an error to be returned by clang, so > >> the cc-option helper adds the unknown hwasan-kernel-mem-intrinsic-prefix=1 > >> flag to CFLAGS with compilers that are new enough for hwasan but too > > > > Hmmm, how did a change like commit 0e1aa5b62160 ("kcsan: Restrict > > supported compilers") work if cc-option does not work with unknown > > '-mllvm' flags (or did it)? That definitely seems like a problem, as I > > see a few different places where '-mllvm' options are used with > > cc-option. I guess I will leave that up to the sanitizer folks to > > comment on that further, one small comment below. > > That one adds both "-fsanitize=thread" and "-mllvm > -tsan-distinguish-volatile=1". If the first one is missing in the > compiler, neither will be set. If only the second one fails, I assume > you'd get the same result I see with hwasan-kernel-mem-intrinsic-prefix=1. I did not look close enough but it turns out that this check is always true for the versions of clang that the kernel currently supports, so it could not fail even if '-mllvm' flag checking worked. $ git grep tsan-distinguish-volatile llvmorg-11.0.0 llvmorg-11.0.0:llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp: "tsan-distinguish-volatile", cl::init(false), llvmorg-11.0.0:llvm/test/Instrumentation/ThreadSanitizer/volatile.ll:; RUN: opt < %s -tsan -tsan-distinguish-volatile -S | FileCheck %s At the time of the Linux change though, we did not have a minimum supported version, so that check was necessary. I wonder if LLVM regressed with regards to '-mllvm' flag checking at some point... > >> # Instrument memcpy/memset/memmove calls by using instrumented __hwasan_mem*(). > >> +ifeq ($(call clang-min-version, 150000),y) > >> CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1) > >> +endif > >> +ifeq ($(call gcc-min-version, 130000),y) > >> +CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1) > >> +endif > > > > I do not think you need to duplicate this block, I think > > > > ifeq ($(call clang-min-version, 150000)$(call gcc-min-version, 130000),y) > > CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1) > > endif > > > > would work, as only one of those conditions can be true at a time. > > Are you sure that clang-min-version evaluates to an empty string > rather than "n" or something else? I haven't found a documentation > that says anything about it other than it returning "y" if the condition > is true. Yes, see the test-ge and test-gt macros in scripts/Kbuild.include, they will only ever print the empty string or 'y'. Cheers, Nathan