From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796311619; b=tXPmKnzm/EpbXQYxD0EEAXZu8CxDJP01/s1RZCmv7IzC5iO/ue2YvF/FsebRNjR1Tq+J eXxy2/zFd7XryJl7x+dC8LAV6opOlPcWgUajsfu3VwEwbnVV0xzC8DsUBQIaQrqwnsU4Z dm+QEGLApUWUSUTna1u3j4hLKPBLoFAQXBSLdqZ2u7xMrK2bSSPXQV+oU9TCH3zAny54N T+ATtbinWjpgnUXedsbq+3D1cE9xwkcXJSb+0eRZ8ZjfUqh0Mp7pDmobkrYG8/feT7X+5 /b1WCs6FL0BG7NeXJ1oHub0QAp0G/lp00J5Z00gkhEvfNoB7ovcBrUjBTbXfdY9P0Bg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796311619; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Mime-Version:Content-Type: Date:Message-Id:Subject:Cc:From:To:References:In-Reply-To: X-Scanned-By; bh=INx5ZTOBCVbDBbsEUO1vls/j8EjIrlMEWlSwg4wzs6Y=; b=e1ghij7bhUibMvmP6fzTC7vlaPqpWdoWiY7rSGGbNfTWmx6TxEgEE7B3AU0Hdirfgo1O /IItmGhd4emL78i5+zc7KYPBT1yrpbyFoc1VGPzcIeQzeW9NlKkMONBhVXUmOloHtN12F QW/DyaE+/TQxRnGCbNrb15tqS45wcZlbIuZkH+0ThfWMxDf9zXZbtCKyRkipsz2FsiBX8 wisJ1HMso0ZpoxYSzmFspt//tvHsJERZR/ScMjiOG8cEsobvp0lWTUb+rbi4b1TTFZh4G GYfbfhl0/DXDd9EY19PjV3XJz5EAHy/K0i/Hbpy7JuZWy7Kz7DRfCTgYqOrrKHjpQ8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GJ3eBBOx; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 388FA606A32D for ; Thu, 3 Dec 2026 15:26:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 388FA606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GJ3eBBOx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796311617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=INx5ZTOBCVbDBbsEUO1vls/j8EjIrlMEWlSwg4wzs6Y=; b=GJ3eBBOxLzXRWSBhtnm5YwhMOgzFRyyS+OEXnMZyS/B1gbfdkVrhSBxoIasfe8jLsIU963 2KFbm44LAhY09rNFL5kiz+J2n03q3K8MjsVWo4G2IEy/fpgyPMW8n0CBRa0OWmWVjcsezX elG1mtAbz7wVBZU3+1DGlvZdDFmPU1o= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-iKxJEUJXO5eLQWcOd_GA_Q-1; Thu, 3 Dec 2026 15:26:51 +0000 X-MC-Unique: iKxJEUJXO5eLQWcOd_GA_Q-1 X-Mimecast-MFC-AGG-ID: iKxJEUJXO5eLQWcOd_GA_Q_1796311609 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 869B3188EEDA; Thu, 3 Dec 2026 15:26:48 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 12F231809B40; Thu, 3 Dec 2026 15:26:46 +0000 (UTC) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: multipart/signed; boundary=3eae75eccacd290d6f91968e3ffac459f4a91cbe17f73dc149eb8058175e; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Thu, 03 Dec 2026 12:26:45 -0300 Message-Id: Subject: Re: [PATCH v2] ima: Fix out-of-bounds read in ima_read_policy() Cc: , , , "Roberto Sassu" From: "Bruno Meneguele" To: "Mimi Zohar" , "Roberto Sassu" , , , , , , , "Kenneth Goldman" References: <20261202105724.3056284-1-roberto.sassu@huaweicloud.com> <6d816790f56a45f95790dd240c56f1625fb5d66e.camel@linux.ibm.com> In-Reply-To: <6d816790f56a45f95790dd240c56f1625fb5d66e.camel@linux.ibm.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 --3eae75eccacd290d6f91968e3ffac459f4a91cbe17f73dc149eb8058175e Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed On Wed Dec 2, 2026 at 5:15 PM -03, Mimi Zohar wrote: > On Wed, 2026-12-02 at 10:23 -0300, Bruno Meneguele wrote: >> On Wed Dec 2, 2026 at 7:57 AM -03, Roberto Sassu wrote: >> > From: Roberto Sassu >> > >> > ima_read_policy() reads the policy file with kernel_read_file_from_pat= h() >> > and splits it into rules with strsep(). However, the buffer allocated = by >> > kernel_read_file_from_path() is exactly the size of the file and is no= t >> > NUL-terminated. If the policy file does not end with a newline, strsep= () >> > scans past the end of the buffer while looking for the next separator.= If >> > the file size is a multiple of PAGE_SIZE, the scan reaches the vmalloc >> > guard page and the kernel oopses. >> > >> > To avoid the problem, reject the read policy if does not end with a ne= wline >> > or the NUL terminator. >> > >> > Fixes: 7429b092811f ("ima: load policy using path") >> > Reported-by: Fabrice Derepas >> > Closes: https://lore.kernel.org/linux-integrity/20260814085443.1211989= -1-fabrice.derepas@canonical.com/ >> > Suggested-by: Mimi Zohar >> > Signed-off-by: Roberto Sassu >> > --- >> > security/integrity/ima/ima_fs.c | 6 ++++++ >> > 1 file changed, 6 insertions(+) >> > >> > diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/= ima_fs.c >> > index 2a0bca554316..872b2c31ca02 100644 >> > --- a/security/integrity/ima/ima_fs.c >> > +++ b/security/integrity/ima/ima_fs.c >> > @@ -548,6 +548,12 @@ static ssize_t ima_read_policy(char *path) >> > rc =3D 0; >> > >> > datap =3D data; >> > + >> > + if (size && datap[size - 1] !=3D '\n' && datap[size - 1] !=3D '\0') = { >> > + vfree(data); >> > + return -EINVAL; >> > + } >> > + >> > while (size > 0 && (p =3D strsep(&datap, "\n"))) { >> > pr_debug("rule: %s\n", p); >> > rc =3D ima_parse_add_rule(p); >> >> May I suggest an addition to [1] about it? That's literally an invisible= failure >> the user won't find out the reason easily. >> >> [1] https://github.com/linux-integrity/ima-doc > > Thanks, Bruno. > > Agreed, ima-docs should be updated. It belongs as the last sentence of t= he > initial custom policy paragraph[1].=C2=A0 > > [1] https://ima-doc.readthedocs.io/en/latest/ima-policy.html#custom-polic= y Yes. It fits nicely there. Thanks Mimi. >> >> >> Acked-by: Bruno Meneguele > > As per the relatively new "Acked-by" usage, let's append a comment like t= he one > described below (e.g. As primary user, userspace pkg maintainer, etc). > > From submitting-patches documentation: > Acked-by: may also be used by other stakeholders, such as people with = domain > knowledge (e.g. the original author of the code being modified), users= pace- > side reviewers for a kernel uAPI patch or key users of a feature. Opti= onally, > in these cases, it can be useful to add a =E2=80=9C# Suffix=E2=80=9D t= o clarify its meaning: > > Acked-by: The Stakeholder # As primary user Oh, sure thing. Thanks for the heads-up and pointer. Acked-by: Bruno Meneguele # As primary user -- Bruno Meneguele PGP Key: http://bmeneg.com/pubkey.txt --3eae75eccacd290d6f91968e3ffac459f4a91cbe17f73dc149eb8058175e Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFGBAABCgAwFiEEdWo6nTbnZdbDmXutYdRkFR+RokMFAmsRijUSHGJtZW5lZ0By ZWRoYXQuY29tAAoJEGHUZBUfkaJDGnIIAL1NUAcG73ej/2sXBe2/jk1Xdm1I3+sn K2xTgRXEUFbXqs8TVkxucs6pjl/U1kWpZ3u3VfdfB32j4PkxKOr7JzXx9Sg/LyUm yx9mUQTN1UOeU4xn+3WbAFJWKKSgQMGYE4nWZDyWoQmcSDNJGh2XyxFciYhPuy0h QvvpoK5S4sLft3H1BAufcWW+ffpblSKfEyegP48qN8K9nzDHEzlHN0HVhRgbb1+i py3W+nPL9nOely7+6ifRkf3VJXc80xM9MQPSL6v7W4tSOIkYyLgiV3bYPklGWkjg UPPnn2asYfRixlDJ8xi2crkta9YrdBTkHS02xMoicRhuoZdKiMTn3Pk= =ReDF -----END PGP SIGNATURE----- --3eae75eccacd290d6f91968e3ffac459f4a91cbe17f73dc149eb8058175e--