Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp517643pxb; Thu, 9 Sep 2021 06:17:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQNFxQJJUU7p7+DGOK+SQaa/wU7mrTzfuTGF+Oiug1Brab8bSZLFfoOStrFk8uKH7ZmeUw X-Received: by 2002:a5e:d80a:: with SMTP id l10mr2569461iok.36.1631193446624; Thu, 09 Sep 2021 06:17:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193446; cv=none; d=google.com; s=arc-20160816; b=rYsGM1Vvabf+PXz+XQgSIjToSCtcHus47Im3C5oAFFFRuTOU3ap4WSb8w0CYeilJAU 5vSXZ7gZrNEYd/ze8LEuhs6VeNZXOi/SzTiaGcr2MU4HZBozK1cbbJOqtBFhpjwXcqCC Ni7vJMLJ0TWs3t0H7ETLpiBpRvGGwA61FHLi+5IOOYOHwEqTc31tT9qhNGSoPqaR/q/4 NeQbaYvKVGluMOvZ/MxGY/k8EkV69v8SOmurmJopWzasAlecqLOB1on7+0x9TrewH927 mXdxlUMMuQ3QJY5JUyzXqzrHowyvCxg/8s51qZumhtzPQm1c1r0UPFhU+LjCUDrBoE3T dOUQ== 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=6am5IA9MJO34S5AnawMpHI7+ZrEfRKwZuIASfL99UBI=; b=r5ctpzV5N9hGX6HjOjy2iHoZ4hUE6kS/xrN1+ytGYlD4rqQGQzLZWi5UZe1dGUEuzY ZCAyvanmn4+8GEPFsSMrz6IG8UI83+lX+zEiVFDGtyQ+HFwt5VRLMHwgAlEDpkYN0mm4 msRMnQQbGaXVqkAevnfnIKVh+nl4BGZ3KjZ21qNWcA5nOXWhCJxFs2IfvX2pTybb9RCx BASWUX637Sq6Wg3rmTv5zwgC+FyLAek7sOgTZa/tDM0Q0R6Y8eFml5Gxm1VpNW4l89BB RxaWmmSw1JX0cCMc3muSL2/YAwWgDEkdfzfub28KNW/KAX+hjNZh1uQ0BVxxy13V3AOb oYvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i9lxA/py"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z23si2038631jas.40.2021.09.09.06.17.13; Thu, 09 Sep 2021 06:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="i9lxA/py"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359066AbhIINQJ (ORCPT + 99 others); Thu, 9 Sep 2021 09:16:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:46258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357658AbhIINDP (ORCPT ); Thu, 9 Sep 2021 09:03:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E61DC6328B; Thu, 9 Sep 2021 11:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188779; bh=H+isFLhv7fXZadAnSAxSil/y1Hb6bZxn8GmeSiUGOhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9lxA/pyBd8kAXRPYrXb/kW7V0rs+F5l/l3bKmqoLWXAXCvho4S7RKTCAWTeKgGnn E/gzKyFYYVXD9E5SXw6rPa7zAHTqY1R5moycTiHKmOHkb696PCgSDlNVq0Uqzb9FW3 9k5wDkgofrTMF5H4nbwMx1+TEC52TrcZ9653Pw1sWm+qGm1RfAkJmCi03693pMtKdX fo7NDNDI/IzCb6yrzROUwoDwsF+HQdKf8ZxOrgUwVT94dqB4UTwxw64xUzhgPiJdRH mcMJQbrA+yIMro03vhYF9Cd43xvs6fkZoYezwoheIml/9WDKZ16kSC3hP5AJcIqsfV 3jeDsSSU3RCmQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johan Almbladh , Andrii Nakryiko , Yonghong Song , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 31/59] bpf: Fix off-by-one in tail call count limiting Date: Thu, 9 Sep 2021 07:58:32 -0400 Message-Id: <20210909115900.149795-31-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Almbladh [ Upstream commit b61a28cf11d61f512172e673b8f8c4a6c789b425 ] Before, the interpreter allowed up to MAX_TAIL_CALL_CNT + 1 tail calls. Now precisely MAX_TAIL_CALL_CNT is allowed, which is in line with the behavior of the x86 JITs. Signed-off-by: Johan Almbladh Signed-off-by: Andrii Nakryiko Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20210728164741.350370-1-johan.almbladh@anyfinetworks.com Signed-off-by: Sasha Levin --- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index e7211b0fa27c..1d19f4fa7f44 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1095,7 +1095,7 @@ static unsigned int ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn, if (unlikely(index >= array->map.max_entries)) goto out; - if (unlikely(tail_call_cnt > MAX_TAIL_CALL_CNT)) + if (unlikely(tail_call_cnt >= MAX_TAIL_CALL_CNT)) goto out; tail_call_cnt++; -- 2.30.2