Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2825148rwb; Mon, 15 Aug 2022 12:05:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Aen3rzsmfQ8mjIH5jzuZnjTVfcnbWPBsfDTYfGE10lH37IeRyPnKv0N83+9DtHCPirs5g X-Received: by 2002:a05:6402:1943:b0:443:5ffb:b04e with SMTP id f3-20020a056402194300b004435ffbb04emr11356681edz.230.1660590343698; Mon, 15 Aug 2022 12:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660590343; cv=none; d=google.com; s=arc-20160816; b=LZYnbYq40kQlKzV9cPP6j3jm/dtJqWeZn9JXRv6rq8GiKiFI4tgVUWz0dBj1w+D6MC tWikmqCoAgsbwiqsf06568VIT/jJlXbiItiMLVtHYtif30TteaauW4QjamnHHSUPIy57 ZfNuzbGdm1St4zeSfP9F41QSmV0L3vP69N8En2q3Ii5Cj2lssEj8mdvii49uP9sSb/Pj E+g7fVYu6IwyQs6zVZSppWOspDMaYzAGPM3qcnkFiQ4vq7s4CKGMZPk79iJZudsfe8Q7 qSl/rlpUy9zfiirYipYKToEx8867bcoxk2zjSK1AHda4OQ2PthUlBffh/iUxSWb70d40 +3OA== 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=uqLZyb9J8wvXlOwljyaHMogMcPsBOUcXfZyjRhyzN84=; b=NW/FLKdcXBKPDhEbZi4JNge/bsCYaDVZ0QrjTL7jmPlbeLAXVrC4SGsJRxOH0ofD45 Rmw/wAlmtraHNu5UKkCbtHGBhFRVQJJNw4t0au72jqB63RaWDtK8OxZ0UkXFM9enfIGW mrV1cuVsAKeNDjUltwcz0Bs/OWyFaZ0c3HzA1+0VZINSk7E77Kc/mjBuDzqhqcBiYwN1 8OjAov9K0HngUZy4xOtLLrYnaSMHZ6YOKpjRQxG5Ti7Q+dGZ/UZdksiNxADpXJ3MjvI1 q3f2APIYVGO/XKawR84H48YjzIzbiTkcXJTapxiEyKk/L7Ri4AWJi3KCNbWTXgNJFSPa rDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEXFY1xx; 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 o11-20020aa7c50b000000b0043da70a82f8si8230564edq.117.2022.08.15.12.05.18; Mon, 15 Aug 2022 12:05:43 -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=kEXFY1xx; 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 S245124AbiHOTDa (ORCPT + 99 others); Mon, 15 Aug 2022 15:03:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245022AbiHOS4d (ORCPT ); Mon, 15 Aug 2022 14:56:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 593273123E; Mon, 15 Aug 2022 11:31:12 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C1A9061029; Mon, 15 Aug 2022 18:31:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD37CC433D6; Mon, 15 Aug 2022 18:31:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588271; bh=cTSrOZZlQgwy0HFIlp6AGXKL8rVxPWkxyDtUG4Olxmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEXFY1xxHiKlKzM63U4MhLUoSnWchax/TlAZQ7mcX1Mi8hXZ9OVL5+xVxmDP0u14L 9KLSD3Yh2jiIdc+wIn5x2Tb6cA15eATFB1Z9Ugyp3/4urI7DEpjoqvUmuKlJIXEM2O FdTVa17QNnUYsHQLSJVuAaPq5CtwgmI3b7lvB/ZE= 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.15 349/779] selftests/bpf: fix a test for snprintf() overflow Date: Mon, 15 Aug 2022 19:59:53 +0200 Message-Id: <20220815180352.150562016@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 649f87382c8d..50afa75bd45b 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf.c +++ b/tools/testing/selftests/bpf/prog_tests/btf.c @@ -4913,7 +4913,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