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=1796361694; b=e+njjks6rrd9ApCd8daowRGJfUUr+Qb91iI76OouNcZTlGtXXec84ONic/iTtBwVAgAE Gp3gAhIcZRWoi854VS/ce97EUTG8ByrvIz+IJhhDUhYzlhPXbkDm62jJ0lkEU3Qo5mNJ0 C5oNLg1CYrdSgJ6XOJ5nomgjdxdar+Tgn1lPNxb9IFLwToDeaECrn5S5Q0H/HB1Pc/VJ7 8tPe5NG0iLCaDZFkHE/ddS/MPFvgNYAWB70YbjjZgGo3Kk2LiUihVsduhcyQXANgIexFI HBfe4o46jh9fFaILBaqODUl2/3ru+VitIrU8Ef5aXx/WTld2JF5bwlcXRBW/6anluhA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796361694; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Kej9bqGH8oo/Cywd2TpLuoR6U4A0iYuIDPrxye3P694=; b=viXsn9v80rLNiOaSioysEAz47W0HtLBRiQGLOHZmdpnCTqeDVR6x4TzlkXeumXYS3ioh eQ7GCQFzuObk0z/6BELaHo7J+9/aQGxR2e+NhxNINjU4CvmBnK1h+eJXW71xRV8D6RNwo 8Q7TqrGP2AIC0VvAS/eUHV/dMoNSziNO5uNVjAIIdLNUqUm6ti9egJD/ToMYuZZ+ZLSzS xsFq/IOnmhGpss4J5RCeHWsBz7l8v91lAzHquSfn6GClBr5pglA48MoSWPTVHb92/rDaG vv6AUeZKGMt+n/dy4I6rG67L/91qPAbxZyIVGyDXfqusTPgEe18lRUWARSfCyQDHLFA== 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=R+A2zFNR; 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 F1B0C606A322 for ; Fri, 4 Dec 2026 05:21:33 +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=R+A2zFNR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88F081F00897 for ; Fri, 4 Dec 2026 05:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796361693; bh=Kej9bqGH8oo/Cywd2TpLuoR6U4A0iYuIDPrxye3P694=; h=From:Subject:Reply-To:Cc:In-Reply-To:References:Date; b=R+A2zFNRI5AW7o6m7W/eFj6nLjx06SQBJtx+5KRGXxGa6djMcVvCcA/p1psmd+bqd 7aa/xRKtkg6o5F23Enwy85bWaYYEEviECNnyEIaCw+HBoow4AYXwpCJIUKUcsJbLIP flMXOORc3PGvTeSfBmXoJHCIAd3K3JpWLlrTPzXQe6um91uMwirALeq2lKbCFmwx7o n8pxb7mS6KXQTocpog4alzWLSzRzxW2Uf3xUasdCgIgckiYi4bJtp+s9FCpQ1Az58x pq+2pLj+M38kyI6jKscewwVs6wc3/b9eX3hYxftypCJ0zOnpTXnFv1rbDSa/cIwA/n zxZRBs98pQ2WA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3] selinux: validate primary symbol count when loading policy Reply-To: sashiko-reviews@lists.linux.dev Cc: selinux@vger.kernel.org In-Reply-To: <179633283854.20472.2166041983398323812@skku.edu> References: <179633283854.20472.2166041983398323812@skku.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 05:21:33 +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: oversized p_classes.nprim warns in security_get_classes() -- commit d4902f40a6a7734f5f4e7db2f7f69f69e560e87e Author: Kyuwon Cho selinux: validate primary symbol count when loading policy This commit bounds each symbol table's primary count by the remaining policy size in policydb_read() and switches policy index array allocations to kvzalloc/kvcalloc with __GFP_NOWARN. > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policyd= b.c > index b75c977c6673d..92dbb43fafbae 100644 > --- a/security/selinux/ss/policydb.c > +++ b/security/selinux/ss/policydb.c [ ... ] > @@ -2904,6 +2909,14 @@ 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 SYM_TYPES || p->policyvers >=3D POLICYDB_VERSION_AVTAB) { > + rc =3D size_check(sizeof(u32), nprim, fp); > + if (rc) { > + pr_err("SELinux: symbol table %u has an invalid primary symbol coun= t %u\n", > + i, nprim); > + goto bad; > + } > + } [Severity: Medium] Should SYM_CLASSES also be capped at U16_MAX here, or does an oversized p_classes.nprim still trigger an allocator warning in security_get_classes()? Now that policydb_index() uses kvzalloc_objs() for class_val_to_struct, a ~2.1 MiB padded policy with p_classes.nprim > 524288 passes size_check() and succeeds in security_load_policy(). sel_write_load() then calls sel_make_policy_nodes() -> sel_make_classes() -> security_get_classes(): security/selinux/ss/services.c:security_get_classes() { ... *nclasses =3D policydb->p_classes.nprim; *classes =3D kcalloc(*nclasses, sizeof(**classes), GFP_ATOMIC); if (!*classes) goto out; ... } On 64-bit 4 KiB-page kernels, that kcalloc() exceeds KMALLOC_MAX_SIZE without __GFP_NOWARN and triggers the order > MAX_PAGE_ORDER warning in alloc_order_allowed(). Since class_read() already rejects class values above U16_MAX, capping SYM_CLASSES nprim at U16_MAX would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179633283854.20472.= 2166041983398323812@skku.edu?part=3D1