Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp83463iof; Sun, 5 Jun 2022 21:51:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsG299FXaneARy8YRAKnNx6QzH/IFE/2AFteT6cQ0a0aizzrsh5Irqgzf7BnItleFuDo+N X-Received: by 2002:a63:1b53:0:b0:3fd:168e:d9a with SMTP id b19-20020a631b53000000b003fd168e0d9amr14785978pgm.617.1654491098574; Sun, 05 Jun 2022 21:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491098; cv=none; d=google.com; s=arc-20160816; b=gfGinz6qiBs8Oi67q133F8jy5X6FK7ra5AcQVDBuiRgcGAttn2vf1BAvT633DxGEtf zbdGpsjcIY+of3uRLApUlRgZe7pBHNddCs5FKli45ASSWpse1fy/fFHiCJbbzbZkQmFl fj3qlGlrb+AQYf1Qaz/5gsQHQV3tAZjRHaRGF6GX4x00CpjEsKgJDI5Hy3SZgifoWnC2 A9FEHm54GAG/VULrDssQCVTnnoocylp5jsY+mG6rOWiitNjEQRTQWkudHaATWcyLM5H/ LEyWRXHctIpQA8mV/RbJkcT3Fqj9uqOlrqKinB86XbFSFi/nH+FGnDu24RjNc3/ogqcO uYhw== 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=P5dmFxE3U3h+VJrwP2VrUmRsZzqWbQL7sCCiqkW4kes=; b=RRO3qyP/hFILwUHVgmR5D/HyJaoeUpAFUXG4xVmaABckpr6Zyc7Bra69SMaImAQcef odUXgriszgNOq6NkRgcwq4Cz0sz8tiobda6d+2Xdv3bhdbMfg0XZSuqq/GRAI+JPEwAn Dh09cGl7pRxC9Y9Fk6XbzMsFF7+m0FBE0lTRSmK20wzzLrgRzN+NmSjNRWcwoKqhEK/X sxAJPXGoWcnw1IHTLiawe0+jXMg/JX45eYUDj1J2MCSCdY3roIBoqiHXpB/76JpA/ggR osXqs5LO3BisdHc2+CtNI4NoUrWhUXRIExzrBcFWvnNhX6YA3H72CqxF0adfp7gPkOIA STGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tRapyWrZ; 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 f15-20020a056a00238f00b00506bc45aaecsi22266654pfc.371.2022.06.05.21.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:51:38 -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=tRapyWrZ; 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 441A918F; Sun, 5 Jun 2022 21:07:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344830AbiFCRwo (ORCPT + 99 others); Fri, 3 Jun 2022 13:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345380AbiFCRsz (ORCPT ); Fri, 3 Jun 2022 13:48:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6289E55362; Fri, 3 Jun 2022 10:45:41 -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 C7BA1B82436; Fri, 3 Jun 2022 17:45:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3761AC385A9; Fri, 3 Jun 2022 17:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278338; bh=dxjPZPVlqmjaq3Wp1+URqSoSvR4DtFcgfltGCSWzzCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tRapyWrZRZZIrB3oVG4BtVJXKHuMfoBFIeEDoH9alxYUNcp6Wdf8zJQrk0fc8CRY3 EysxVMrh1zMw3inBcqS3zrspx6Yv7/UBRgbGmDVDAlEDcUvYa/DEN6mQVYlOjw/kX6 6eF+CUfAJ59t81/zaR7MDZnVSTbBy/H56tWal0Ig= 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 5.4 34/34] bpf: Enlarge offset check value to INT_MAX in bpf_skb_{load,store}_bytes Date: Fri, 3 Jun 2022 19:43:30 +0200 Message-Id: <20220603173817.172203017@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173815.990072516@linuxfoundation.org> References: <20220603173815.990072516@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: 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 @@ -1668,7 +1668,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; @@ -1703,7 +1703,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);