Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 996A537C92A; Thu, 20 Aug 2026 15:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238057; cv=none; b=ubv5IYFEhi3l8cskey0uqgcCa4SZVshJP1KjQnORSbzlg0Wva0wM20GcK4WWd/pXR+gZ+nbAM6B7Z6orGbW7SibFC/BEeX9swnbxfjfTO6P0ywaZA8smRH3YH0ea55jEkUWkex+sWLaAZVsuVuKeT4HRazb6sCYEersR8H++T10= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238057; c=relaxed/simple; bh=5qOhcCDdZR4Wbwk6t4tOkPha3DapInYWDGatwfH2WL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T6xxhpNA3V1xYLa+VOSOpxbw6BRe3GbznNuozohTX9AmsT0jiBfubRd8B6WpHZMi9XkzJAhtWExtREsyaDbZt67veoZrJItTPDRzdqpUNRekV2WDXDsGUSLlUew6bstbeOhNlonBm2/T8le3P9nqJEs03oI7szcKOWzv2QdslTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XVukFHt5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XVukFHt5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EBF01F00A3A; Thu, 20 Aug 2026 15:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787238052; bh=hQZgKFhzEwq4mWum1dBvvrqyw+xLXrlKLf8Bv2Fo+gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XVukFHt5RWF1JTGdbEy/ZAcP2r7S/mCA9Kf55StjDmS6YnuPrQYNESJw2Mx1Tmywy 8A4MP5FLMN+7YTUoRD8+r62xjxiTW8r+ZJAcf3RyyNcm4ls3qegC9SBgLIxkrJ9QU1 KBCWo3R4cSUc4wVQrZOgp0kmK3Oqt3ajMLig84+U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , Stephen Smalley , Paul Moore Subject: [PATCH 7.1 004/228] selinux: do not cancel a policy conversion that never started Date: Thu, 20 Aug 2026 16:52:26 +0200 Message-ID: <20260820145244.599276817@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145244.450574346@linuxfoundation.org> References: <20260820145244.450574346@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas commit e5c0235a3c4e9eb047a16cd02323fe4ecf2f570e upstream. sel_write_load() calls selinux_policy_cancel() when sel_make_policy_nodes() fails, and that helper dereferences the outgoing policy to cancel its sidtab conversion. On the first policy load there is no outgoing policy: security_load_policy() returns early for that case, before it converts anything, and state->policy is still NULL. A first load that fails while building the selinuxfs tree therefore takes a NULL dereference in selinux_policy_cancel(), reached from a write(2) to /sys/fs/selinux/load. Skip the cancel when there is no old policy, mirroring the check security_load_policy() already makes before it converts. Cc: stable@vger.kernel.org Fixes: 02a52c5c8c3b ("selinux: move policy commit after updating selinuxfs") Signed-off-by: Bryam Vargas Acked-by: Stephen Smalley Signed-off-by: Paul Moore Signed-off-by: Greg Kroah-Hartman --- security/selinux/ss/services.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -2220,7 +2220,9 @@ void selinux_policy_cancel(struct selinu oldpolicy = rcu_dereference_protected(state->policy, lockdep_is_held(&state->policy_mutex)); - sidtab_cancel_convert(oldpolicy->sidtab); + /* a first load has no outgoing policy and converted nothing */ + if (oldpolicy) + sidtab_cancel_convert(oldpolicy->sidtab); selinux_policy_free(load_state->policy); kfree(load_state->convert_data); }