Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp625210pxb; Thu, 15 Apr 2021 02:43:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBUHApa1zjSl+smmMy06l2bAG+KqbesD+k6/zy50YhxYTXpvpX7ZTcdIVdN99FK+Lm18Zh X-Received: by 2002:a17:906:5e15:: with SMTP id n21mr2461219eju.57.1618479823531; Thu, 15 Apr 2021 02:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618479823; cv=none; d=google.com; s=arc-20160816; b=GgdxeECS7aSJCsUKz95emH2Sa5x4DHaFbqlgEth4Os0rIboIld5o0JVQL4AN5jZWKs N0Zh+vAdQlhUmPbkqByAUGaf6uh4I+YjbjIYueK/qkzoUCIR5NLSV4UbIAsp0EwgYDr9 3mMoQRbRt8ikGu3zmNgiRXibIS+BUbjyfhqzusP2aSUYgb6r3fSPSu3I1hmhU7HLDytn HlT9EU8DklNHyMA7zcGbrSDWxPQJW1tjOa7kYKtjwyt/xN/MXQKwpPJVKjIRUlUOATEs yBOxUKzkNp1KSxIC7a6311WP54XLdKCT38pEwT25M9LPa9iB65/kzV2D9EoMt209E4dA MYlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OPgFWlOukLXcxKTGO6irUprnq/4nHV4Q9KnPOIDBncA=; b=TvxjenbOu4JxjGbQqbXqRnUUTRwi5vEb+vUgiuWTyFRZKcJjzrb6Mm7a7Ui14NPFrk X9xm0QwYliQkYStEqpUxAQChR+7gjNjrkP4hHZZNz2n/LZwCsIVswQAib7sZjgeFO95d ZkH9wNeM0RDh4l55Bf3doUTyAsvzVfuB8FY/s4IVfCLFn5+tc2MFoBM8NK1EVzzmaq+R +8Bw7cGPHJDa0yC1CEMLQp/LZpKcRhq1GeR+KFfGJ5d2QRxKgvPBVCdWE6rv8dAVUPFx XuOtw8tAPshFXmRgsE4cOn0wd6Iaglgg3UhmyrrY8+2E0SUxGshloQZyU8IYou2EkBm8 vJJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=A4Ulwq6R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si1897377ejc.214.2021.04.15.02.43.19; Thu, 15 Apr 2021 02:43:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=A4Ulwq6R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232132AbhDOJiv (ORCPT + 99 others); Thu, 15 Apr 2021 05:38:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231309AbhDOJii (ORCPT ); Thu, 15 Apr 2021 05:38:38 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 254D4C061574 for ; Thu, 15 Apr 2021 02:38:16 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id b10so23585824iot.4 for ; Thu, 15 Apr 2021 02:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OPgFWlOukLXcxKTGO6irUprnq/4nHV4Q9KnPOIDBncA=; b=A4Ulwq6Rh/qbp/3COX+y1Bp6wCwZvsZbFa2/shD3RdMtC+Bp4OIHe98dW7NmtRzP6n kFz7rAbDa19iXTIbRMlkry6i6mDznRlQNT/ghDF9gkA1GakPRdraf+wcOvIpVSb+tP1N 9o/GW01w0QH9XZRLwEn/34ZZu5VXGH0udyGiw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OPgFWlOukLXcxKTGO6irUprnq/4nHV4Q9KnPOIDBncA=; b=X1ELOxmJfvG4N+RZuzvoGt/aRMgAk1UZnExNgbSDRe//vLIdp82eDYi/rTv4kpp4LN vb9/LXqq7zufTC23XmymaytlY2vRm9iZctx2t7vKY1923oqrkoJdkqVoHh3yuasJslwz /4Tv7PpyZ6VZlG8HWCXxGcLiyMmYTrkzKiTqI1pV/zABTurzrpvFZB/9PVx+1oExz46Y pcFQ7REbesNVAHLkzbzEhAW5hlJ7GROj/XlqU75gG9eLv2oApmBfdidm+mKgTxsN+Rlu ZyImfCJsfmql8zcfoOa+nH6cNNGW0RCPlRR7nz8LINInZ+0DcjqftbUG8mX2Zs1jFx9B HwkA== X-Gm-Message-State: AOAM532XEuxqRfD94HOPkPWb8rzRWdJ3Y1RglGpiuq8aw9JxoPopClZC C66pTW9FcmXJxir1rujL3mxCV9jPWJvx8+E3oAFsrQ== X-Received: by 2002:a02:662b:: with SMTP id k43mr1983699jac.139.1618479495616; Thu, 15 Apr 2021 02:38:15 -0700 (PDT) MIME-Version: 1.0 References: <20210412153754.235500-1-revest@chromium.org> <20210412153754.235500-7-revest@chromium.org> In-Reply-To: From: Florent Revest Date: Thu, 15 Apr 2021 11:38:04 +0200 Message-ID: Subject: Re: [PATCH bpf-next v3 6/6] selftests/bpf: Add a series of tests for bpf_snprintf To: Andrii Nakryiko Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Yonghong Song , KP Singh , Brendan Jackman , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 12:16 AM Andrii Nakryiko wrote: > > On Wed, Apr 14, 2021 at 2:21 AM Florent Revest wrote: > > > > On Wed, Apr 14, 2021 at 1:21 AM Andrii Nakryiko > > wrote: > > > > > > On Mon, Apr 12, 2021 at 8:38 AM Florent Revest wrote: > > > > > > > > This exercises most of the format specifiers. > > > > > > > > Signed-off-by: Florent Revest > > > > Acked-by: Andrii Nakryiko > > > > --- > > > > > > As I mentioned on another patch, we probably need negative tests even > > > more than positive ones. > > > > Agreed. > > > > > I think an easy and nice way to do this is to have a separate BPF > > > skeleton where fmt string and arguments are provided through read-only > > > global variables, so that user-space can re-use the same BPF skeleton > > > to simulate multiple cases. BPF program itself would just call > > > bpf_snprintf() and store the returned result. > > > > Ah, great idea! I was thinking of having one skeleton for each but it > > would be a bit much indeed. > > > > Because the format string needs to be in a read only map though, I > > hope it can be modified from userspace before loading. I'll try it out > > and see :) if it doesn't work I'll just use more skeletons > > You need read-only variables (const volatile my_type). Their contents > are statically verified by BPF verifier, yet user-space can pre-setup > it at runtime. Thanks :) v4 has negative fmt tests