Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3031271rwb; Mon, 15 Aug 2022 16:30:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR42jnqxTve6IbUA4A3by2Ko985rc8TfEqH+pXeRtCA4JYPPzyMXEp4VlJpzcYcHhyRFJhdU X-Received: by 2002:a17:907:1dc5:b0:730:aade:95fb with SMTP id og5-20020a1709071dc500b00730aade95fbmr11534144ejc.520.1660605897805; Mon, 15 Aug 2022 16:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605897; cv=none; d=google.com; s=arc-20160816; b=HsmXVLY1l08q47PDx1Ls4Dnc0EmgU2+NQVGJb7Na/+X3BIDuy1Wgk47KFQoSo6LjGW KhI2AgJ1E+rHIovWWyLOpXIOggjxU75I06g0cJjieoTiYbKCUJSsqvxB39Byd1CqBZPH zq8BMnzon9BbqNRGZII2A9DC1p8i4NCoeL0T8E4LZhjQt9XcAKdH8EAjY+qrCOnQzaEg W6op1XMrSbAhHpItVHc1VbjbLvvmak5b9tpXj5TxnOstZbwxUuCWx5ICOWqcyaKADBKm 3G45qU0jj8E6KIuCPTPPkGTv0tfCPjFZwlDBKw3apq4ezoY/lK2VVRtnI577jqA2m4ig UHkw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qgJPa51Kw2nOVIPsre7ArtYEwqiuTbbCyp4BpDAgTjE=; b=wUWod8XMyVpBD1RCUsN+mPyVdUlLIB+xQOYc45iNgrSV35+jBlTqjwiUyzAooUoi7H +i5z7gTFoAxhqwg0F1f+WwYdU/moA7Cmf4qLFSijvNT7mmA6icifv3qZWqbIemQqy7b/ Vtl2pS3P0GHfrtJnFgVESl/IVJ6PyI2ZV44aGchOb+X/Rfk5u+jbO60FO9EfC74ETply rF/kvNkrvg8BUsCCcJJu0GYBtKwE4TFr0rZHtaz6+r0BllF2J234SGfXlCNsE3gBNf+P 6XTliWglINizjhjhHxSE8MQZR783t3ZyZIU8s8oZSyb2K51lsR3uE8iL/jRXMk2XEaEg 1yxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rclxg+/w"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp26-20020a1709073e1a00b0072ab4b5ffe5si10164598ejc.987.2022.08.15.16.24.32; Mon, 15 Aug 2022 16:24:57 -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=@linuxfoundation.org header.s=korg header.b="rclxg+/w"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347619AbiHOVSg (ORCPT + 99 others); Mon, 15 Aug 2022 17:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243585AbiHOVKF (ORCPT ); Mon, 15 Aug 2022 17:10:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C27315509F; Mon, 15 Aug 2022 12:18:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 126E1B81120; Mon, 15 Aug 2022 19:18:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 625B7C433C1; Mon, 15 Aug 2022 19:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591136; bh=zo472JXDZC4ztxKvqyyytsSeGVG+XJDGa+4eATKg5Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rclxg+/wJferl0senWSDyT4tmR0r4yXs8eVFPi44i7UZ/7hh43HRcMioXKGOTPTEl WSIfyHnMeh0wEuB7FfM+Ad8qRkVnN1FlYvsRIBdH/euniQvmkrySOCnlplefux8PNL f9sA52ltqI2Wky60QXfNdVsH7XD6VkNqg5F0jx+c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Martin KaFai Lau , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.18 0483/1095] selftests/bpf: fix a test for snprintf() overflow Date: Mon, 15 Aug 2022 19:58:02 +0200 Message-Id: <20220815180449.544839968@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Dan Carpenter [ Upstream commit c5d22f4cfe8dfb93f1db0a1e7e2e7ebc41395d98 ] The snprintf() function returns the number of bytes which *would* have been copied if there were space. In other words, it can be > sizeof(pin_path). Fixes: c0fa1b6c3efc ("bpf: btf: Add BTF tests") Signed-off-by: Dan Carpenter Acked-by: Martin KaFai Lau Link: https://lore.kernel.org/r/YtZ+aD/tZMkgOUw+@kili Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/prog_tests/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c index ec823561b912..a294176f8a9d 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf.c +++ b/tools/testing/selftests/bpf/prog_tests/btf.c @@ -5226,7 +5226,7 @@ static void do_test_pprint(int test_num) ret = snprintf(pin_path, sizeof(pin_path), "%s/%s", "/sys/fs/bpf", test->map_name); - if (CHECK(ret == sizeof(pin_path), "pin_path %s/%s is too long", + if (CHECK(ret >= sizeof(pin_path), "pin_path %s/%s is too long", "/sys/fs/bpf", test->map_name)) { err = -1; goto done; -- 2.35.1