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=1796385241; b=A0MhH3r4bFx7kpZTI3kBCHWpxGGQtoSa3k1KVPJJX57qfgKeJ9zt7wA8NpN8AbXC+vry vhhfAV0ecX912l2S0wBUwbica6ZoyKslx0RXpLGPZIN61UW3afx7viGgeTGBUYZGbk9sV OuK1sBu/ux2Y80FfcCAHFKhSUTUSGEzEPjxXu1nSEGRYk5GLTcqgEq9XAicjw6gvwqZD0 m3993LSC8lh7psqFPyFRDhZUg1xY/hyOH5fj0D0ZlZGwZZPnDb/hyAY7k2dncMVUzmY3t GerqhWzE3oUeZtDvt0rGjkg2IXoWZVko3fAboZN9ttwGENVj3m++E+d2PMI4Y6XEFYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385241; 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-Type:Content-Transfer-Encoding; bh=xOTIVHf7BKQHhUFaj4yGqNDT8xmFAn/1U0RtlH1y1qU=; b=f8RhpyU+9Wp5M0DGQj1LPY8c60bGO/7ImIffgzSJBfoMaF9ZbdnE9iQKtnwUiT5wRgi9 M2WtqoowuTrTDDu9df51552OCKLuIBQjHIkwEvysW/8+YSsIM30am9G8DSnGfokRuX7Pi IvapTrkGbVy6/XaFgl+ZrdnjfDi+Gy8VmjuGtl9pTBKEMRmrg2iypAmvYaoM8hNiy3Uh2 T0VL+I2GyrW6zwO8mlZrRb4xya000xa42ThvTeUi5vcWi5PZXzMs8aP+3tyZ4KlzW8bSI vXzxhgGUrMF+3JlgDd4fHQPKklCownJulObA9D6sYOLVWac+Qj61XQqkjSORFbxRYyQ== 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=g+KkdA7a; 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 B0531606A322; Fri, 4 Dec 2026 11:54:01 +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=g+KkdA7a Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAC4C1F0093A; Fri, 4 Dec 2026 11:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385241; bh=xOTIVHf7BKQHhUFaj4yGqNDT8xmFAn/1U0RtlH1y1qU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g+KkdA7avtkEMFG6ABuflcqlXQD3vfWFikqY2KiWeadNtVAo/oXnPD/cUq2rZSZ2u Ql0i6chEGiYNqUlOD3eGjN4bcXJ5sV0hGGK0zCDdgzG8x1cNJ62xT1AzmQXAWcE6rd QLrvDZOCIMs9qj1bEfYwpfokfgjYNJV1bqlt8ONI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= , John Johansen , Sasha Levin Subject: [PATCH 6.6 0476/1167] apparmor: check connect permission for SCTP Date: Fri, 4 Dec 2026 18:58:23 +0900 Message-ID: <20261204100714.422643612@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jérémy Jean [ Upstream commit 2f764c08bb191a8c8f4051926dba0d25d195f39b ] SCTP can start an association through sendmsg() or CONNECTX. These paths call the SCTP-specific sctp_bind_connect hook instead of the normal socket connect hook, but AppArmor does not register it. As a result, a profile can deny connect and allow send or setopt, yet a task can still create an SCTP association. Register the SCTP hook. Ask for connect permission when SENDMSG_CONNECT or CONNECTX creates an association. Fixes: 56974a6fcfef ("apparmor: add base infastructure for socket mediation") Assisted-by: LLM Signed-off-by: Jérémy Jean Signed-off-by: John Johansen [ sashal: adjusted context for a kernel-doc comment above apparmor_socket_listen() by placing the new function after apparmor_socket_connect() and keeping the comment attached to its function ] Signed-off-by: Sasha Levin --- security/apparmor/lsm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 20b60b8d93159..d58250b56364c 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -964,6 +965,18 @@ static int apparmor_socket_connect(struct socket *sock, aa_sk_perm(OP_CONNECT, AA_MAY_CONNECT, sock->sk)); } +static int apparmor_sctp_bind_connect(struct sock *sk, int optname, + struct sockaddr *address, int addrlen) +{ + switch (optname) { + case SCTP_SOCKOPT_CONNECTX: + case SCTP_SENDMSG_CONNECT: + return aa_sk_perm(OP_CONNECT, AA_MAY_CONNECT, sk); + } + + return 0; +} + /** * apparmor_socket_listen - check perms before allowing listen */ @@ -1304,6 +1317,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = { LSM_HOOK_INIT(socket_getsockopt, apparmor_socket_getsockopt), LSM_HOOK_INIT(socket_setsockopt, apparmor_socket_setsockopt), LSM_HOOK_INIT(socket_shutdown, apparmor_socket_shutdown), + LSM_HOOK_INIT(sctp_bind_connect, apparmor_sctp_bind_connect), #ifdef CONFIG_NETWORK_SECMARK LSM_HOOK_INIT(socket_sock_rcv_skb, apparmor_socket_sock_rcv_skb), #endif -- 2.53.0