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=1796318886; b=pVSD7dq29g/7VRhj4U/0wHr3PL14gYLk+8vtti1cCXNVJPxDY8u+iV65P54I60McbPw5 CZYgiaDLRhQukudLZ/DF1y2ZW5aZEYBZnkTAfFT6DFn+bY9mRUWgE1pll1TzL8RJ0C1H+ /aJ0z+Q99hO1bj3YlbBerhNJ3mOXW3J+ag6D2EfkLKH6K7QoqUcIRc4EC73wjbIY51sUL i/NfzUUjHVIIqI/sUVvenq0x5Aujfu85PEjmZGvfOn0ncgjvMmrj1STWQLpLi4QSdxmL5 6xte/msM3gxrHrhJOFkXtDBkESIJGrw/rL0qbS5Ile6SXjcWjFb1SJxyPnmATE7ZBiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796318886; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Ilqq+8Bj+IfQlN4JDBwPxkXG78ala+rJewjl9W2YUXE=; b=rQx+ewWctjRSIank/OvXf4UtssfJbPTEWQuSTlW5zpr6qQ0Phg+eznjQ3Bxybo9BC6Lp wotfPFGNEkpD7dPFXOB1OwjuG4kPUEv2yMDRwaVaDSzau6JRnNU+5aRupAh/Q3S8Xg4Dj xU5E6FgK3kV9cjgKzcesm5SDyv7B7EWCS9QmQzaKcRd5LWTZmM28fRaWk6bP79kNCBnsp Qonnh5bWGBap+aOJ656XH/HQLbR3szhNT5CYAysc4azerZErKuDSxc3Z7Z7EzCiu60aLd +UfTFtfyQZHOElxtXA1y6DkYGF4ba54XqT7NU/EeHs0Brluu78gzsvEdDaOFe2YHxVQ== 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=I2aTA44m; 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 52604606A322 for ; Thu, 3 Dec 2026 17:28:06 +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=I2aTA44m Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20B7C1F00893 for ; Thu, 3 Dec 2026 17:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796318886; bh=Ilqq+8Bj+IfQlN4JDBwPxkXG78ala+rJewjl9W2YUXE=; h=From:Subject:Reply-To:Cc:In-Reply-To:References:Date; b=I2aTA44mkth2oQdmUe0Ym7lp+nbzFTgXe5WsGBtXoQ29Chd83oOfkQsPbFbTOoBHI +OMT2BQgi/RIWp5VjrrDCj5JILF2lHcZaIcl/wBa+1GSRUJrKQkBJhicSpE/VNmv5v cYqT9ph8DQsLgs1Ilxy89DfoEK24CFblWVtmgSWBBd8BU6KsPwpcMyNrSz5uUkN/6P lpFBNVSbecARPsY578fRIZUDXBsZEh2Ku6G1g5nRxRlxZ1/8MebksROKGNSE+q++h1 5p02hEVV4tvz21s8D7SacytXz0GqG1tF2aN6XDIlpr6vRMY8K4Vzht+iErE1BeG6WZ h9PUa6Xdw8LKg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] selinux: validate primary symbol count when loading policy Reply-To: sashiko-reviews@lists.linux.dev Cc: selinux@vger.kernel.org In-Reply-To: <179621430413.2669974.16944159499886043558@skku.edu> References: <179621430413.2669974.16944159499886043558@skku.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 17:28:05 +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: - [Medium] selinux: policydb_read() rejects valid pre-v24 policies where nprim > nel -- commit 7c587f0526cf279c4d9f66db4544173a329147fa Author: Kyuwon Cho selinux: validate primary symbol count when loading policy This commit adds a check in policydb_read() to reject symbol tables whose primary symbol count (nprim) exceeds the entry count (nel) with -EINVAL. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policyd= b.c > index b75c977c6673d..5eb17378483b6 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c > @@ -2904,6 +2904,12 @@ 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 (nprim > nel) { > + pr_err("SELinux: symbol table %u has %u primary names but only %u en= tries\n", > + i, nprim, nel); > + rc =3D -EINVAL; > + goto bad; > + } [Severity: Medium] Does rejecting nprim > nel break loading valid policies older than POLICYDB_VERSION_BOUNDARY (versions 15 through 23)? Before POLICYDB_VERSION_BOUNDARY, type_read() has no attribute flag, so valid policies omit type attributes from serialized SYM_TYPES entries (nel) while still counting their IDs in p->p_types.nprim. Any pre-v24 policy with more type attributes than type aliases therefore has nprim > nel and will now fail to load with -EINVAL. Top-level symbol tables can also be sparse, and roles_init() pre-populates OBJECT_R into SYM_ROLES, so a policy omitting object_r would hit the same rejection. Guarding this check for pre-POLICYDB_VERSION_BOUNDARY SYM_TYPES (or bounding nprim against the remaining policy image size) would avoid rejecting valid legacy policies. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179621430413.266997= 4.16944159499886043558@skku.edu?part=3D1