Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1470812rwj; Sun, 18 Dec 2022 08:49:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXtaNPYqY+HdEMBExCjcey+fq1ECWWYF4RHirjC9WoCks57DZWBG+HtIYoAqqWkKua4eB1P+ X-Received: by 2002:aa7:d6da:0:b0:474:c69:9af5 with SMTP id x26-20020aa7d6da000000b004740c699af5mr12001678edr.22.1671382158156; Sun, 18 Dec 2022 08:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671382158; cv=none; d=google.com; s=arc-20160816; b=d2KpQFuXiaOoXMoAUvDnDf2MDZFt9sNT/eFDfTujvYH27eZyJhmOQptCzhu775mBD9 8b8fgR/m0PfLWe4em7piaGnExo0eKscb/iJK0xcwBCJbuA36FyeS5BY6w4QLNGH48aCj DpwF+usHNvbvLxRJRvViKUqKlloJLfcP5K6FqyJ7BfNcKy90jFDcTagqp8eKchQbhaax 1+gMXnjej4c3kXhSbkp5JDj2csWDzEXXgaNIjJ7+b3an3Z3sB1EiKzeiKeAbhxG6eM0m m3QI2VJX+ebKtLLffOW5lFT3cNuGSR7Avna7VdShnJ2B1KrcLCW55+9uvQE0SXEoVG5B tnuw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z6ObvWj1mUg5zMQ9FLumP0SczxswtOrKIyXq6i/yVB4=; b=IHOMnEYTyzhykeXJ+tNLiM+eiRhx97eycEC0DhW35ebV1gZTJoLoeNauVvB4uauyqM feUjzdoTV8LSRH8PwQMAUnjJUSkS/dEYa0gnBV1SdVfy9GOY1wV/eg2kwmxOB/hZwPbw UcDN1Es/bcvykShiz0B783UOs3SDPeNAzNaQVRK3tWtel4R6vjBCt3jK4BClvkvS/hFP 9R8mtyjs3YZ6/me+F3/a4uik66kCjv55IK6tVcuNX1nmiCcmolEsrerUWoDhsbwh5Pwd 21Ulk57VL9+6Y8f2hahABclpPMQB5xGtzHLthd9iSE/8q1YibBKCI5sDVyRVxqoLCinE /AKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RuDC576+; 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 v6-20020a056402174600b0046a7c877f58si6178184edx.335.2022.12.18.08.49.01; Sun, 18 Dec 2022 08:49:18 -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=RuDC576+; 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 S232542AbiLRQks (ORCPT + 70 others); Sun, 18 Dec 2022 11:40:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232498AbiLRQjq (ORCPT ); Sun, 18 Dec 2022 11:39:46 -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 46B15B866; Sun, 18 Dec 2022 08:14:10 -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 E31C8B80BA8; Sun, 18 Dec 2022 16:14:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34389C433F1; Sun, 18 Dec 2022 16:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380048; bh=JVxxHZ9SQ7h2QGln3ffdzdFW2g/qAn2mr5LedDU777s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RuDC576+8RTLqQ909WFNOBAoP+nmpIqmEoYIYq6/cang8j9tlcZ41nXPuhnJpdEC1 C+RGSe2Wr9g2n3EUHqFgzzYEMDEbieYxZHXd1K8eo3HKRwjtkb9lzduQ1UTMSYYgaK fnlyCxdsGE0NynuW/p8Kbo5QxM2LoqlsDdShlhRWSf2Q0LHk46A/u1mtBGwQRdRQLo 69uNK/XZmlbjDq893eOcsZ6j+HucNVw/wFWiOoBcoBr9whcC7oPnYH0ZvrcIcyL1mF 2pEMEtm+FWYXgKMFtjROnJkxpti8rFEfPEV5ndQVO5HmIisGLhBSDvSDPdbfNnenzR E5Zt4xRmgYhtg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Alexandra Winter , Kees Cook , "David S . Miller" , Sasha Levin , wenjia@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, ndesaulniers@google.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 5.15 18/46] s390/ctcm: Fix return type of ctc{mp,}m_tx() Date: Sun, 18 Dec 2022 11:12:16 -0500 Message-Id: <20221218161244.930785-18-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161244.930785-1-sashal@kernel.org> References: <20221218161244.930785-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 Chancellor [ Upstream commit aa5bf80c3c067b82b4362cd6e8e2194623bcaca6 ] With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals: drivers/s390/net/ctcm_main.c:1064: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 = ctcm_tx, ^~~~~~~ drivers/s390/net/ctcm_main.c:1072: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 = ctcmpc_tx, ^~~~~~~~~ ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of ctc{mp,}m_tx() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future. Additionally, while in the area, remove a comment block that is no longer relevant. Link: https://github.com/ClangBuiltLinux/linux/issues/1750 Reviewed-by: Alexandra Winter Reviewed-by: Kees Cook Signed-off-by: Nathan Chancellor Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/s390/net/ctcm_main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index fd705429708e..f91b6cfd7ed0 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -825,16 +825,9 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) /** * Start transmission of a packet. * Called from generic network device layer. - * - * skb Pointer to buffer containing the packet. - * dev Pointer to interface struct. - * - * returns 0 if packet consumed, !0 if packet rejected. - * Note: If we return !0, then the packet is free'd by - * the generic network layer. */ /* first merge version - leaving both functions separated */ -static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t ctcm_tx(struct sk_buff *skb, struct net_device *dev) { struct ctcm_priv *priv = dev->ml_priv; @@ -877,7 +870,7 @@ static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) } /* unmerged MPC variant of ctcm_tx */ -static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) { int len = 0; struct ctcm_priv *priv = dev->ml_priv; -- 2.35.1