Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1226629rwr; Wed, 3 May 2023 11:54:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6fAjhfWpiTwosMw2P+rsH3C/AraHlIBy3Mb+TqBZyUDRmq7FDHRSGoWek/L6YIyfIQAY6t X-Received: by 2002:a05:6a00:b84:b0:63d:3a18:4a03 with SMTP id g4-20020a056a000b8400b0063d3a184a03mr31566246pfj.5.1683140061583; Wed, 03 May 2023 11:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683140061; cv=none; d=google.com; s=arc-20160816; b=eFiTlU5w2fCNMElScTQSNimTAHoansKyQfWNOXRnXOPSFnbafJ2TddLty6R798/G4c CVMb2nca6tVSFwToLsben0q4hGftjQcgeKTkGoKHQsVX8JI7qQ8xDrA5v+rVGmne6k1A s16lLiHypcLgIFeJ668bVk5Cg0VALUr61woEnHJCHa+oCa8Vo2Jt8vt/5XG/nbWZv0I4 8c4ziMMi1+UNDDYX9qe2q3y9BbwW9vCLbVKfrccJUchsJLANd5HhdL4kBTnhJvGl20+3 NKsKCsWgeu84QYmUo5XPI8dYwhc0Y3cb4Pd/Yv92d/Un7hJBd8QysLHB/q4MGCJ2eZ6B KxFw== 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=VD37naz1y4adnKBHCi37A5366cr37Qr3DhQA4M+9vdQ=; b=Vu7yIdEtlT0Ho9BHVWBcu5ANg6BXZVgRAJ28BY5fk74HAQeca496ihpM0l7+d7Uz3f 5O0kuvVdG7xSnqjnIi6fQIHQP0HscaynTU2urZ3RhyG+cAqOumkRFWlfn6iVpgSgJuq2 fIJVTkvyXnEENT/OBr0ZLUzd2KdsKd5WS7Qz1n+O86s9ApTicHAWj6urujlFIvEb3Ns4 L0AG+OTZTeFTxOL9yeuVehVYD7QHbCFx+0td+p68XN+WorOPq1s+NAD9A6O0AjUNRuZU bgI2N4D4QFC88hG6MND2yFqQ9hsZJO8ao3//iCQBXaCYtyEZYNSz/xxQ/KRCvR3mRWIg ItLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jkHZIic4; 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 d79-20020a621d52000000b0063b8e26e438si33518856pfd.97.2023.05.03.11.54.09; Wed, 03 May 2023 11:54:21 -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=jkHZIic4; 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 S229555AbjECSuR (ORCPT + 99 others); Wed, 3 May 2023 14:50:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjECSts (ORCPT ); Wed, 3 May 2023 14:49:48 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37CE619A8; Wed, 3 May 2023 11:49:28 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-50bc570b4a3so7792753a12.1; Wed, 03 May 2023 11:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683139766; x=1685731766; 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=VD37naz1y4adnKBHCi37A5366cr37Qr3DhQA4M+9vdQ=; b=jkHZIic4zMoD2D2yKKLHoDBj8KjdV3nyMVlwyyr0FnYbpXXvQv6KGvKRQHhFePhJwN y4a4OrmvGg+JAf2TIM1ezAvyCU50MiMjI4z1u0bIQdNDaDaf7haDBipYJRCznMo2i34D qEPDeWxhj8DyfuAPO50Ocg8KfSuYD+iBekQZ9cT3B/fjBzeADPWq95Zcwkw+Ha72wlpL s2iH79GfwdYK15llrl7MI1tQ1dwdetsOMBH8A5cbzI5ndGgMNxhdu11RyoyfdVoB/Sbc sSYeyMMt0h63uIaDqFvaAv0/yhBWU8dgHdoeJyMi+mUFXxuyG/3dMAOvY470EPraBy+j XUjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683139766; x=1685731766; 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=VD37naz1y4adnKBHCi37A5366cr37Qr3DhQA4M+9vdQ=; b=fZCq2oQqADWNkSvCpwh5JtAMddvcfNJAXdbvXUxoh+YGFt3FLqpmkmZyQgKPKzvrch chLErvNpMmUzZUMnUpphgKubhioV/ZgpbRAc3JWhPxTxhTA/TBw0oxu6P8sOX/VHH6LZ 0cAjljzrJfc6dhW0oDIVrhDJLHavSnq18XvwdKLQOsbCqunTVMCYzoOgPgvqaeONNow1 OmSI4qck/x0dXpT/uQ40aCPIW+hjwndafAcuUJeEKKVJJdFNEf/rq7VrqoVU4tcVJ+o2 XC/j4WYqPaGN3ixGJSq2qGH9r9FUyOIIRl0/IVCPnjU0ttZiidCC1g1++Rq1eow03SMg uGHQ== X-Gm-Message-State: AC+VfDyrJWQuqF1KEmwpyWx3Lc7l4BtXAVKQEQkbSp4k02GhyAWyiGaS EXnwQu4OtPnZsWV3ZgLonw3bwcZrtDZcOb3NX4o= X-Received: by 2002:a17:907:844:b0:961:69a2:c8d6 with SMTP id ww4-20020a170907084400b0096169a2c8d6mr4206788ejb.69.1683139766485; Wed, 03 May 2023 11:49:26 -0700 (PDT) MIME-Version: 1.0 References: <20230502005218.3627530-1-drosen@google.com> In-Reply-To: <20230502005218.3627530-1-drosen@google.com> From: Andrii Nakryiko Date: Wed, 3 May 2023 11:49:14 -0700 Message-ID: Subject: Re: [PATCH v2 1/3] bpf: Allow NULL buffers in bpf_dynptr_slice(_rw) 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 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_NONE,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, May 1, 2023 at 5:52=E2=80=AFPM Daniel Rosenberg = wrote: > > bpf_dynptr_slice(_rw) uses a user provided buffer if it can not provide > a pointer to a block of contiguous memory. This buffer is unused in the > case of local dynptrs, and may be unused in other cases as well. There > is no need to require the buffer, as the kfunc can just return NULL if > it was needed and not provided. > > This adds another kfunc annotation, __opt, which combines with __sz and > __szk to allow the buffer associated with the size to be NULL. If the > buffer is NULL, the verifier does not check that the buffer is of > sufficient size. > > Signed-off-by: Daniel Rosenberg > --- LGTM Acked-by: Andrii Nakryiko > Documentation/bpf/kfuncs.rst | 23 ++++++++++++++++++++++- > include/linux/skbuff.h | 2 +- > kernel/bpf/helpers.c | 30 ++++++++++++++++++------------ > kernel/bpf/verifier.c | 17 +++++++++++++---- > 4 files changed, 54 insertions(+), 18 deletions(-) > [...]