Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4166522pxk; Tue, 29 Sep 2020 16:46:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFawwJCYIFjJZJZryFSGARvBd+KeXnDAwMlb9//1UHB445himjTOAClAb/pKhvxGXXAdcq X-Received: by 2002:a17:906:33ca:: with SMTP id w10mr94178eja.438.1601423189562; Tue, 29 Sep 2020 16:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601423189; cv=none; d=google.com; s=arc-20160816; b=i17nXG7AwIBBXjKg7mTYqUlR62E+f4Ns7Nik7tjYqDFxOzYrXQkpZDoahedJfrBbaH 1M8d6rhSYpJlWLV+zXx7TF9/MXNnBscK9SQn7qdKWPMaCjm9ELA4zoWVZ5m7dETgs2hw Xrq0oMRMplxJwQJGVmoQKKMFgkE5U6S7Kh0S9Jc01vW4UXkglcT+nZb/oShKNhhFn1dA nMQDgYYf5xOIh1VqwtZ4gMZ+JuauSncrqBp9tpYBbyNBsSpL+GTHQaSK/Azm93w5vfy2 HPcM5/yE2ntmhFNzoDUfuAhePL5/o5O57uiPJpu9PYrv/JMNZ0cPdwfN1zYXgWASBsT9 d9Fg== 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=LHFC3pSp/lOd7ky65H/yobNgw+7t15stg1Jz7JjkFbI=; b=PuRLxMfkQLIGOIPWC/1MPfeFcB7kMuDU8MiqnJEesn1erxbBS2IxvHI595d8mLTvKM 7N5AQUUoSiB+1SaT/UmdVn3DvJmoAo4uljOzOKvNbtOWV772uK/S41/6P/9BmHyG+mZE ljSiLk3rQyY8p668EV7rI71m+2nasiGIyXm46LNuO1JJ/BVNubQbuAj/WRPu0zkLTKQb m3sGuX7yUjnKrbFcI7JgPoR4UadomnVcobVlkWGhW7kQHcyYaHRYDUodMgeKYc4GhDRp qS06jbfp9yWClb8hUl5jdwCBcDndIFFd8rig5W5ktmIB2sTuCkvK4P/OaajMZL3BOKFN ss9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P1rBseIR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id uz13si3629698ejb.531.2020.09.29.16.46.06; Tue, 29 Sep 2020 16:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P1rBseIR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728943AbgI2Xoa (ORCPT + 99 others); Tue, 29 Sep 2020 19:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728192AbgI2Xo3 (ORCPT ); Tue, 29 Sep 2020 19:44:29 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFFC7C061755 for ; Tue, 29 Sep 2020 16:44:27 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id x22so6385922pfo.12 for ; Tue, 29 Sep 2020 16:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LHFC3pSp/lOd7ky65H/yobNgw+7t15stg1Jz7JjkFbI=; b=P1rBseIRvL73O9KEgzsraANxelNynazHAaHgBcUNJGXW1FAVi9U/kndAv1g4k6feHa W/vIsM7esd7daIbIDh9a+hsvBhPZE0n4RkImb3UMkAxUJ7sBgcRf+bKd/KwaAIzmQZwB AyHBB/I9asrY7CY7byhP5KYw7oJIvw9EFm5rU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LHFC3pSp/lOd7ky65H/yobNgw+7t15stg1Jz7JjkFbI=; b=RiclnbGNMSEY7Bzdsps9A0HdMhpT3xKDwcm9WPJKKBSi6UTf+DPD1KO8p805Zyj5bb E8arbglQDYNHMDzD8PrzxKUOAq8QvA3IkfWV9BXebM8CmBMUS/g5ABVjtSUwfHp00/u8 VUH2CJTubYroUMIL88ykQUYqKV4SNwhHo+zbDGG8cMLdS53gpv/xzmcDiXL7/emQyF1y 2wKOV71/ifWdOCabPPFSjf/iakUPAF0WwdwYAJk28aD2CXtqyNTdtig7NW9wBjsu0ihL bWe/7GIlgAkoTMUKe02K98oZfR9VY5C7ZrdyPBfk1qgC1T4UoJSYDm/+7cJP1JIgMD6l ujTg== X-Gm-Message-State: AOAM533V2cnK57n2Hr3hQ9AIDU7tTasWvucQyidgHgFuXw1qBk5e9OEQ 23QIAT24C/5yU9uStIdVzS23YQ== X-Received: by 2002:a65:4342:: with SMTP id k2mr4984144pgq.343.1601423066988; Tue, 29 Sep 2020 16:44:26 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id p11sm20964pjz.44.2020.09.29.16.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 16:44:26 -0700 (PDT) Date: Tue, 29 Sep 2020 16:44:25 -0700 From: Kees Cook To: Nick Desaulniers Cc: Andrew Morton , kbuild test robot , Nathan Chancellor , Masahiro Yamada , Matthias Maennich , Jessica Yu , Greg Kroah-Hartman , Will Deacon , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang Message-ID: <202009291643.97AA3D46@keescook> References: <20200929190701.398762-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929190701.398762-1-ndesaulniers@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 12:07:00PM -0700, Nick Desaulniers wrote: > When enabling CONFIG_TRIM_UNUSED_KSYMS, the linker will warn about the > orphan sections: > (".discard.ksym") is being placed in '".discard.ksym"' > repeatedly when linking vmlinux. This is because the stringification > operator, `#`, in the preprocessor escapes strings. GCC and Clang > differ in how they treat section names that contain \". > > The portable solution is to not use a string literal with the > preprocessor stringification operator. > > Link: https://bugs.llvm.org/show_bug.cgi?id=42950 > Link: https://github.com/ClangBuiltLinux/linux/issues/1166 > Fixes: commit bbda5ec671d3 ("kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS") > Reported-by: kbuild test robot > Suggested-by: Kees Cook > Signed-off-by: Nick Desaulniers Reviewed-by: Kees Cook Do these other cases need fixing too? arch/arm64/mm/mmu.c:u64 __section(".mmuoff.data.write") vabits_actual; include/linux/srcutree.h: __section("___srcu_struct_ptrs") = &name -Kees > --- > include/linux/export.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/export.h b/include/linux/export.h > index fceb5e855717..8933ff6ad23a 100644 > --- a/include/linux/export.h > +++ b/include/linux/export.h > @@ -130,7 +130,7 @@ struct kernel_symbol { > * discarded in the final link stage. > */ > #define __ksym_marker(sym) \ > - static int __ksym_marker_##sym[0] __section(".discard.ksym") __used > + static int __ksym_marker_##sym[0] __section(.discard.ksym) __used > > #define __EXPORT_SYMBOL(sym, sec, ns) \ > __ksym_marker(sym); \ > -- > 2.28.0.709.gb0816b6eb0-goog > -- Kees Cook