Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6031173rwb; Mon, 14 Nov 2022 13:10:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uJAiYgQFe3FXfhe/hhmNjrJYueHJao9OnkBVZNqSMrsZhg1kbkukI1XZaWLXbt2qC4UAf X-Received: by 2002:aa7:cc91:0:b0:459:4c7:60d7 with SMTP id p17-20020aa7cc91000000b0045904c760d7mr13050279edt.175.1668460243732; Mon, 14 Nov 2022 13:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668460243; cv=none; d=google.com; s=arc-20160816; b=jxvsIIqtlbTlZkVeKwGkPH5dV6wpz4sEaM1zy9WNAzRIICLzxcXNwLAMGDbFSKLVLU ypShKsMsAH9Kmj3DxYjFP9bTG3sb8rzlUtZxqkGvbMmeOhhkry9tQFvS46mQ1fG/wSuk g6wq8TUWda58bYVWuK3khkQPmj5/33Hh2ccTA9aFyB7cXn62KCvD38pii7ERFDPRe+jn 6uU6+f1j4ffXQl3qYrp39gCyJTCBVKK2P1yncaoYfGCkxQ3fYjwj8LSqRnYMBjdiIcMr YlZFTfqWwfTPetCrVZNvA7iND8ufxIAVKokyXMBcxMe/QvX9F3GAXXRDd8QRkgX2FitO 0RxQ== 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=ngVb8uJJUhIWa/AElJ6h2291IQqLZ5chCdSoy/INKDE=; b=kCysu35ksputhIuJ1U0C6IPdhnR9cgviwcaGrPtWvTghTXZDK30+Y7732nvziSPyoi JFLAzUeidQC8pxhYqW517Mb1FCGT5Ehs+JQPZBtAXClkkhxREqN6RhNwZIwYIIT4lUk/ bkh6tp2ZOzuMamPI4blMOhaZhDJyIed8JTJT7IuY3kB/6P7IKzzzP9vR+eOgxSNzA+9L R69AuRQhXoAgvitA2esRCPZ9hysVr9CeCrG9hvDFqn8JSXMVkFdV8arqeYVb+HNxReFs iC/n1AK3esg/gWd+XedQMckGZnU3Ml3OEhmjfHy6aGXVI8TEQYmns0UKvnu9rH3h656J BKXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@isovalent-com.20210112.gappssmtp.com header.s=20210112 header.b=PhXFGiSs; 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=fail (p=NONE sp=NONE dis=NONE) header.from=isovalent.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020aa7db4f000000b004615b657cbcsi8523757edt.190.2022.11.14.13.10.22; Mon, 14 Nov 2022 13:10:43 -0800 (PST) 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=@isovalent-com.20210112.gappssmtp.com header.s=20210112 header.b=PhXFGiSs; 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=fail (p=NONE sp=NONE dis=NONE) header.from=isovalent.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236629AbiKNUxm (ORCPT + 88 others); Mon, 14 Nov 2022 15:53:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236399AbiKNUxe (ORCPT ); Mon, 14 Nov 2022 15:53:34 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10AF641F for ; Mon, 14 Nov 2022 12:53:32 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id h21so7594245qtu.2 for ; Mon, 14 Nov 2022 12:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ngVb8uJJUhIWa/AElJ6h2291IQqLZ5chCdSoy/INKDE=; b=PhXFGiSsGmxHsfpNFJxPmpLKMrwuwOxrIoNKgXS8yxdt4zZ+zQocDot/VAmBZRcRwd +Er9IKtxkd5b4yBV1FZXD6hYoB8djT1LpbXoAABCHnXp639/rjrEM+Ga7L29L0dvBfq7 HVavIgkX0TOX0bpYkUFxCHeywmLEhwiUkZAeD9iSAVoRKkac5zqzcSpUCRJ0BY/PFEkJ vr7oSrENMmtwEE6kGOFo9VuDjDTqaTSPF8YeVWtuO/04qIsM2xWApVCNaNgiVok/H9z2 tHqU/UZdUPAq7FEfBuJJ3W0GHFDierX0shummOoBdytqhPnu08YPaIOtvp5ZVg0n4uJT YFVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=ngVb8uJJUhIWa/AElJ6h2291IQqLZ5chCdSoy/INKDE=; b=Zdqqwje24kO13EvWNlDhXtlWl3OgxOx1NJ/ooJW+/uD0EN9Ze/XfNtsY7k5ouVHWI2 BSB5UNSC5VavtSI+JVpsibJyeU2yKGJD0iGmFPYYKRpUU0tHvb/832xe4GVSH0umFHXv aJuf/tCPvXxsmHQk5IFUr493cTIkOFLXi3fmE3gCD2twktIMsRvBKXwN+mSxY+XXIHJL ScF7LlpShy3lk1KOZshsMj7PJ1BcNY69l/sg5jpVFA9d5qK9Q7Xh8Abc8j4ePW0DZ3Gs 6eQR2inHn97Ou67YNrw1XM6yIxgdzc0/fpfBrVvHNuGYq6j3FVn/aGr9HBb/y/sSu3xy EkKA== X-Gm-Message-State: ANoB5pnDpqfuzVUpBCQD5Jtf3PzcupwVQq3tJlHa9V8seY9lLRAP3cT0 0giquXWaJqVlFyeeDtyiqxaC6/IZAPA6SCmf4l8RyA== X-Received: by 2002:ac8:67c4:0:b0:3a5:2e13:bd82 with SMTP id r4-20020ac867c4000000b003a52e13bd82mr14080023qtp.480.1668459211981; Mon, 14 Nov 2022 12:53:31 -0800 (PST) MIME-Version: 1.0 References: <1668396484-4596-1-git-send-email-yangtiezhu@loongson.cn> <1668396484-4596-3-git-send-email-yangtiezhu@loongson.cn> In-Reply-To: From: Quentin Monnet Date: Mon, 14 Nov 2022 20:53:20 +0000 Message-ID: Subject: Re: [PATCH bpf-next 2/2] bpftool: Check argc first before "file" in do_batch() To: sdf@google.com Cc: Tiezhu Yang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Mon, 14 Nov 2022 at 17:30, wrote: > > On 11/14, Tiezhu Yang wrote: > > If the parameters for batch are more than 2, check argc first can > > return immediately, no need to use strcmp() to check "file" with > > a little overhead and then check argc, it is better to check "file" > > only when the parameters for batch are 2. Thanks for the patch > Seems fine if you respin with is_prefix instead of strcmp. > Has the potential of breaking some buggy users which pass > more than one file, but I don't think it's a good justification > no to do the fix? Quentin? I don't think it could break, the argc check is already enforced (currently after the check on "file") and no more than one batch file can be passed. I'm not sure it's super useful to swap the checks either, because you can similarly argue that there's no need to check argc is <= 2 if the first arg for "bpftool batch" is different from "file" (or a prefix). The argc check is faster than the is_prefix() comparison, but that's a minor optimization for one specific error case. I don't really see the point, but I'm not opposed to the patch either if you repost with is_prefix() as suggested by Stanislav.