Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp9166371ioo; Sun, 5 Jun 2022 06:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp6pUXEcIBfpQb2WkRUqVFaO3Ga0Qaz65p4QtNZUHZVOYj3kqCKF8BLYR4zO46eARgqJ2C X-Received: by 2002:a17:903:120f:b0:15f:99f:9597 with SMTP id l15-20020a170903120f00b0015f099f9597mr19244970plh.45.1654437389434; Sun, 05 Jun 2022 06:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654437389; cv=none; d=google.com; s=arc-20160816; b=UKH21o6Q02paSDzplDPqK0AMHb9t56OUXxtfD9mysR0vAfqbOXaL0dVOhL5hcZmCPA 4CAnCc0MmjE5zjqc9ShytqaGjx9VQNiRzMpPibKKjuTx9w9jaBSjMyu5gw+w4O29tm2f PbSFmiUpHOZVpw3LG86xnRye138a9HYFGpRMS4rmLMkN0hh53peU+GxbcUpUPZVWwmoG le2FoF7JE9KfDpLz4UmeRpozblNRQwis1S7f0AwO5HddytgHSLjzEsC7KaeX81ztWhNJ KT7fIUvv6wGBuiMJXARfadw5baqxg2JtQV53wgT1uqtW+S+bUIZlk9/rCM1Sz8oNDkz9 MS6Q== 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=onX3BFaIHURfzsE4xlnFQCUL3ITP+AHRgmY9LcmchfA=; b=y3q3vUuvpTC2srDvUnaCpxLu7/iPd3StkygMlIjpM/0jnn1y0v9RAj6oEsKoNI/zMb G8gL0YcRJpE01ums+qMH5uFgwM48EV8AD1GnYrj7SkAjj2WSE7tx1iHDflCoo3Ocn8vS aDtsfLM6bxveRBsPymNsKYVyAY3JhEY/1pSEFOryLe8k54kD1NaNffGarlg7hZNPp8ap 9EuqXULK6cSzJhWOlcBv16BcBXMSrPXDzfT5kyA8Iq1tHjY4hrhtGY3idcS8x/Xj6XFx HgIlnQAbKp/+ly98OGFBl0hXR21V63s20VbS/6ohpmJsrY5bpqlA7N48qKhIxGkDRQv2 PmBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tlOKGkyS; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu13-20020a17090b1b0d00b001e6a0a4c86asi11044375pjb.178.2022.06.05.06.56.16; Sun, 05 Jun 2022 06:56:29 -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=@linuxfoundation.org header.s=korg header.b=tlOKGkyS; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344773AbiFCRmQ (ORCPT + 99 others); Fri, 3 Jun 2022 13:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344832AbiFCRlw (ORCPT ); Fri, 3 Jun 2022 13:41:52 -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 B406853710; Fri, 3 Jun 2022 10:41:10 -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 285E6B8241E; Fri, 3 Jun 2022 17:41:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70706C385A9; Fri, 3 Jun 2022 17:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278067; bh=BH80/xrWi3HHDzmncsNTp32aPsRHWdcdKFT71F8XLJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tlOKGkySvNO8ZEoItxDVtR9ShZqZ+VEAVPqTY+tkwWCMAfod2J0E8HwdTmPPR116o qvkVH+cI/oJcNca4N1Ou1+r4ddOKfFkFDDePLZRuU8DIwSTr1GyZhYSnLznLuE0jW6 +q3KUGGHHAwWwjN999RfohrBYTx6ikTDCBAEkwhg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Jian , Daniel Borkmann , Song Liu Subject: [PATCH 4.14 23/23] bpf: Enlarge offset check value to INT_MAX in bpf_skb_{load,store}_bytes Date: Fri, 3 Jun 2022 19:39:50 +0200 Message-Id: <20220603173815.063242055@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173814.362515009@linuxfoundation.org> References: <20220603173814.362515009@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=-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: Liu Jian commit 45969b4152c1752089351cd6836a42a566d49bcf upstream. The data length of skb frags + frag_list may be greater than 0xffff, and skb_header_pointer can not handle negative offset. So, here INT_MAX is used to check the validity of offset. Add the same change to the related function skb_store_bytes. Fixes: 05c74e5e53f6 ("bpf: add bpf_skb_load_bytes helper") Signed-off-by: Liu Jian Signed-off-by: Daniel Borkmann Acked-by: Song Liu Link: https://lore.kernel.org/bpf/20220416105801.88708-2-liujian56@huawei.com Signed-off-by: Greg Kroah-Hartman --- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/core/filter.c +++ b/net/core/filter.c @@ -1443,7 +1443,7 @@ BPF_CALL_5(bpf_skb_store_bytes, struct s if (unlikely(flags & ~(BPF_F_RECOMPUTE_CSUM | BPF_F_INVALIDATE_HASH))) return -EINVAL; - if (unlikely(offset > 0xffff)) + if (unlikely(offset > INT_MAX)) return -EFAULT; if (unlikely(bpf_try_make_writable(skb, offset + len))) return -EFAULT; @@ -1478,7 +1478,7 @@ BPF_CALL_4(bpf_skb_load_bytes, const str { void *ptr; - if (unlikely(offset > 0xffff)) + if (unlikely(offset > INT_MAX)) goto err_clear; ptr = skb_header_pointer(skb, offset, len, to);