Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5774674ioo; Wed, 1 Jun 2022 12:18:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhkiEHDoGuvRqtRtwbGnJO9wDqnAc9zuEtG1Jm1NEorYmNH+AWLxCJyrYtXk+3lSBF11ES X-Received: by 2002:aa7:88d5:0:b0:518:8ef4:f378 with SMTP id k21-20020aa788d5000000b005188ef4f378mr1056957pff.2.1654111088029; Wed, 01 Jun 2022 12:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654111088; cv=none; d=google.com; s=arc-20160816; b=yyEfNL4n1bVfur2LEvuKPmWrO6+R6vdXAPyczBiEIDCLFclHlMmxb6NSrP5v2cwefM akogX+wO55MgeJuhnVW7Yym+4NLhaEQYIKq1PymX9bGIP4YbAKnkhfzo7hlVzt3lYa15 Vi0977s1qy7Q0iOz0Cknihpdub8HbV395d2Xnm4xupwYb6SxBy3Z9Qbw7gJ3TAJUlq4S 4SjNZisH78honVQqgEbaIB47PzWASoNAI8RMvOXV/AatggJCKtVbZ57Kc8sbcmTsM/Dw d9o5Hny700iv/bFtbUrqa/wutgpMlZ2WWgzWitjALtrqznIlaN7NAERooRF9Dbh5wAYX dBcw== 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=ojkjv17ZCifJZC1fWm7rouvaQzRc8T4zsMN07h67fhI=; b=rMnNxbg4w/OlhxDgfLOjrPB0Ip2Y7qS/rV17cg20pAuaBxOUq8pPOtJ1cHJRBVQgE5 BVhg7hMD4zf6ypSPCADwwsCFI1ZrQ0q2S3NWFjyTjc557JN0Jpe1DrA+UvdQ3mX0z+6i FFatHqoWTqJOKYxVDJpNzlwpJRUpDwxWiCIVlzimCP2+QGMdLenSZf5KWT6Rya/Y8tIu BmQXhov6OSozYSwkJcctksx7JHHWBZ8xpMRv1VdrRq9rEYvYaa5VaOuK8a8EEhuNnaWK 9BZqNfgY36CZo8LMCLfcSmH3YY43fPOCPmlzXQxMvxFJZFKVA/TWq069kJovDjMuHXwA a63A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZDVGgHdv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ca13-20020a056a00418d00b005104bf71586si2740491pfb.278.2022.06.01.12.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:18:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZDVGgHdv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25B05151FE6; Wed, 1 Jun 2022 11:54:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242169AbiE3OvU (ORCPT + 99 others); Mon, 30 May 2022 10:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242602AbiE3ObV (ORCPT ); Mon, 30 May 2022 10:31:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A1881997; Mon, 30 May 2022 06:53:12 -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 74F80B80DE5; Mon, 30 May 2022 13:52:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF4CEC36AE3; Mon, 30 May 2022 13:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918771; bh=xFZ/qA6yDXkSrcTFBTSW99brMlcXXlUY75Bdj3PbFFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZDVGgHdv51TR/F2n6byZD8U4Glz/SnMFzUW05i8eHBv8OMLAX9D5nsmRRdWj4dck+ YgUACvIcsCcVj79vH0A+38AsrC2Jd1ddo/b+z6TVHGzRUDqi52rwNoDRbl/Lu8/jQd 2UcDVM1CDq+Uw46ZFSUF3ufBZTZpr+dUjsieI05Cbzc9GyXukGnxvFMQnZkSc3/ye0 N67WIjeNwHWsMk26oeuZj2HOr7TOA23cnmDY2WZ9XTOTydomVfR2niiBSfAlNQIHBa X9YzsvuMFwMWJaF1IucXqtC6+MBbwsJ926fuNV9aKImHxnVShntSArxukKNt+eGkC0 mbsCJMtq1VfQg== 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 4.9 15/24] net: remove two BUG() from skb_checksum_help() Date: Mon, 30 May 2022 09:52:02 -0400 Message-Id: <20220530135211.1937674-15-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530135211.1937674-1-sashal@kernel.org> References: <20220530135211.1937674-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 47468fc5d0c9..d725ca4d4455 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2518,11 +2518,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