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=1796414853; b=pwNKvDWd6LGRILutsz3ClevWaFLS9jgRp6SjVjDVwMt/zKp8njWS/mJRLvBOJWUPmtk/ mzNPQ3JKgfqd7S/JVreNjDORkaU4D4u837WjlKqLcyN/OmEptkvSkE1u5qZRHPU9ZBgAD Bb5yZJBunWX27XcicBia2K4x140xBGtwxfX52qyzcXuMBNcsPU2+SUE6HV9xni3RG7cVt FbxpbJD1p5IF6UFeDLc9qcOS326UEfrylBuKP42lmzh1sb+y6K7DIUJID8hvAoB9oTBHC TSuAoBImPG50bGE55XSSKOBhBkk5NIkyqz7tps0v73KnstJnStII2+GH1SFURQSYI6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796414853; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=mYSofw3dxXMLyDGgapOQwrNd4GqrQtgHYbF6Sp+gWvk=; b=CPITKzyAHMeoSSj/NgGKZB5RvOG8JbQzrUz11MjXHP+0Sl5BKQoBFK/i4bpCQdTUjY96 ysjUxpzl94L9wWmH1rjmywZjYL7R2r2BwFgBwFz1h8oqjG0iFvIvK0xd7PU1xIBb29BG5 1IJ9dAiVzrCwITcLhmjzMV8qA7S2QBuSylThPwmGAS/EPSWaA+kCyIOLS+fHjebSk9Pn1 b2JZUNjbcZ5r12aWUKu9pY81CPMuIurWH8SutAPHPQzax8cSl29/IpA9KEdne4quup/Id hrv6v+KxxY9wXQ1MtiMTE1ADq/8tZwrdUYVN/cN++hFYaIBIqzhPpD+bMVDA+zI/APA== 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=iSD5ihMT; 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 E8AA1606A322 for ; Fri, 4 Dec 2026 20:07:32 +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=iSD5ihMT Received: by smtp.kernel.org (Postfix) with ESMTPSA id A06501F00936 for ; Fri, 4 Dec 2026 20:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796414852; bh=mYSofw3dxXMLyDGgapOQwrNd4GqrQtgHYbF6Sp+gWvk=; h=From:Subject:Reply-To:Cc:In-Reply-To:References:Date; b=iSD5ihMT2PAYzJt2YPf2SM9lCi/ViB68bKYv2gx0ccqMDXH/mHblEhTLnJ8d47O2S Y8npG5hcw8LTtjM+RKBUen0BAtWcJkZQ2ISAeU+kBthDVVQPF3yAr577dScj62rsH5 LGUAiudSD+XC5rmG3Uc31gu3CVax864gCto2Pwfc2yC5PYcFj2gdSK/7d1DzwQigx6 NeTUecb5ICciNKLrtjXYG2COGQLTdY02aYs0hmtbrkFgSx9qle2oCgBwJxJPEQEM2d X2Lq+vPrrz4eDP+b66Rfh/SyiVcFojcgEiBSjfWwuygClOcLyj8NwpOwV8b8uYxmyn N0/03PTn+HYjg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4] selinux: validate primary symbol count when loading policy Reply-To: sashiko-reviews@lists.linux.dev Cc: selinux@vger.kernel.org In-Reply-To: <179641334208.1696188.13639506462697032325@skku.edu> References: <179641334208.1696188.13639506462697032325@skku.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 20:07:31 +0000 X-Mailing-List: selinux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] selinux: policydb_read() returns 0 on oversized SYM_CLASSES nprim -- commit f5b341ba25ff924a6cef1b9b61666631c03a9a2d Author: Kyuwon Cho selinux: validate primary symbol count when loading policy This commit validates primary symbol counts against the remaining policy size (and U16_MAX for classes) in policydb_read(), and switches policy index array allocations to kvzalloc with __GFP_NOWARN. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policyd= b.c > index b75c977c6673d..633508855e165 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c [ ... ] > @@ -2904,6 +2909,21 @@ int policydb_read(struct policydb *p, struct polic= y_file *fp) > goto bad; > nprim =3D le32_to_cpu(buf[0]); > nel =3D le32_to_cpu(buf[1]); > + if (i =3D=3D SYM_CLASSES && nprim > U16_MAX) { > + pr_err("SELinux: class table has an invalid primary symbol count %u\= n", > + nprim); > + goto bad; > + } [Severity: High] Does this jump to bad return 0 because rc is still 0 from next_entry()? At the bad label, policydb_read() calls policydb_destroy(p) and returns rc. Seeing rc =3D=3D 0, security_load_policy() continues using the destroyed policydb instead of aborting the load. If selinux_set_mapping() then fails (for example with REJECT_UNKNOWN set), security_load_policy() calls policydb_destroy() a second time. Because hashtab_destroy() clears h->htable without resetting h->size, hashtab_map() triggers a NULL pointer dereference on SYM_COMMONS. Setting rc =3D -EINVAL before goto bad fixes this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179641334208.169618= 8.13639506462697032325@skku.edu?part=3D1