Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp448394pxb; Thu, 9 Sep 2021 04:50:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc/dy0o83mYlAZks4oEF1Q/1fGOOjVtcZul69tBwLeci+wPnWcOlpoTpZxRI02+cjCxdYz X-Received: by 2002:a02:cb0c:: with SMTP id j12mr2373909jap.83.1631188226595; Thu, 09 Sep 2021 04:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188226; cv=none; d=google.com; s=arc-20160816; b=Z42f6K2eyZc9Ked5xQ8rQjFbNSTHBx9I9jhNMm1ZoeP9w5C3jjoO5UfrYRZXEtBf/L ptdRhK3kVN7/Xhb4Dh4GnHIRdF5LlJxYmFK02pKntlzB1tgzjsyVALyaoUw6SnEGLmP7 aDG7otaSPrKn/l5xxTsvZuPzdJJ224cl81fXzIcWs8bEqwpEzddokPt84qK7GkvXOeTn Ge0iOgTW98qNFKNrvLXzr25delbDevkc7u8y1qLmCBHSJyf/vgHXOy+p/Bvhwe4Bk+VV K+QZiOM7jb6FKF1QdE3DFt+qdTAonyKXJsg/J4AAojdJBOlalWJlDn27OmYkQVccdNw+ 0x4A== 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=EnizJUB4jUUaIAUj+bBl5U+CfoTlvKSjuldFdWBtO68=; b=joTggqvuohI4TAtLLrIcyovzn2C/YGQ1r6UEmfU3xRF/AcP62MihnS2l1XMz02Tf9t 6M6Q4e/jw4exiZAoWNRI8BE200DgO8SI13AHL1LsWNEmI5gBdzJISSOonJI7BSMtUDL0 xQSnq5sWfMBspEL/M7HAv5E5Ecm3l9Nqho6b/rYOOe+gSm3VwtThi7wX7dy9F4msVN1v nf8IIRQoNsZDS7RcPXLMQu1YC5c2vof3bcQB+qxw4AaErWPVZDOOgCusu6FMnUr3++Jb 6j1r2/hTxkdA9039VzOS9Bty2ij5nADYDe3iMULRepG360pHr0e+UhF43OKvGU0xwd2/ PVvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RoN64ATk; 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 y6si1370947ion.66.2021.09.09.04.50.14; Thu, 09 Sep 2021 04:50: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=RoN64ATk; 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 S240711AbhIILuc (ORCPT + 99 others); Thu, 9 Sep 2021 07:50:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:53686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241724AbhIILrt (ORCPT ); Thu, 9 Sep 2021 07:47:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8FF0761252; Thu, 9 Sep 2021 11:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187796; bh=s6XsWzVWqD2vMfqoDgZZEKdCdulOgvw3qFos1Sot6d4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RoN64ATk8rF8doMIyYjY4GyC6apzMH7ru6q9kCDOj1JqqSHWmxstc7iTtRKny7dcL OtD0Yh4LapIMxGSWFSuL3rYM3aqAINa4VJZLxN8GKHhsItso9WHBkXe4pTJeMh3s+f 0BHgtHPkJ2N41+dFX5ft8DKfupcf3eU94mcGZ5Sts19AVpDXMpSNJf6TiNjGPHkpNE 8WH6z1VDsATn5D6CHA//mlI7ivEliQ7WAj6rshGlxU6LdFGBUkIu4G+YfJLcP35yI/ LKiEZXI6Guv7qtjyfV33ZNIV7bLD19w1o6M4BQ9F0OArzQXad5Zcg27xKVQci4PV6D tkFbMfIXdJQJQ== 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 5.14 101/252] bpf: Fix off-by-one in tail call count limiting Date: Thu, 9 Sep 2021 07:38:35 -0400 Message-Id: <20210909114106.141462-101-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-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 0a28a8095d3e..82af6279992d 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1564,7 +1564,7 @@ static u64 ___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