From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5C62155730; Thu, 5 Sep 2024 09:49:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725529784; cv=none; b=Qi61NoKnTcItO7qlWSj7YefIU8wbI1uGV4E5ki9CqlB2Q66Rh8qt7vAlQAtJKWhex0BbBI0YFRhA+k8auq8Ti/PxiT2hjIuuVrnU1jxfDFN6lsrGSZDqt/pR2/9exEWfHjpnEB0pRSnyrHpMLaNydysx+pjvrpqHm6bJPKhW2ZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725529784; c=relaxed/simple; bh=VbViuRn6rcWxTDTp3F3G7FzkBM6p5ANNmkWcn4qZ6HQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y7aTVaUJAZGyyZnxvrF56tNmq0QXJEXTTTozofvkqG6U7ttfEcw6AIOAvHndi1OFSUGKYDd6JXLgnKB8bY2iYROs2mElA05nO6bdbGl5DdfXT88PRTWjaOHoN2LTsAPcJNH9XpwcD8rLhiJ7wYPJE7SEqKU34fqeGODPOEHyA04= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BEBTUbWq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BEBTUbWq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44E3BC4CEC3; Thu, 5 Sep 2024 09:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725529784; bh=VbViuRn6rcWxTDTp3F3G7FzkBM6p5ANNmkWcn4qZ6HQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEBTUbWqhQvJaE+pb62DPeCfxtD5lH/iB3jstZ6C5c6i+tD7uHdjmEvlCfTDHAPiZ YxBFLWxCALPDnqMgX96ZhB64EkGLxz+axa0wUj8ZEbTant8mB8VGxGDlzKoQKuQhG5 liFjhLIekqxhwkSfvA591tgRx0qYGWeuU6OCMKIY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Konstantin Andreev , Casey Schaufler , Sasha Levin Subject: [PATCH 6.10 142/184] smack: tcp: ipv4, fix incorrect labeling Date: Thu, 5 Sep 2024 11:40:55 +0200 Message-ID: <20240905093737.877846841@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905093732.239411633@linuxfoundation.org> References: <20240905093732.239411633@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Casey Schaufler [ Upstream commit 2fe209d0ad2e2729f7e22b9b31a86cc3ff0db550 ] Currently, Smack mirrors the label of incoming tcp/ipv4 connections: when a label 'foo' connects to a label 'bar' with tcp/ipv4, 'foo' always gets 'foo' in returned ipv4 packets. So, 1) returned packets are incorrectly labeled ('foo' instead of 'bar') 2) 'bar' can write to 'foo' without being authorized to write. Here is a scenario how to see this: * Take two machines, let's call them C and S, with active Smack in the default state (no settings, no rules, no labeled hosts, only builtin labels) * At S, add Smack rule 'foo bar w' (labels 'foo' and 'bar' are instantiated at S at this moment) * At S, at label 'bar', launch a program that listens for incoming tcp/ipv4 connections * From C, at label 'foo', connect to the listener at S. (label 'foo' is instantiated at C at this moment) Connection succeedes and works. * Send some data in both directions. * Collect network traffic of this connection. All packets in both directions are labeled with the CIPSO of the label 'foo'. Hence, label 'bar' writes to 'foo' without being authorized, and even without ever being known at C. If anybody cares: exactly the same happens with DCCP. This behavior 1st manifested in release 2.6.29.4 (see Fixes below) and it looks unintentional. At least, no explanation was provided. I changed returned packes label into the 'bar', to bring it into line with the Smack documentation claims. Signed-off-by: Konstantin Andreev Signed-off-by: Casey Schaufler Signed-off-by: Sasha Levin --- security/smack/smack_lsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 081129be5b62..ab939e6449e4 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -4456,7 +4456,7 @@ static int smack_inet_conn_request(const struct sock *sk, struct sk_buff *skb, rcu_read_unlock(); if (hskp == NULL) - rc = netlbl_req_setattr(req, &skp->smk_netlabel); + rc = netlbl_req_setattr(req, &ssp->smk_out->smk_netlabel); else netlbl_req_delattr(req); -- 2.43.0