Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4385998rwb; Tue, 8 Nov 2022 16:37:25 -0800 (PST) X-Google-Smtp-Source: AMsMyM7dXLu3hxJBZOh7aiJCesxfjFPAEW+ExjFltjLLj6M4H3raf8Zliw7LYoOHJlY18GDu64Rh X-Received: by 2002:a05:6402:655:b0:464:d83:d02c with SMTP id u21-20020a056402065500b004640d83d02cmr36112877edx.335.1667954244915; Tue, 08 Nov 2022 16:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667954244; cv=none; d=google.com; s=arc-20160816; b=AmdKSJTXadk/tf9ZZeLYK/tJXZWqzJ/tmf2GNZaf3mm0nR+tA45wh1kn8O2QAl8/va xK6/ot/VW/HkGjf7QZIMdSpxAKTnC9Zo6+CRtgrqc0sWmMmGFEeZulIPFkbi0LQBvxs/ 5cCWYRjUPsAqTjute9uToigNzafrDvjPDPUan1sbYhghdopFCl5qOFFkaIqkuVxzjwI3 K9TkoGfdCljhvNAhPOEKtzcoMvYiS+pFjidUrHshozCmknedf4hqXXBFEWXsRHZ3G8pq UtztCUWepzDoeuDBoTZ39JHzvOt9PvLh1pi0drRfWEfpKPe6ocw0uUcCnMvC3WYvPY/B KrBQ== 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=VqAUkRisLCZmEqsqf1xijJFLnu/3UjDiB3iT5ZcPpmM=; b=cR51MUQCkihXpwszLIckR7z1pMsgg630hUHj8H5ILZN1XxGfMApeijECcRVfS/HSDL YPUdhKbJ25cTzj/r+xUVhi6OB6kJmJBzCRHfzHb3nPZPRK7GNT6coA3AOlNpnO30IbF5 IeahSTLAsg55MKZoFGhM3tAxraBpE4eF0lsv4+912uZ7FTgjb0rOli4uoFDHwOUJPo/7 dJ+mEoaB4IAGR3DO+NNzSfO5xOxBr6J7/TOc8Wgb42uQRtnSjQ/maTVLjikW9hLmRo1v FIpYvDnXUs+bLMrHyc6yhXH2h5AmlolYit6j7ANZ5iaw0PoLuGgRCjze8iM9awKDX5Qt n2Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q8bHSIZ1; 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 qk44-20020a1709077fac00b007ae0ca417e4si14566202ejc.690.2022.11.08.16.37.02; Tue, 08 Nov 2022 16:37:24 -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=q8bHSIZ1; 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 S229615AbiKIA2s (ORCPT + 93 others); Tue, 8 Nov 2022 19:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbiKIA2c (ORCPT ); Tue, 8 Nov 2022 19:28:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E4AAD; Tue, 8 Nov 2022 16:28:21 -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 ams.source.kernel.org (Postfix) with ESMTPS id EA245B81BDF; Wed, 9 Nov 2022 00:28:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 792B9C433D6; Wed, 9 Nov 2022 00:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667953698; bh=HWHf8Rl0nBj9nc3udlptxTqUuonteTAfMEYPiSz8dG4=; h=From:To:Cc:Subject:Date:From; b=q8bHSIZ1IMWsPyMHLigT5XjNnubx5J5ByjfwIQ5gSqiABwFvXHEttHj6trfOiskpm ui6O2j06eX9wveGxOPWfzZ0EBY46uPdhEcPm6FKA0gw6jg2nrHBsBW4OeP9bGjB1DE 6mNDQRLI4oUheiSTHQBqwc9DcjrSb2Wc5crexZEqBJgacf56pvvKOJ9sKqaS3ilP98 LkwpUKpRxGq2JdccJ6uC6gDt221EVzEa0M35ZUmjvqVzuVjkBXG65cqsOON7qO2DQm polFPC/b5YciteDnmsWIuPYaZ0Buc4w9PP34R6jP26F6ny/NpdElarpxP1t4CVWjiF NMvYdsInyuJ4g== From: Nathan Chancellor To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, Nick Desaulniers , Tom Rix , Kees Cook , Sami Tolvanen , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Nathan Huckleberry , Dan Carpenter , Nathan Chancellor Subject: [PATCH v3] net: mana: Fix return type of mana_start_xmit() Date: Tue, 8 Nov 2022 17:26:30 -0700 Message-Id: <20221109002629.1446680-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Nathan Huckleberry The ndo_start_xmit field in net_device_ops is expected to be of type netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb, struct net_device *dev). The mismatched return type breaks forward edge kCFI since the underlying function definition does not match the function hook definition. A new warning in clang will catch this at compile time: drivers/net/ethernet/microsoft/mana/mana_en.c:382:21: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict] .ndo_start_xmit = mana_start_xmit, ^~~~~~~~~~~~~~~ 1 error generated. The return type of mana_start_xmit should be changed from int to netdev_tx_t. Reported-by: Dan Carpenter Link: https://github.com/ClangBuiltLinux/linux/issues/1703 Link: https://github.com/ClangBuiltLinux/linux/issues/1750 Signed-off-by: Nathan Huckleberry Reviewed-by: Dexuan Cui [nathan: Rebase on net-next and resolve conflicts Add note about new clang warning] Signed-off-by: Nathan Chancellor --- v3: - Take over for Nathan, as he is busy with other matters. - Rebase on net-next and resolve conflicts. - Add a note about new clang warning that will catch this issue at compile time. v2: https://lore.kernel.org/20220929181411.61331-1-nhuck@google.com/ drivers/net/ethernet/microsoft/mana/mana.h | 2 +- drivers/net/ethernet/microsoft/mana/mana_en.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana.h b/drivers/net/ethernet/microsoft/mana/mana.h index d58be64374c8..ffcd27cde17b 100644 --- a/drivers/net/ethernet/microsoft/mana/mana.h +++ b/drivers/net/ethernet/microsoft/mana/mana.h @@ -388,7 +388,7 @@ struct mana_port_context { struct mana_ethtool_stats eth_stats; }; -int mana_start_xmit(struct sk_buff *skb, struct net_device *ndev); +netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev); int mana_config_rss(struct mana_port_context *ac, enum TRI_STATE rx, bool update_hash, bool update_tab); diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 318dbbb48279..91a8d3577c14 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -128,7 +128,7 @@ static int mana_map_skb(struct sk_buff *skb, struct mana_port_context *apc, return -ENOMEM; } -int mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) +netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) { enum mana_tx_pkt_format pkt_fmt = MANA_SHORT_PKT_FMT; struct mana_port_context *apc = netdev_priv(ndev); base-commit: 8e18be7610aebea50e9327c11afcd5eeaaa06644 -- 2.38.1