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=1796359595; b=LWNfeBXhUggkgjsNzToKNgk1HJNq6g6yywYu1lU77pfegWplaDMBVGltPKt/ewRrmoz9 Or10SqVm8fIl48KWTrgFCeYUAmg7SKGVNUGCga5lMxLo7eExM98kVav5RD2dtUyFwqa08 mq1DM2t6A14zr9do5Q5c6yzwzCIYmuz4fXDyBAfnip+eME4JI1w9ry0WrJvikDlaiexBe s52pMciD08TEJXWQQDd4yD7PRa7a001Y1vCbA9v5dqQf9618PTRV1Dn6Qk2g04OzandHa jKaI1DXIMjytqkrYaEbvRwT8/cuQ+4BMS3Hwp8j0SO86XpRE1ajZGZdZz2LREInaWgA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796359595; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=oDMz8Syo0lOJD4DCCQV2WjujJybf9VNhcK/z3pdMBZE=; b=2fgZocFIx7A9W7ZTmN8TO0jyws0Rpogagt07tD0LMUpOrCmClZjt7CcIrbDEJdJssoTW HAS8vlJyplZM6Q+8m0ECY5I+xf5lA2NR80r/PoS6rVwOMaNsBiuBg+oU0Z4slD7bHXW0z pBjfzNLDcvFhMBDtzvGQCqUSRhTSmX718Sg/0eHL3EOuFGmp3G60W9CpqIIcxeCl/RfTW q21ps5fF4Uphz+vpvnwg/CWTyozMbaG7QQKoNH94theOpsA4/ErWrHYGRAp7R7KezrjST RxKe6MDn5DUQ0py4+RTKWqBlsAO2BYv1EmZtg2nShzshZjL/Nq4p+ZAfoXPkBp0g5Uw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SW13dk46; 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 8530A606A322 for ; Fri, 4 Dec 2026 04:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SW13dk46 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EC031F000C2; Fri, 4 Dec 2026 04:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796359595; bh=oDMz8Syo0lOJD4DCCQV2WjujJybf9VNhcK/z3pdMBZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SW13dk46TE9U0+EilJmd8O89pD7oiAmiaAI9toN9NSYBclE+koYqHXluMtgO5IQVy vNcQ3I7RrHcI751AN/SazkTWK6X3SFw33cfaJb6l0eHo1MBkzwphxv9NgeHYFayQfH 4XZAQAtexnTewXDLDCMGsBIjGVynrjw59ale+70g3eX3FdQR1gioP/jZWTI6R0DMAD JIF275cL9CH6u57JPY95Y1dcRnobhchdhYdAWv7PkNGLVIX/ywRdZpqIVo8ia6Efhz 2hYnzGPiijxXHX5sCxvocTl1nyzjgMWdipaerycu+z7pRJ/R5Aw7KocdHfxRN+xkpm 1wTCV6iZzYCeA== From: Sasha Levin To: stable@vger.kernel.org Cc: Stephen Smalley , Paul Moore , Sasha Levin Subject: [PATCH 6.1.y] selinux: check MAP_SHARED_VALIDATE mappings as shared Date: Thu, 3 Dec 2026 23:46:33 -0500 Message-ID: <20261204044609.2656503-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120258-blog-astrology-e2ad@gregkh> References: <2026120258-blog-astrology-e2ad@gregkh> 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 From: Stephen Smalley [ Upstream commit beb0ae6bcd7505e2e61babe5d98a8dd3b3f03c7f ] selinux_mmap_file() only recognizes MAP_SHARED as a shared mapping, but MAP_SHARED_VALIDATE is also a shared mapping type. The mmap flags reach this hook before the mm code processes the mapping type. Consequently, a writable MAP_SHARED_VALIDATE mapping was failing to check the file write permission at mmap time, and a writable executable file mapping was wrongly checking process execmem permission as if it were private. Cc: stable@vger.kernel.org Link: https://github.com/SELinuxProject/selinux-kernel/issues/78 Fixes: 1c9725974074 ("mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags") Signed-off-by: Stephen Smalley Signed-off-by: Paul Moore [ sashal: Replaced the upstream selinux_mmap_file_common() edit with an inline change in selinux_mmap_file(), adding a map_type local and passing it to file_map_prot_check(), since the refactor is absent. ] Signed-off-by: Sasha Levin --- security/selinux/hooks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 299d7721ca9f7..6775c8e1279ab 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3810,6 +3810,7 @@ static int selinux_mmap_addr(unsigned long addr) static int selinux_mmap_file(struct file *file, unsigned long reqprot, unsigned long prot, unsigned long flags) { + const unsigned long map_type = (flags & MAP_TYPE); struct common_audit_data ad; int rc; @@ -3826,7 +3827,8 @@ static int selinux_mmap_file(struct file *file, unsigned long reqprot, prot = reqprot; return file_map_prot_check(file, prot, - (flags & MAP_TYPE) == MAP_SHARED); + (map_type == MAP_SHARED || + map_type == MAP_SHARED_VALIDATE)); } static int selinux_file_mprotect(struct vm_area_struct *vma, -- 2.53.0