Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2144960iof; Tue, 7 Jun 2022 21:15:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR4PzrWGwRBnY+qI3AzJuFJOsTmOB+MJHwULIpa8A5nNpPq67WvG3HmkvY21yvH8yhaVPd X-Received: by 2002:a17:90b:350d:b0:1e6:7780:6c92 with SMTP id ls13-20020a17090b350d00b001e677806c92mr36626181pjb.46.1654661700064; Tue, 07 Jun 2022 21:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661700; cv=none; d=google.com; s=arc-20160816; b=tPtZbg42Bnl+QRFrUeW2jbffbj/mvhaVD8jpSdXx3IJ1hlyumOC20/YjntlWQPdgR4 Ijf3FyxnY0012K0y2bKt/jJlAsfEFcDs88TfjTAaSCS5bqXWsgrZOMZNJU5kCy3eQYwQ c6bx5E/UTQepKW/ZYTZqhwble1r2DHFHyCEdFwMGbUqzJEN0nwx4sVAqqOUsUINOcLjH Z9yKClpM27+2orbj+ipvO20H88l0QqZfXoglCht4rf+tQv/1IvHW8wI355j0jaY/6u1l rjHC0cCpxLskO5OeZ1h4XyzHxWgqj1bDGNRNy81IuXu04cwIIm5XUuyPLmWoVTSwJGkS ZbRg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2r0NIJwUlZU7pPCFNpr07Q0i11G6Emp9C9LZ771PvwE=; b=Qts5TrV32xr17owHDPevfgKEAvCOFSqTzUA/rsv7CKFtBDZVgscwZkRH7njY6aWHo8 UeYlwVuALdMlGXR8Du+8Su04XubPH471mk32QdDLhGSMlWSjnXuh4wmdxCm8WAARGOIJ wOVql0tOwy3YPQ0MjlnQysekww+WHt2MxjjO+6mhCAiuRk+QrQzgQz4oz3ShpU0BUmxV 1EQJOxX4mX8MkbjN0buxTRj+zRnilbnBLelbAaORL8vqvLtfWlu5sFa9htKXLky7mnhh n4wt40NlKsBgdBUhJBAcjj2cDKKn1HadsTiqxdfRo0bJovBsF3V3qs2AwPvmFlYKR0C9 7mZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a+nu8dYR; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 7-20020a630f47000000b003aba3e87b3csi29021275pgp.43.2022.06.07.21.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:15:00 -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=@linuxfoundation.org header.s=korg header.b=a+nu8dYR; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3329122EFE8; Tue, 7 Jun 2022 20:46:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346528AbiFGR3g (ORCPT + 99 others); Tue, 7 Jun 2022 13:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346868AbiFGRZc (ORCPT ); Tue, 7 Jun 2022 13:25:32 -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 B556D1109B4; Tue, 7 Jun 2022 10:23:25 -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 69611B81F38; Tue, 7 Jun 2022 17:23:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7A2AC385A5; Tue, 7 Jun 2022 17:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622603; bh=4lNzNS2p7KxnpndFtuhi60Ak7ru+mfW1yQXaFo4Cags=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+nu8dYRQjSh7qHlbmFZNzsQLVYGZvOW5oVTtus8/ihjmm9JDWwQ6u3Q5+HM5pxZg uY/FzPeEvNVcbE0hEHX2DnGfMHZNvxyX2qiK9xCN3G0/VFVTXUM/DIeV/k7vRDyLXS dhk2EmIR6fHWe7Y98a5Ztl9b4pMhGUe/ulGTBtFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 068/452] net: remove two BUG() from skb_checksum_help() Date: Tue, 7 Jun 2022 18:58:45 +0200 Message-Id: <20220607164910.577153212@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 0bab2aca07fd..af52050b0f38 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3241,11 +3241,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; ret = skb_ensure_writable(skb, offset + sizeof(__sum16)); if (ret) -- 2.35.1