Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7079220rwp; Tue, 18 Jul 2023 09:42:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHFHNLEQyqSFvdcMRD/DXQAqC72Hf95jjs3Fcd5JMapdvDMBqATozRQiP6b1YGK/gvG9dKz X-Received: by 2002:a05:6512:3e21:b0:4fd:cc8c:54e5 with SMTP id i33-20020a0565123e2100b004fdcc8c54e5mr2019890lfv.41.1689698579185; Tue, 18 Jul 2023 09:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689698579; cv=none; d=google.com; s=arc-20160816; b=ve8ALwXOVcht+zksDxHZDhnDGfVfS0GTzKqThWvf+pmXIzPogs4w9ITQCklVSMZ2O+ FeljXd1k4f1TJqoy8kMf9iAwSzUEGsrJpudbvbfJXCZDw+Eg8eHRfMmMkiCJ8A+TBll7 +ip9mK9WuX5kQJjUgDxBHVlkcDiw9ixVrC8Xd8INiuB71n5aac5DXX9ZezVaVrvJ2cH3 WLCPjNp/0qMamJtVSdJ58Fdx4jstpT9vQ46CgsVxT1Kwyxzn1QBcG71mAseu1tysa8hE vC1vMpCiosz2yd/3HRoDsLTiOd91ufqetnsecJG+ghj8DG6tDaxNSr3k0klArlAbAP9O oLJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OntbrWTAQG/PerhnF1AEFKB9M8jeJIrSqTc2k/U9oQE=; fh=5qA7X02o2skGitbAtY8yZLK4fmfA4uYoZfE1Tm/5VXw=; b=uCPcG8zvYihZDtQS9zoI+lckN1sop7vSVTBCWbAaw8P6sv2PxhmgcyA138mXZu48W9 Wf8icEeHiY5m9KpDQ2Wx5g2RxMUkEP1TfI0D+FJleivkHaYeuRDeVOaNfEq6p/bmp31X CYK9fqtXB/vf7xdmNyr+G/lj+QWmoThlKfk7B1Uke9HhkoY19oZwAupwsxUOhhZBxQuB rMSXeC1haIaTZ7vAK0BqM+22B6tqC6Pt4XeClKXWhiiWDU7dMrXvg6f68SCvC6Hs4Itt RgzIvasrrkTebBVE0HQ4aL8gm4nD8kG+JLRrvapfcPG5/Qa+4eFbX0K254e7AT4SCsun dn0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VGnT5Lmt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020aa7c983000000b0051e0fc86b39si1550391edt.329.2023.07.18.09.42.35; Tue, 18 Jul 2023 09:42:59 -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=@gmail.com header.s=20221208 header.b=VGnT5Lmt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233767AbjGRPxT (ORCPT + 99 others); Tue, 18 Jul 2023 11:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233747AbjGRPxL (ORCPT ); Tue, 18 Jul 2023 11:53:11 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC54EA9; Tue, 18 Jul 2023 08:53:08 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4faaaa476a9so9845943e87.2; Tue, 18 Jul 2023 08:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689695587; x=1692287587; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OntbrWTAQG/PerhnF1AEFKB9M8jeJIrSqTc2k/U9oQE=; b=VGnT5Lmti59eeyj2eatxU2586QG+5HxDd4I/eNRYaJaStFWcWVZiDu7NckgcIde4UK F6mKPo4mWOwK1K1nZtBslnWyWsvqbyuS9Kn7b0p1hUno1espiZ/kmNlSck8u64tM4e7B dEEPLcHZ8Ste3wuXaXMMWBFthndctigEK0MDNS4MHS9as3aga9DVX4aVJGhoZx3tw5Nj Y15fGe6c6NF+VPOK3Q4j8O5AMDzzXM043c7HZgosyIze/1RZaYOayOjD0BD0Wji01HY6 6zK+5KE8Vd8ESbEceUou+3vxrDcV/rL/v6AKNwk07pPtFuK8Oz/0g9twBTkpo2oGxCoG mMzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689695587; x=1692287587; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OntbrWTAQG/PerhnF1AEFKB9M8jeJIrSqTc2k/U9oQE=; b=R5LmUri3ygkVO/oBo8zgahmhX90A3TDlBqABEsTaeVRKUmrzER8EssVm71li6a8yqc LcbMwrPHTIvHIVgEqa0AENyc8Bh0v39b+6H1DxtFf9z2cyCoWKuUfkRx3edsqEhKMueC U2sYmpvx93Pd0LwdN4toiNKMdEkb8aTmHj5bIPY++SbU+LXbL9AEO/sGvaObagqGRZES +8Nd/1HUIaQBtmh9itDBBDuhUY7SkxbIwr9jeZj675SH3BRt6MXzsxwzNjRP5YE4cZpn D4z14rXD3KmNVv23MmYoT+wLxY32ipFTwX1NgcvakfKMnrwGQ4nx2SIIPgn/pMYC1Jsk Yq0w== X-Gm-Message-State: ABy/qLaQc5e0j7y+HGq9kMVl7Nkr63L4AbYQtVB1n76QeHqdUeUW1ltL g0yIRepivLn2nd/eCaofwxMSpszdfgk0YRDFqhE= X-Received: by 2002:a2e:9b4f:0:b0:2b6:cdfb:d06a with SMTP id o15-20020a2e9b4f000000b002b6cdfbd06amr12003868ljj.22.1689695586605; Tue, 18 Jul 2023 08:53:06 -0700 (PDT) MIME-Version: 1.0 References: <20230502005218.3627530-1-drosen@google.com> <20230718082615.08448806@kernel.org> In-Reply-To: <20230718082615.08448806@kernel.org> From: Alexei Starovoitov Date: Tue, 18 Jul 2023 08:52:55 -0700 Message-ID: Subject: Re: [PATCH v2 1/3] bpf: Allow NULL buffers in bpf_dynptr_slice(_rw) To: Jakub Kicinski Cc: Daniel Rosenberg , bpf , 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 , LKML , "open list:KERNEL SELFTEST FRAMEWORK" , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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 Tue, Jul 18, 2023 at 8:26=E2=80=AFAM Jakub Kicinski wr= ote: > > 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, i= nt offset, int len, > > if (likely(hlen - offset >=3D 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. This is NOT for safety. You misread the code.