From nobody Fri Oct 24 20:13:49 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CCBBC32757 for ; Mon, 15 Aug 2022 21:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347642AbiHOVSi (ORCPT ); Mon, 15 Aug 2022 17:18:38 -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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/s= elftests/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 =3D snprintf(pin_path, sizeof(pin_path), "%s/%s", "/sys/fs/bpf", test->map_name); =20 - if (CHECK(ret =3D=3D sizeof(pin_path), "pin_path %s/%s is too long", + if (CHECK(ret >=3D sizeof(pin_path), "pin_path %s/%s is too long", "/sys/fs/bpf", test->map_name)) { err =3D -1; goto done; --=20 2.35.1