From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380527; b=2soNigHYa6z80mVmFdme8To6A4vDX9+LuRYwYqxJmLbARG3Wd/QyV9wlV56LgbS8KEsO ADp9MEPm/5ad1/SklFNrNqthbLZYo2ERP0yP+5g/oAl9pCa/aFaiqoJMAE4hBdK2928V7 5iWetP+LWSIAs7oFzZF6Sa+jvciBB8KwgJV0enrLXSXQdNcYB2hEWIS9I3TeJIqKAxflF H/PAhsfKHupJoIwlRj1VO0so5s3l29KShshA+6k4oCjZQ/5rVriOx+IEeB5S3MrGIin23 ymapoVuheh8Dgy8A4n6TCXJLnIuZIq3qAUr0xjZMvz/5NpabL7eHbfa2xy78u/1TBTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380527; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=nlpwi4O0Klku/NbQekZ6gV9SAKY8oh7Iwi1T4Ltmesw=; b=UxRMAEgKgnDJ++ygHX59JAWmRtZJAdjaC5rmzAD0LlAIv/980tp0WPMyT7mOH3CmHDxp m1krdLy+Eo6oCFoMob299B71YWX1yx0YY6jgOaU3OlRsDuhfwVhxqrdBYqYmJebFmmk0N VsGVWlguPJpDA9QT6lWhySmuaIdtrwIm+mlslvRWYZN59V3S41wXVePtI6/zr1+R5JrnB uJvFYFA/HjR4mTmJU7d9456YhWAGw7tZmf6OLbSuvzLkvirpOYfYwys47vjeYQ6DVGjN9 VutThjqE1PiRrM4v5v3433PyxulE9ONnGwsYYZoRvBai4PjvZX9yggaxMgk22Q9Pxng== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=rfIFtc8A; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 317DE606A682; Fri, 4 Dec 2026 10:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=rfIFtc8A Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DFC31F000C2; Fri, 4 Dec 2026 10:35:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380527; bh=nlpwi4O0Klku/NbQekZ6gV9SAKY8oh7Iwi1T4Ltmesw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rfIFtc8AwcbOaZ7FxVrOl7re5T44bncgKh8q4KEmDolbWDMAKtQRodw1+qq1OtkHk G4tqZSVfcuFC9zOyBRDQWpX0jPQwpoHlPo6k/3EALNZJ5bkmg16eaqW6p2O+dtaLjm YRkWKex9bK4/zM/PZKPAMeQUKxelcTXRHiKS4vfg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 7.3 271/742] bpf: Take the attach type of the target for tail calls of an extension Date: Fri, 4 Dec 2026 19:02:15 +0900 Message-ID: <20261204100642.252711625@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit 3d6d222bb9794a054188e9304b5c5f0c30a83063 ] A prog array compares expected_attach_type. It is 0 for an extension at the time of the check, so the extension can call programs that were checked for another attach type, and cannot share an array with its target. Take the attach type of the target. Fixes: 4540aed51b12 ("bpf: Enforce expected_attach_type for tailcall compatibility") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261125032938.670542-7-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- kernel/bpf/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 37f6cbfac5113..6e81e0d9f886f 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2514,6 +2514,7 @@ static unsigned int __bpf_prog_ret0_warn(const void *ctx, static bool __bpf_prog_map_compatible(struct bpf_map *map, const struct bpf_prog *fp) { + enum bpf_attach_type attach_type = fp->expected_attach_type; enum bpf_prog_type prog_type = resolve_prog_type(fp); struct bpf_prog_aux *aux = fp->aux; enum bpf_cgroup_storage_type i; @@ -2523,6 +2524,9 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map, if (fp->kprobe_override) return ret; + if (fp->type == BPF_PROG_TYPE_EXT) + attach_type = aux->saved_dst_attach_type; + spin_lock(&map->owner_lock); /* There's no owner yet where we could check for compatibility. */ if (!map->owner) { @@ -2533,7 +2537,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map, map->owner->jited = fp->jited; map->owner->xdp_has_frags = aux->xdp_has_frags; map->owner->sleepable = fp->sleepable; - map->owner->expected_attach_type = fp->expected_attach_type; + map->owner->expected_attach_type = attach_type; map->owner->attach_func_proto = aux->attach_func_proto; for_each_cgroup_storage_type(i) { map->owner->storage_cookie[i] = @@ -2548,7 +2552,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map, map->owner->sleepable == fp->sleepable; if (ret && map->map_type == BPF_MAP_TYPE_PROG_ARRAY && - map->owner->expected_attach_type != fp->expected_attach_type) + map->owner->expected_attach_type != attach_type) ret = false; for_each_cgroup_storage_type(i) { if (!ret) -- 2.53.0