Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1524837rwj; Sun, 18 Dec 2022 09:51:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5BuvDmOyysaK9Ztv6NM+SCDskkR4pELXB2UDaksbwyJ8MsnLpk0S8MGN69JIlNHLAFcQ/q X-Received: by 2002:a17:902:b406:b0:189:e711:173 with SMTP id x6-20020a170902b40600b00189e7110173mr41104223plr.33.1671385909071; Sun, 18 Dec 2022 09:51:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671385909; cv=none; d=google.com; s=arc-20160816; b=UWHFyZ+9EhHGFiKua6hz7Itnq9ZMRG0AEHSzDZdWkDROw+BXNugDdqxk3x2jZzlNxk tBaIkAm2Rpbcu1MnmneldFACvY17khr941pJG73tS3HDIaib0i+ipe6SOwXwpuSnD1ev Xai5qOqNrZgD4rbEwtGu4kb4myecKaAniXXJ/mNkdW8OcndZCFoXWAK2sEnr7oK8XGjT Nq21dHlPnrAOd71eY7ZI260f7qWqO2vzK+ka11BMFzmjpXUh9RfIMYUwtolH1i+M/phu T7YTs4nZxOEVUO7NpMl4GL8UbyfEi8Du0i0/U6qenl9qqK0bOP9rgLGIj9l6e7dOxa7/ auZw== 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=7O4IgEBvZWgOClJVNfoVwccGSHmmmTwEDlF6WuJnFew=; b=BYBamKDeoNHhrbfph9OsqEpRV+u9DMMj6z7yPX2TdZA39gI3MxD5emUGcbdAURYYUO mashF3pokeJJnKsjjNxj9e35QqAs7u1M+e/4XKfh+YB0eryt1K8hMG/HxZxpQOtozODe YTLtHaEJWpM+W2I8uWnEFKTbZ3MaMZm1Rn3uaT0k37MOJW186mGA3yaa6qjG/9phnH5d EnKhgIp15T7v4OPD8NbfzDK5dtmTzbWcD4PLv+IrbZH49SD3IC/Gd/iYurBD0B43f15s fpTm6C14i9UPe2FZtnZSg8Cl1eSQmD1gbvIbNH6PMWoBbiYZQzpVUpwZ+Xwrsm4khTX4 POYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sc0yogfY; 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 jg2-20020a17090326c200b0018981449921si7826195plb.107.2022.12.18.09.51.40; Sun, 18 Dec 2022 09:51:49 -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=Sc0yogfY; 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 S232524AbiLRQlX (ORCPT + 70 others); Sun, 18 Dec 2022 11:41:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbiLRQkY (ORCPT ); Sun, 18 Dec 2022 11:40:24 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8C656402; Sun, 18 Dec 2022 08:14:18 -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 AED6660DD4; Sun, 18 Dec 2022 16:14:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C562C43445; Sun, 18 Dec 2022 16:14:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380053; bh=NOapnwRvF1kxmYK8Zm2Y22YSLJTDcv2aaVj5LhFVnRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sc0yogfYDL/tIWIAB3vr+ojtWOmwYqzCOADCw5Ls3ldO5fOBB916oIQVXPXctPL/Z aThlAdNV2CHbZ37KaXVPGt+H0GBzAwlaLd9LKq/Tb4HnDN2+fewrRo+NChtHchYQyu 7XC9kbKd9WTWnoTjlzgjIvd3ds7zDII87yTZBV0J3ESlCbVjr3G/Dcmd5wBzwvndoF 2ju+Y6S+gXMNbCcSI/12DZySaC3596p6EWu//m4+89f+IR+z2sXBxWOneJeI2oChJD bnSTP5eBvaAoYwYvE304dSAltBJIzW0Izz/TghsFPFus9lvUGC5ButjYD0KYO8JKqy xsZrxCBw+30yw== 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 20/46] s390/lcs: Fix return type of lcs_start_xmit() Date: Sun, 18 Dec 2022 11:12:18 -0500 Message-Id: <20221218161244.930785-20-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 bb16db8393658e0978c3f0d30ae069e878264fa3 ] 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/lcs.c:2090: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 = lcs_start_xmit, ^~~~~~~~~~~~~~ drivers/s390/net/lcs.c:2097: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 = lcs_start_xmit, ^~~~~~~~~~~~~~ ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of lcs_start_xmit() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future. 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/lcs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index 06a322bdced6..7e743f4717a9 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -1518,9 +1518,8 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer) /** * Packet transmit function called by network stack */ -static int -__lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, - struct net_device *dev) +static netdev_tx_t __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, + struct net_device *dev) { struct lcs_header *header; int rc = NETDEV_TX_OK; @@ -1581,8 +1580,7 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, return rc; } -static int -lcs_start_xmit(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t lcs_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct lcs_card *card; int rc; -- 2.35.1