Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1020607pxb; Wed, 6 Apr 2022 06:55:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFxdr9aFNQ4E+nPsmMSQRjjHvf1M7BkkDA2NdszKW5gDwzIKcrn+ESN/2AybLPvM8DdIDq X-Received: by 2002:a17:90a:d3d1:b0:1bb:fdc5:182 with SMTP id d17-20020a17090ad3d100b001bbfdc50182mr10129459pjw.206.1649253320135; Wed, 06 Apr 2022 06:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649253320; cv=none; d=google.com; s=arc-20160816; b=uMEZYg7H2mBa/t4ZWtXhvCSjnZOYI3UP1ldw3yCDo2O/2uz/drqlZVF3J6aM5BEdZl Jnm66SBywE8xz0Fey9i3QzTl3kPO+4asgqR7yXc/EM7+Elt9xZ4M223Kv+tpbQScro+4 c2Dq4hqTWByCmHcucSCb0F5NLLz6rywTGboc8IWlD+gZzhFRRk4azkVow2eQXr/8E2sG SG/ZoiqqT4+Ah46pXj5ksi+7XEl8RnZbvtWo+RJ6ZBjtWEGLEYXT3BACzKrkSzj4YrZm qrbFKimZK4zjATPJgGybH7L5NLcuR4lZiE+trdvb/etgqKcNfQNomP374gDALF/w06fr GG4w== 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:date:subject:cc:to:from :dkim-signature; bh=FGwusd761ZZmZCn6Lx1iBjIKmRJjAIBS+Tn3Y7KvQk4=; b=eDbChGm0LmC3quJuGMP64vBB7lt3gcO18rqVEGNSUyhZz6neqWWhdJdlr2nchz2j/M LHAix65xwpNg2edmEJkd5erqt2JYBns7et3baZKPdZ1tnKWRhx7fwqG4qSt5x2pARF1s B3AvJUdsq+5aW/TQ2OXXyrf3fIeiYtPoz95lj/7FCcwYxLGxoxhhOcYj0U7EaSf64jJo xk1B6jlYrHSVDwzBSfK/Grhlr5/DTgHdvvVNSiDYn22ETLdGnmceggj2Bwfq4BnYQCNc dSBS4kEy058RduS8stIvyO93eeH2x6a/zuXNsZMB6oLVRGhp7Sej7NkP5PQyi2XBu3Cm SJZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ogCxh//S"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o16-20020a170902779000b00153b2d16542si14690338pll.330.2022.04.06.06.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:55:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ogCxh//S"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 039C743373A; Wed, 6 Apr 2022 04:49:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348170AbiDFFtV (ORCPT + 99 others); Wed, 6 Apr 2022 01:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2361726AbiDFEb7 (ORCPT ); Wed, 6 Apr 2022 00:31:59 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB40B264F68; Tue, 5 Apr 2022 17:36:30 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id n9so574315plc.4; Tue, 05 Apr 2022 17:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FGwusd761ZZmZCn6Lx1iBjIKmRJjAIBS+Tn3Y7KvQk4=; b=ogCxh//SGlbIZda9y8AAuQpajUpqX7pWroQr5OGfPAfgwVA0OEonu5uJ7pLurDzlQU VC1fBekbyF/svKWuIsGA1yIhxv389X+jGpjtGjQND8Udf8NVpTQPkACELsMUOpUeqJIu NgSRZv144GI3Ry/Oh+Vbn6mSlXbjwdr2MeHrsxzErbIdWd42brCBDooAI1lsyDROZ8xZ w1mnsPBhRr/Z74YzIPsPuCI73vOKEr+DVuZfS3qzuZyslX+oz8We8AryP44s8oMswyT9 J5PsX7xHBWmHLwiwMBDikCzMRAp/OJPTy/acb1t27gu/3W7eolYvRwgt/81kxjTF1Gqr xSHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FGwusd761ZZmZCn6Lx1iBjIKmRJjAIBS+Tn3Y7KvQk4=; b=5v4ORP3y7qbj94znYIL8nA0zQlvhRAubAUVcCaHzX1n9VYDLX0Qm1XrKj0GEVwritc U7Voupq4WeXjnxSFL5JkGdqDod0AzQmmfmEhs8xJODiSsDR9ZC2NKY1th9vb+iJXwZ0t safN6fjY3eyBEHnDvsBsWrycknsI9ZxVKfgczVXY0tIO/ilov60FD1waXpcC+LLudsBv kIMIYXbFqgzADfmMR06p/AwCjaNl2tEm4syyBF5E71p3xZpJBes6V0Arz+z0EnWx+lBv 8UUK0jlBojaZaf1d2OX1fjPdW9L2Av3/MO42qTJQ+p2j8015LLoNvNJPtWFNeFaCzw+l BEKA== X-Gm-Message-State: AOAM531RepU54F0BAQ6/FgHfkyxm3CAB5UZdy7/LIX79GJZwyioXzCQy m7jr208jbUQOKVWWmNEkVMa9QicVgT3rtbeD X-Received: by 2002:a17:902:8644:b0:153:9f01:2090 with SMTP id y4-20020a170902864400b001539f012090mr5925967plt.101.1649205390463; Tue, 05 Apr 2022 17:36:30 -0700 (PDT) Received: from localhost.localdomain ([223.212.58.71]) by smtp.gmail.com with ESMTPSA id t15-20020a63b70f000000b00381510608e9sm14387946pgf.14.2022.04.05.17.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:36:29 -0700 (PDT) From: Yuntao Wang To: Andrii Nakryiko , bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yuntao Wang Subject: [PATCH bpf-next v3] selftests/bpf: Fix issues in parse_num_list() Date: Wed, 6 Apr 2022 08:36:22 +0800 Message-Id: <20220406003622.73539-1-ytcoode@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 The function does not check that parsing_end is false after parsing argument. Thus, if the final part of the argument is something like '4-', which is invalid, parse_num_list() will discard it instead of returning -EINVAL. Before: $ ./test_progs -n 2,4- #2 atomic_bounds:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED After: $ ./test_progs -n 2,4- Failed to parse test numbers. Signed-off-by: Yuntao Wang --- v1 -> v2: add more details to commit message v2 -> v3: remove the first part of the patch tools/testing/selftests/bpf/testing_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c index 795b6798ccee..87867f7a78c3 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -60,7 +60,7 @@ int parse_num_list(const char *s, bool **num_set, int *num_set_len) set[i] = true; } - if (!set) + if (!set || parsing_end) return -EINVAL; *num_set = set; -- 2.35.1