Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4266908ioo; Tue, 31 May 2022 00:01:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfOX1VEWPOD1tpuwzcW/YxOV+I8ydwoEcD++yqWcsxjce8a0Kfy/ySFjC2+YcgDnajvx5x X-Received: by 2002:a17:907:7745:b0:6f3:674a:339 with SMTP id kx5-20020a170907774500b006f3674a0339mr52106493ejc.207.1653980464080; Tue, 31 May 2022 00:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653980464; cv=none; d=google.com; s=arc-20160816; b=vSopC6yMyGIegQFsu3YUhi8+fXdd3QPGphXW8F7/2H3JDyDuc4lxQGd3h78GWfaKFQ N2s+YmlLXs08xY5ENxLw5N8QrE91Un9rLTp/jqC2fsp5wffcCn54/KT9dcx+yHdMf1FJ ZRqnXzcxIfWX6aPt8FIDz8oIul37zpZlJ/3E6XOz2G3c0ZZzC7X7H8QthB6Cu6rpNEaG 18dv+kRWJtBd8spGQhZBnPCpXM8it5UL8aAOZMrLiAM/GhVfDsj9FQxZO5d2ErgFvoB9 NtB3sbNFPheJI8P9ko5/klGtQAGiJrNpKEEvWVpYSrtCTsMEiuQd/I4gtZu2l8im7zC0 qCAw== 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=lMChjvCOk0D5KYnEVW+o69HSnLHDZGl88IF7VY39p/E=; b=JyRiUFUusOzUIiwy9HDy9tFeYutrw/zDhypP9V3dDZKbGxIauzlECljY32hQ/dtGFd 6DbTp7AlB7KKsPMEvx0abKM0yXPnwOt5zR+X7PQVoI3iY5buByoeqfknubfgD65SOnqf zlnJKDH3B45Rg3RocXHbFDhFLTUFgcCrL5sMrEiog/WkrCzJV05ckbD0b3rXHKBaresH ZV192VplLKR4JO4GhYV3k3Tj+yHhGTnNZKEdPwiDKssmDNZuU+7L0SAM3Yv1UXW/qDNX F6FmY3pQBstzAURr6hq0BVy5nbeU4rEcWEj+LR0wSLeEBFQjtSfkWD4P7FGP4LpMkxsT +qtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qej3Qwua; 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 ne39-20020a1709077ba700b006e8925846cesi16217242ejc.471.2022.05.31.00.00.28; Tue, 31 May 2022 00:01:04 -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=qej3Qwua; 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 S241371AbiE3Oon (ORCPT + 99 others); Mon, 30 May 2022 10:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241942AbiE3OSN (ORCPT ); Mon, 30 May 2022 10:18:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1F499CF2A; Mon, 30 May 2022 06:48:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9B47DB80DAC; Mon, 30 May 2022 13:48:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C578DC3411A; Mon, 30 May 2022 13:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918512; bh=D1xKN/mMd+ATU/bbOM5le7faxJRmppzL8zhz3hlRk24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qej3Qwua4Wbi7cnvqI0ICS1TLjhAOh+YZZBohf7dKyd/yha4574GOVWawzX4cCuxL hRfCqFR7BXS3nT82Jb1Skr9IXlJbw0P7CW1zDzEZEy7GTnWOGGoYBm+fopzPj751jB 0doQpjGf0pBLKJOeYXBYQHE6QRkl5mDuqBI4rYP2Atnyo8w4Wb73OvSzjG/SDWGd/S EFIHF3tX0PCa4HwHa4WKLHSvxBgiueBpnDUnaSJ6twEIoEioyLY3u5sXv+rqUYm2g4 iaUnJ/V9HshFGUXMU0N++nLAIuWYffltRzn3SKS21MlvhGKzQxFjW+ueMSFaan70tX QyC84+dohVkQg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eric Dumazet , "David S . Miller" , Sasha Levin , kuba@kernel.org, pabeni@redhat.com, bigeasy@linutronix.de, imagedong@tencent.com, petrm@nvidia.com, memxor@gmail.com, arnd@arndb.de, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 34/55] net: remove two BUG() from skb_checksum_help() Date: Mon, 30 May 2022 09:46:40 -0400 Message-Id: <20220530134701.1935933-34-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-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.7 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,T_SCC_BODY_TEXT_LINE 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: Eric Dumazet [ Upstream commit d7ea0d9df2a6265b2b180d17ebc64b38105968fc ] I have a syzbot report that managed to get a crash in skb_checksum_help() If syzbot can trigger these BUG(), it makes sense to replace them with more friendly WARN_ON_ONCE() since skb_checksum_help() can instead return an error code. Note that syzbot will still crash there, until real bug is fixed. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/dev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index a03036456221..8fd0a0591e89 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2857,11 +2857,15 @@ int skb_checksum_help(struct sk_buff *skb) } offset = skb_checksum_start_offset(skb); - BUG_ON(offset >= skb_headlen(skb)); + ret = -EINVAL; + if (WARN_ON_ONCE(offset >= skb_headlen(skb))) + goto out; + csum = skb_checksum(skb, offset, skb->len - offset, 0); offset += skb->csum_offset; - BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb)); + if (WARN_ON_ONCE(offset + sizeof(__sum16) > skb_headlen(skb))) + goto out; if (skb_cloned(skb) && !skb_clone_writable(skb, offset + sizeof(__sum16))) { -- 2.35.1