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=1796388138; b=JaC3ahB0top8Oiot0rVSB0m/3Fg6XXShzhvL5KgwrGRsn0ld13rQKaS5Z5EYjhVhFf00 nIjnNK4NfhsnhEatyQe9CYYKQC5G2lloK3C6DJiuw1H76YCiAnkGAx3T8cW41AgFM89Ck LRLk35daknmF0xQlKhoR1vt3NOHN/OpIsGRH84xkStonLS5cZBuVj37NAd9mYkl7fwYTZ IXShJqrzsZVDAhnNYFGV2Ezhy/+7QIMl9xCOPSrXIuC7S98LaQglV2lO+9mPxUK2ZulM2 yD47/WbehJ76I2jclvwgX9yMxLlNwXDbNjrOuwFCvKPqliDdBjJHjR6ddrg1ecvCf5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388138; 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=HTDG/4XpTVaQMy6u2Lr/KMWJ3+pOXcUfwXIQwOyH+DQ=; b=m38yPnMyPr/+9L/X2ZzUQHB4Ti2tAVZtY+h2YxIQ2xvLPoCcY0cHvd8wdVb+/ewGCAul mgUzkuTDetEGE0WEfdoU7GeWpH3xG9PcDSBfyVv8yehp7GbUzvEc6dhk6WzdG5Pk5aHU2 +DnPzngRIwH7U07b0SbCPi2hFj6rii4NtAm7SzVAouSdLOlWSnfT2hE7qIlNFeOPwpoVC 9rc9uK4fJ1+daCM5nq1GMFY9Msi2nmhEYbcGBJrAEdDsDBm1YE2B7hU/ux+jZrxpo7pn1 bphrBbKbTkkMSqgtCW40fwv3PWOCTroU69fiopcrz8xzpWTL704A4MdWHPUoxQ7/vZg== 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=cCySdHUO; 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 31583606A334; Fri, 4 Dec 2026 12:42:18 +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=cCySdHUO Received: by smtp.kernel.org (Postfix) with ESMTPSA id A19031F00897; Fri, 4 Dec 2026 12:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388138; bh=HTDG/4XpTVaQMy6u2Lr/KMWJ3+pOXcUfwXIQwOyH+DQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cCySdHUO8H3Vuuhg1zdfvKzg8cWGNnSD/p+n8pq+e02JttIfY7z/KhcGWMvzmrsuf +PkR+c8ULU4wwIsFhUVeuByGIGO0ie3FPjOQsOQsXpQY8FN+BTB5yizVAuwR1sMrw0 HuQxORMTeeBINu8U8Mq8rZIkZhXHTSqGGmtAPjRA= 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.1 0457/1059] apparmor: check connect permission for SCTP Date: Fri, 4 Dec 2026 18:59:48 +0900 Message-ID: <20261204100656.118236176@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev 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.1-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: the new SCTP hook function is inserted before the kerneldoc comment above apparmor_socket_listen(), and the neighbouring include and af_select() context differ. ] 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 501e3ec6c3e7d..65d09c76a0670 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -915,6 +916,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 */ @@ -1256,6 +1269,7 @@ static struct security_hook_list apparmor_hooks[] __lsm_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