Message ID | 20221102160610.1186145-1-nathan@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a40e:b0:83:7221:86ba with SMTP id ck14csp60813dyb; Wed, 2 Nov 2022 09:08:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67nl0jk39Yfnh2ZmYniO8lBVBdPG9zTpCryLiJDev2vfGwv7mR8BQsnL7TB0KD4h42m/Qh X-Received: by 2002:a17:90b:2246:b0:213:48f0:297f with SMTP id hk6-20020a17090b224600b0021348f0297fmr26872779pjb.236.1667405303474; Wed, 02 Nov 2022 09:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405303; cv=none; d=google.com; s=arc-20160816; b=lIpkL6JhaMELmXVLeZhU0fOO+ePvgS62W4pZRHmsmEe0jmN0I/XaO6sUlimJwilVlb wtTnQlmtrb8dl8PmHM2g9V9/gQO6xkbCSjIryhubQz0rKCm+UdCtpr6vvXj5D1an1jmF twyueHdXrW9fseyrWEqdEb/+X4gTl6KYWWC9H71crNkxWd4ylAsCMVLFRjlFqM8kwHCj W7UWzmRmyh16Ypqb6y4mIWO08MbdFpX4yJHi8zZcGBq1Z0BDVGD9hwPPTjDExtPFFKHy JPNFe1p0vdNR6/GJ9Ot4mgIoAVqJXpv+WCpGeBpJeva8yleC/YkEwvWI0DM4qhZx2dnN UdKw== 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=Uvvmbr50zna//Xb+fO5k+L/6McYtPqnoEtae1ZaNJuc=; b=TWK7sc4FD6zMAb5XZagaMbVZL0db3RPYjry/VnBSsYbVdhVWd1B9XJtwL03YdXC62f LVXbLVNE9YZphBnsr7x13q6KLy+Po/qohM55sTVBUU/4KfjkzgF7UCGlayMgiHNdcr9u +E72ksyicXAwIhZC+vIYzNgj5NXFLolHDJEwtYDUbQYNKByOF06EzpXhtELYeIZpRnyi 0co0u4f5KT4wJHAAhTLZjsZBhOT4pE5raQ1/TvHbT/nHv2R82BfWEEzd+knKLOEbglE2 3sJfu6ezwSzFjWMsGl0egQhC8l4pkLPsNOWHD7Yy4j3VYF2X7e9H0IgJxG59TNsqwBH5 RuMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qbRk6eCB; 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 ip5-20020a17090b314500b0020982a8dbf2si2986075pjb.96.2022.11.02.09.07.40; Wed, 02 Nov 2022 09:08:23 -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=@kernel.org header.s=k20201202 header.b=qbRk6eCB; 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 S230005AbiKBQG0 (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 12:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiKBQGY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 12:06:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F37D25EB4; Wed, 2 Nov 2022 09:06:22 -0700 (PDT) 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 E3A2E6158D; Wed, 2 Nov 2022 16:06:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F660C433C1; Wed, 2 Nov 2022 16:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667405181; bh=uC/huKB8ojZr8E05891PDIL9GMzoWr5Ol6Vawz7NAHA=; h=From:To:Cc:Subject:Date:From; b=qbRk6eCBhBWgx0CQOO8Ik3q+htKp2pOYraMX06ybmCfSfqt/k/glkH97uTHhjR0M6 hcGl8TwcwSEkKCclmwA+UvEd0fxu/Q+nq0yIqgPoMzz44jRTlrU3KiD3Lfh5AaGsSg AYsmL3hr5pyJBOQQlncDwfP36xRqSCg5hYB+cOiUUcF4dSZ59FBpN4vv43478FM6kk Vk2piNjs/G9UgECa0gQIiO4dZk6bIz4cGlIDiJWEGzGqpM20K9TjtVWgun7EVKBBjq swIQumGh12Wn9Bt5g/0FQlavdScVCqIdG5UM/M1wtcK84sqR2JCyArpj6QTUsk3str Zt28kbB47Q4JA== From: Nathan Chancellor <nathan@kernel.org> To: Thomas Sailer <t.sailer@alumni.ethz.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-hams@vger.kernel.org, netdev@vger.kernel.org, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Kees Cook <keescook@chromium.org>, Sami Tolvanen <samitolvanen@google.com>, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Nathan Chancellor <nathan@kernel.org> Subject: [PATCH] hamradio: baycom_epp: Fix return type of baycom_send_packet() Date: Wed, 2 Nov 2022 09:06:10 -0700 Message-Id: <20221102160610.1186145-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=-8.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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748401183566497916?= X-GMAIL-MSGID: =?utf-8?q?1748401183566497916?= |
Series |
hamradio: baycom_epp: Fix return type of baycom_send_packet()
|
|
Commit Message
Nathan Chancellor
Nov. 2, 2022, 4:06 p.m. UTC
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/net/hamradio/baycom_epp.c:1119:25: 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 = baycom_send_packet,
^~~~~~~~~~~~~~~~~~
1 error generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
'netdev_tx_t', not 'int'. Adjust the return type of baycom_send_packet()
to match the prototype's to resolve the warning and CFI failure.
Link: https://github.com/ClangBuiltLinux/linux/issues/1750
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/net/hamradio/baycom_epp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
Comments
On Wed, Nov 02, 2022 at 09:06:10AM -0700, Nathan Chancellor wrote: > 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/net/hamradio/baycom_epp.c:1119:25: 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 = baycom_send_packet, > ^~~~~~~~~~~~~~~~~~ > 1 error generated. > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of > 'netdev_tx_t', not 'int'. Adjust the return type of baycom_send_packet() > to match the prototype's to resolve the warning and CFI failure. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Signed-off-by: Nathan Chancellor <nathan@kernel.org> Heh, this one was already using the enum for the argument to "return", too. :) Reviewed-by: Kees Cook <keescook@chromium.org>
Hello: This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <kuba@kernel.org>: On Wed, 2 Nov 2022 09:06:10 -0700 you wrote: > 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: > > [...] Here is the summary with links: - hamradio: baycom_epp: Fix return type of baycom_send_packet() https://git.kernel.org/netdev/net-next/c/c5733e5b15d9 You are awesome, thank you!
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 791b4a53d69f..bd3b0c2655a2 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c @@ -758,7 +758,7 @@ static void epp_bh(struct work_struct *work) * ===================== network driver interface ========================= */ -static int baycom_send_packet(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t baycom_send_packet(struct sk_buff *skb, struct net_device *dev) { struct baycom_state *bc = netdev_priv(dev);