From patchwork Mon Nov 7 17:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 16579 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2180355wru; Mon, 7 Nov 2022 09:15:22 -0800 (PST) X-Google-Smtp-Source: AMsMyM6gDV27JtH4qx1mSDR9qI1N2yRy4lut0X5JN8faUwRJI/MrJ/uHLxQw0WY6m22ym+tiS+rT X-Received: by 2002:a63:da43:0:b0:46f:9193:466b with SMTP id l3-20020a63da43000000b0046f9193466bmr42232461pgj.419.1667841322068; Mon, 07 Nov 2022 09:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667841322; cv=none; d=google.com; s=arc-20160816; b=MFus8DSKFaxn2rIspCp2/m3fQH505XSCDA7h8AVi7ADUc+Lld92UGOPS0YNFWcbAEm XxedxFptc2cK9b3eRTpO9jnLvrVmm1VBvqP4Mm2RrTVMcokhuCYvVzF8zbDtwYAyekJc 140gT4oifCTDDc3hYOyeySdBPDZwaAqbRUjMFqZ4EnmdB14iAL7OcPEsi11Yn6TUAuF5 utQdiWjEO51JJKiM2Q87sp404T7TkRyydG/Mu1GsES0kYaqoWs6cIhc+M/4ZrLIHULeq EETnmmWB2yLOgSKhP/gYf4cA61vbQ4FqhZFoW6gPRWeqxbZ78P30BJVwbbS+huxmgkXn Qy9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Tv4YwKFem9Tw+BCbpfk9sN62C5KTsVzGonmTid5b9OU=; b=QUjtig9oAN0QhLbqqWUpLotBgZLrGBtSPlJmOffKJhnxdKPnprHdGy3aeH+rDK/wcy NsDggX0g4SaWbOtfZXCZzPcx5Ry3AUBiZOV/CVb1ZP/tLbcL9ZoXZJIdrnISm69WfzIm mo+S6Asf3fdOQq86YNaWde9+Sx0JJ4WeYlIUOT/VBq6DL8M8b9X8TX+hgKvHdDxs29Ue yhmcEAkj+9RCpRAsXHEfzefehMaIlTTe1ENLVh74unJr6BeJr3hpubU4MNlYQKIECa5l QtiDsayBe3NHFAvF39aM8ZsjHP+30oJuyxuqOOy12RzkhpmxJi1wnca4m2irp584kf+x V0Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KT+9TnHx; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg10-20020a1709028e8a00b00186aace22ccsi10118232plb.288.2022.11.07.09.14.45; Mon, 07 Nov 2022 09:15:22 -0800 (PST) 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=KT+9TnHx; 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 S232291AbiKGRHk (ORCPT + 99 others); Mon, 7 Nov 2022 12:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiKGRHh (ORCPT ); Mon, 7 Nov 2022 12:07:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB461EED1; Mon, 7 Nov 2022 09:07:36 -0800 (PST) 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 29D8D611B9; Mon, 7 Nov 2022 17:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2624C433C1; Mon, 7 Nov 2022 17:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667840855; bh=JhvxwGh6CHd/kos2GLFjcIg4ffzMl1S5afABnifg974=; h=From:To:Cc:Subject:Date:From; b=KT+9TnHx220XRrjPA99dqFGYvbztZkzEPy/Gb6QPRBp3heSpQG85+Xs+KiH3THlxt iJ08hNiBO5837fWdJnWDWUD6bJX3QDaaHGYdy6q4DkPD7kvvMWDrXtpnw3DCmOzCd/ MZ/76QrKnkIYgld5Qgav+c4n3sKg3gsfLjKy8VRWCVYyLtgztWepGUuYS7xJWt4K/n RkdHXCJ6kteVMslBChX2CxdM1VOqxSfgm3qlFLrRWFDfOVH1IF/YA4mig8stoF7i7Z OKsb5t+kpvtiKh4xBogxIAvM9aI/b+fTotVqPmc1hcjLBzLE7fBM4caDdV1BsOtDW2 evw/zwgutMHHw== From: Nathan Chancellor To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: John Fastabend , Jiri Olsa , Peter Zijlstra , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Nick Desaulniers , Tom Rix , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor , kernel test robot , "kernelci.org bot" Subject: [PATCH bpf] bpf: Add explicit cast to 'void *' for __BPF_DISPATCHER_UPDATE() Date: Mon, 7 Nov 2022 10:07:11 -0700 Message-Id: <20221107170711.42409-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748858382170598603?= X-GMAIL-MSGID: =?utf-8?q?1748858382170598603?= When building with clang: kernel/bpf/dispatcher.c:126:33: error: pointer type mismatch ('void *' and 'unsigned int (*)(const void *, const struct bpf_insn *, bpf_func_t)' (aka 'unsigned int (*)(const void *, const struct bpf_insn *, unsigned int (*)(const void *, const struct bpf_insn *))')) [-Werror,-Wpointer-type-mismatch] __BPF_DISPATCHER_UPDATE(d, new ?: &bpf_dispatcher_nop_func); ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/bpf.h:1045:54: note: expanded from macro '__BPF_DISPATCHER_UPDATE' __static_call_update((_d)->sc_key, (_d)->sc_tramp, (_new)) ^~~~ 1 error generated. The warning is pointing out that the type of new ('void *') and &bpf_dispatcher_nop_func are not compatible, which could have side effects coming out of a conditional operator due to promotion rules. Add the explicit cast to 'void *' to make it clear that this is expected, as __BPF_DISPATCHER_UPDATE() expands to a call to __static_call_update(), which expects a 'void *' as its final argument. Fixes: c86df29d11df ("bpf: Convert BPF_DISPATCHER to use static_call() (not ftrace)") Link: https://github.com/ClangBuiltLinux/linux/issues/1755 Reported-by: kernel test robot Reported-by: "kernelci.org bot" Signed-off-by: Nathan Chancellor Acked-by: Björn Töpel Acked-by: Yonghong Song --- kernel/bpf/dispatcher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: c86df29d11dfba27c0a1f5039cd6fe387fbf4239 diff --git a/kernel/bpf/dispatcher.c b/kernel/bpf/dispatcher.c index 7dfb8d0d5202..c19719f48ce0 100644 --- a/kernel/bpf/dispatcher.c +++ b/kernel/bpf/dispatcher.c @@ -123,7 +123,7 @@ static void bpf_dispatcher_update(struct bpf_dispatcher *d, int prev_num_progs) return; } - __BPF_DISPATCHER_UPDATE(d, new ?: &bpf_dispatcher_nop_func); + __BPF_DISPATCHER_UPDATE(d, new ?: (void *)&bpf_dispatcher_nop_func); if (new) d->image_off = noff;