Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7036158rwp; Tue, 18 Jul 2023 09:07:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlEIAkzWjagdgVLdpWoZSbgz4yt9Zcvs/5tzsjBvazPY+u+Jp7J75JIFJFEok8iNXnf9vGWF X-Received: by 2002:a17:90b:4c45:b0:263:fa04:4f53 with SMTP id np5-20020a17090b4c4500b00263fa044f53mr12153268pjb.2.1689696443576; Tue, 18 Jul 2023 09:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689696443; cv=none; d=google.com; s=arc-20160816; b=VAhJphgB6iKhZhwc50PICxyVA1LwtMpXVd5DlvDVeJFvM/3+8NejNWEl8XBF8/xZ18 9uuXfNEw2bLVdSJJ+OBUQU4Yn2+/gZExa9CggEfSycQxK2xmPozM/HhEtGY4gF2GtdJr sjv8tYQr43hrmhEIP2bwovKH1o86mSycTHQzHkhk6zw5l5eEknIN+vUGvdLtBOLAjDsW esluH/ul6dSZbGlR+j0BKPODv3dz6hO7aV0O6g+ttF1ds9YeurQx//1Qlc/teMbOkTYi A2zd1+B8ayZNTONYoGKuNY43ulbHjE/NsJ5cBm5ej2MtUUI6PAq5zf8ywXIiCQk/74Iu vcKA== 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:subject:cc:to:from:date :dkim-signature; bh=oiXnpMBgI8JsrgdalAsOGA8FzrT1CBTAlFg0HjjhaHs=; fh=hTfDfrLW2UJ27V1HY0ZA6oio7PjCFIwelVMAAtH1LOg=; b=xz4dtKZQVhZybS1XhWJRyTDEBeNl/tfU3ldG9wE6sClselkMowmQREtJKtgsnIcFn9 ldycDtMzLT1EXk/0W3EPoie9XVSImnE4lFw0tdbXZKtuvvizsjr7NrZGjNfrgxIbLAf3 hB9lO70H3Hazx0mDmum4q+UNuIpMrCSHnx1jzYUzmzmF0/4Es2JQ9IWTtoRYjDVUgGPQ UGGrBcQAZwwv/0VB7Of9QOBGcG3hHA7o5jO1tpFs/rV0lqJcpHKEK8MuwlEnNxMiExK3 iDaY1SQPwbcFQ9FMiZswUSiX+HA3USlS8JoGes7GiH7YF1DUnULBEx0c2w0muJO1A7tn J8+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PxXZhcH7; 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 nu14-20020a17090b1b0e00b002634e08d484si7940259pjb.56.2023.07.18.09.07.11; Tue, 18 Jul 2023 09:07:23 -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=PxXZhcH7; 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 S233618AbjGRP0W (ORCPT + 99 others); Tue, 18 Jul 2023 11:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjGRP0V (ORCPT ); Tue, 18 Jul 2023 11:26:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAEB2A1; Tue, 18 Jul 2023 08:26:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4886C61634; Tue, 18 Jul 2023 15:26:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D625C433C7; Tue, 18 Jul 2023 15:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689693979; bh=+TJ92Gupq0pfZnkJvIFO8Zsm9FylALOLZj8QN/yUCyA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PxXZhcH7MKY+vV3z5wfPbRR/veeKx6Ls5TW4S882XnV9tbZTqlD8d64+yDPZQ7qEk KEOypCkz7mEya1nKgOp6t82p8ZnW4S29X4otsZHFo4TSllqoTQE5kzcfU3FBVzq5nz qVglZcZcJHhr+BveM4TDuGRvmlPcTFUQ5Z+iRRj3IydKhaSGR17Yoydnm8tI8lqj6m DtLQy+uq/Oqq9m1Ur3FEHWSSFe27pONGg8YwwCg3ltQl0kgKoCpWqaSpe2IChtPMZ0 f9MY8RQbsr4K6/x2J1n4KdVBosBsa4MMeDbku9P7ykOHMnSttZCs1fALRBzh1iIjMp HiNjZ0mmJgoIQ== Date: Tue, 18 Jul 2023 08:26:15 -0700 From: Jakub Kicinski To: Daniel Rosenberg Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jonathan Corbet , Joanne Koong , Mykola Lysenko , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v2 1/3] bpf: Allow NULL buffers in bpf_dynptr_slice(_rw) Message-ID: <20230718082615.08448806@kernel.org> In-Reply-To: <20230502005218.3627530-1-drosen@google.com> References: <20230502005218.3627530-1-drosen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 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 On Mon, 1 May 2023 17:52:16 -0700 Daniel Rosenberg wrote: > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -4033,7 +4033,7 @@ __skb_header_pointer(const struct sk_buff *skb, int offset, int len, > if (likely(hlen - offset >= len)) > return (void *)data + offset; > > - if (!skb || unlikely(skb_copy_bits(skb, offset, buffer, len) < 0)) > + if (!skb || !buffer || unlikely(skb_copy_bits(skb, offset, buffer, len) < 0)) > return NULL; First off - please make sure you CC netdev on changes to networking! Please do not add stupid error checks to core code for BPF safety. Wrap the call if you can't guarantee that value is sane, this is a very bad precedent.