Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5320834iob; Mon, 9 May 2022 13:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzslAk+0N7EitDre4Qd0lAyQxKjrLB9e7HJQ4kbth633nSWiaugPjrqdn5UCyBHnKxJm1EC X-Received: by 2002:a37:752:0:b0:69f:b793:7f92 with SMTP id 79-20020a370752000000b0069fb7937f92mr13309531qkh.56.1652129060038; Mon, 09 May 2022 13:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652129060; cv=none; d=google.com; s=arc-20160816; b=TFmVMAiRyknZKUL/iZ433bQs81vcKva1FLGjSW3dJqPqytyQ7vBTDshphsug6sV1KB uunfS1JCNly6Lis3lzYVjT4aVUA1M2yWFIktt0pAFakEypyagbuB4x/YzNUB0UOWbCUs 5od+9wxBtkyDUr+/C7faWZBTYZUKV+5iy3KIezsZx6k/8MF3Y9TharSBqdzCRGBJg8qU cfvWesnEI5zKf7nYYUprOfn1IPhLEtPMSqunn7Guw7NDHb22Y/E4GkXPXsywnLwQivjF PgrE2ULyFkZT8qVFQmLAVyEHYC7jSoRcCjt2p0m7Aw/FncxpJZr1xXqrr2cUjeF6p8+X gahQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DJvkssOcF8+m+Ove9gLIwYNOA7vpMPRTcC342WLSizg=; b=Saf6BoVXvO+/1Wn9QHFw4SZKQcmvj8giopVDi9IRFH6BznymIlnB036yCNt/LpS4DW HmiXERjd2DE1fGTYw1nk4Tpm0fiwwZKzBcCrivsRYEqHjSkULDc1eKpDiDiS3vkCFxXK zduHwa4uJ8RpC1hwiAjiaNkk6rBmBL85xBL9QK36g2saXLP42ikL8VhuS61WbilYchiU 1siPBRlzj1pN4Ob0A/gN7861qDgv1ke48IuNF+84Be8BYQ1eLWolYSp6SGTnACuWXgeI 4nfy+yOz3mFhZXaIWSPAoNT6auGv81KY2aIn/ranZxVEMY0wnHUP9FdmqQeqss9AEb9Y Ocmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=KpKgCLBf; 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 jq15-20020ad45fcf000000b0045a97f21031si10720058qvb.260.2022.05.09.13.44.05; Mon, 09 May 2022 13:44:20 -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=@infradead.org header.s=bombadil.20210309 header.b=KpKgCLBf; 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 S229636AbiEIUkf (ORCPT + 99 others); Mon, 9 May 2022 16:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiEIUk0 (ORCPT ); Mon, 9 May 2022 16:40:26 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F8F6424; Mon, 9 May 2022 13:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=DJvkssOcF8+m+Ove9gLIwYNOA7vpMPRTcC342WLSizg=; b=KpKgCLBfutwIM6QfTn7oZ1fOI0 4JX2oo2OGp9VpO65yNS70YWgPPl2q/IFttVJGj0CVQFLyhmV1r+2gRtv3HAV4S+u0CieG/zjo4P8Y blDSX62zTFAlDAlkTZl1CXE76IQNtzkrL8JC1JDgk1I8+07hYV8aCE9RrwvmXf9QfYwDimhRsbaxd dHtm5sw3m9ASqeh+A5Hv0sN6/00XJwItWJE1lM24uaQDGHjwGved8yQHp36+JaJlyc9RQBG15TYBt G1a4Q0yOaTaqh3CT2r8O6Srku4lEE7Knihuq5qMwcSIXCyy6CczW3ujT39EfdcMYxuATc+Z6yyy1V j2SOz2YA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1noA7F-00GBNP-Uk; Mon, 09 May 2022 20:36:25 +0000 From: Luis Chamberlain To: ast@kernel.org, daniel@iogearbox.net Cc: songliubraving@fb.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, mcgrof@kernel.org Subject: [PATCH] bpf.h: fix clang compiler warning with unpriv_ebpf_notify() Date: Mon, 9 May 2022 13:36:23 -0700 Message-Id: <20220509203623.3856965-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,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 The recent commit "bpf: Move BPF sysctls from kernel/sysctl.c to BPF core" triggered 0-day to issue an email for what seems to have been an old clang warning. So this issue should have existed before as well, from what I can tell. The issue is that clang expects a forward declaration for routines declared as weak while gcc does not. This can be reproduced with 0-day's x86_64-randconfig-c007 https://download.01.org/0day-ci/archive/20220424/202204240008.JDntM9cU-lkp@intel.com/config And using: COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 SHELL=/bin/bash kernel/bpf/syscall.o Compiler will be installed in /home/mcgrof/0day make --keep-going HOSTCC=/home/mcgrof/0day/clang/bin/clang CC=/home/mcgrof/0day/clang/bin/clang LD=/home/mcgrof/0day/clang/bin/ld.lld HOSTLD=/home/mcgrof/0day/clang/bin/ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size READELF=llvm-readelf HOSTCXX=clang++ HOSTAR=llvm-ar CROSS_COMPILE=x86_64-linux-gnu- --jobs=24 W=1 ARCH=x86_64 SHELL=/bin/bash kernel/bpf/syscall.o DESCEND objtool CALL scripts/atomic/check-atomics.sh CALL scripts/checksyscalls.sh CC kernel/bpf/syscall.o kernel/bpf/syscall.c:4944:13: warning: no previous prototype for function 'unpriv_ebpf_notify' [-Wmissing-prototypes] void __weak unpriv_ebpf_notify(int new_state) ^ kernel/bpf/syscall.c:4944:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void __weak unpriv_ebpf_notify(int new_state) ^ static Fixes: 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core") Signed-off-by: Luis Chamberlain --- Daniel, Given what we did fore 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core") where I had pulled pr/bpf-sysctl a while ago into sysctl-next and then merged the patch in question, should I just safely carry this patch onto sysctl-next? Let me know how you'd like to proceed. Also, it wasn't clear if putting this forward declaration on bpf.h was your ideal preference. Luis include/linux/bpf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index bdb5298735ce..bd3e17a9f821 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1551,6 +1551,9 @@ bpf_map_alloc_percpu(const struct bpf_map *map, size_t size, size_t align, #endif extern int sysctl_unprivileged_bpf_disabled; +#ifdef CONFIG_SYSCTL +void unpriv_ebpf_notify(int new_state); +#endif static inline bool bpf_allow_ptr_leaks(void) { -- 2.35.1