From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796242578; b=BzP+ljWybm3UWw/tyDtxPkyXyGYAKVHP6z81SAIoFNqarmZkPODWRVJjtMqDWIn2aswH XDSmhj09kOdrCeYYuO7+eAPzfw4dE1+/A3vU6upfN5IuTRFnJXMB0n1kfY01Ht70hcCmr TT6kbpRpNiFjZiJN/zidBIhF9ETIEJMSqcVa3O90vecxwD0Q/4cYe+45N4jLO78MeP9ta CYbqyRc+1+QXKpLbCwRFBR2hQN4HJX0lWQ/37snxeS71QjwvnKGc70PJQEE5jXiDoOoWx NK+Iag6aSUed3bauB5CtUiXFiTJK6SH1Fl3jJ1JKGEhTVB/SpauvePAEgzFx5aRk3PQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796242578; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Message-ID:Subject:From:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date: MIME-Version:User-Agent:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=AGQdM0iTE0VVbCuopHX6bKIs1gatlkoYeoKzQLrh0T8=; b=VjMs9X4QuW02xQe3E/OtrDYv2PUIjzmbOpHAIzN2iIUXeaEhjWgAHT9k9YF/OKissTFj ZkwB1W+d33xGjiMO9FcW+uECmLvaH2JdpO7MsWUW8D/3CA0MClkbxkBeobk4vuUeJpw8A YZQtBKaNx+kucWqRmTgb2d8o8bDftS/wVpWF5GW7Vcuvk6k7yUdU9iq0LEE4WWvGZYBc0 luGQAgvhBRefAit/ikTdxZoX06X8AQnCELu3ey8LVy5+7jGRHcEUWrpaUplsZEhRxSj5b x0uGHbp2orQ2RtxXZLxrgdM+oSQVEaSr+YhlImi21o2/yWNbQkw35pcDQX8Pihb02zg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=oZcxc9db; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 CDA69606A322; Wed, 2 Dec 2026 20:16:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CDA69606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=oZcxc9db Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2J4iDs1457636; Wed, 2 Dec 2026 20:15:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=AGQdM0 iTE0VVbCuopHX6bKIs1gatlkoYeoKzQLrh0T8=; b=oZcxc9dbf9ro/Ohr+nEVKK Gd5Zi7tudZkMD01B6BYRKkFsil87zP+Ybxfa2pK26GFmjfDJHCLuop+eOct0ZOb+ PPXAvLM/NCeaZWfojXsvx7QwtxuJn0dqnoJBZ1olOgeKKW8cJVl04aFw1Rsj1sz6 8nLjhGNwpsfcn4rp+CvTCOUKSEWHRccZK3R8CEEIQ6vwUtLBtM48vGeucczqCre1 juDX8FrM1gwMbaTGO8vcIFQnax4BA+0SXsperTI4DemD07H5QDXzaFcoGISng83S /ZMdiQFzhuqg5JvrvXkxvOnIavlkRxeR6F1gBHj0qpQhho4cBXqAqP/OUZpBPgzw == Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pf43ts6-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 20:15:46 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2J4Gr42859109; Wed, 2 Dec 2026 20:15:45 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4jaajsbav0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 20:15:45 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B2KFiId29426194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Dec 2026 20:15:45 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D027958069; Wed, 2 Dec 2026 20:15:44 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2503C58052; Wed, 2 Dec 2026 20:15:44 +0000 (GMT) Received: from li-43857255-d5e6-4659-90f1-fc5cee4750ad.ibm.com (unknown [9.77.162.217]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Dec 2026 20:15:44 +0000 (GMT) Message-ID: <6d816790f56a45f95790dd240c56f1625fb5d66e.camel@linux.ibm.com> Subject: Re: [PATCH v2] ima: Fix out-of-bounds read in ima_read_policy() From: Mimi Zohar To: Bruno Meneguele , Roberto Sassu , dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, fabrice.derepas@canonical.com, Kenneth Goldman Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Roberto Sassu In-Reply-To: References: <20261202105724.3056284-1-roberto.sassu@huaweicloud.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:15:43 -0500 X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Evolution 3.62.1 (3.62.1-1.fc45) X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA4MCBTYWx0ZWRfX0/9/iO40GmXg 2obyrEfhJbehGCL9UDb/PMKhUIYHd9TkvUGz3GMcEfAc/ofCQtH+DUbrGg83XXSnZm2SxYuBSj/ mZmlPic3s/QZB5JAhHIDEhunHSnlq/s= X-Proofpoint-ORIG-GUID: 0qfzmR-5DV_CNRavsObNm50ZfM8vSxwm X-Proofpoint-GUID: 7THzAoDaSzOnomiGj1XOBrLJCVC7HYlv X-Authority-Analysis: v=2.4 cv=R6eWitRX c=1 sm=1 tr=0 ts=6b107c73 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VwQbUJbxAAAA:8 a=DfNHnWVPAAAA:8 a=NEAV23lmAAAA:8 a=UXIAUNObAAAA:8 a=i0EeH86SAAAA:8 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8 a=QIhr-27iAAAA:8 a=lT5sErzFNmj0oS74rUIA:9 a=QEXdDO2ut3YA:10 a=rjTVMONInIDnV1a_A2c_:22 a=a1s67YnXd6TbAZZNj1wK:22 a=cgaYBWEFosGJW4rWv5Lf:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA4MCBTYWx0ZWRfX97H/anmrB2Kj mZwLXnsZxgA72AmIqwWZ/XjbUj/P0S4Efjl7mfcYOYDFBcMZZJoJuvhC6f8Q/Pmlm1takLjsBvL 1ddaqgAQItvLorLK4P/AYfbdqFashU3Ty6EyyEws9X5CnUoSVADpEKDrmpH8Sax/fCMZCkzhQxB BNYIM/tIfS6qVq+GmqxAZsM/DaJnFr4025jKG7WI1PktkCSQ+yutxoAhZTDOLlLypcUG8U0JjWF DQCfbsgjs25oj4Jg0Mcuk/6ShihS7t1Z0NtW4OhpB4xeWZtJzA9QYVGW6V2ufQx7jHLkbyf37kv rEHVIM20ioe/yBGM9YTaheCDaRDu7nxft/04ItKUD9NlgHkbW2AObEJUu9U09LioodhgT9LBumE lia3RHkCHf11unHAwh0dyABw9qU9j5AaKJF+0Ah7OeOMfiMivOmgO52AOX3iX43ihVfK/2Jtt+2 wAVAbKP12gGBTYQCs1A== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_05,2026-12-02_07,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020080 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 > >=20 > > ima_read_policy() reads the policy file with kernel_read_file_from_path= () > > and splits it into rules with strsep(). However, the buffer allocated b= y > > kernel_read_file_from_path() is exactly the size of the file and is not > > 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. > >=20 > > To avoid the problem, reject the read policy if does not end with a new= line > > or the NUL terminator. > >=20 > > 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(+) > >=20 > > diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/i= ma_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) > > =09rc =3D 0; > >=20 > > =09datap =3D data; > > + > > +=09if (size && datap[size - 1] !=3D '\n' && datap[size - 1] !=3D '\0')= { > > +=09=09vfree(data); > > +=09=09return -EINVAL; > > +=09} > > + > > =09while (size > 0 && (p =3D strsep(&datap, "\n"))) { > > =09=09pr_debug("rule: %s\n", p); > > =09=09rc =3D ima_parse_add_rule(p); >=20 > May I suggest an addition to [1] about it? That's literally an invisible = failure > the user won't find out the reason easily. >=20 > [1] https://github.com/linux-integrity/ima-doc Thanks, Bruno. Agreed, ima-docs should be updated. It belongs as the last sentence of the initial custom policy paragraph[1].=C2=A0 [1] https://ima-doc.readthedocs.io/en/latest/ima-policy.html#custom-policy >=20 >=20 > Acked-by: Bruno Meneguele As per the relatively new "Acked-by" usage, let's append a comment like the= 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 do= main knowledge (e.g. the original author of the code being modified), userspa= ce- side reviewers for a kernel uAPI patch or key users of a feature. Option= ally, in these cases, it can be useful to add a =E2=80=9C# Suffix=E2=80=9D to = clarify its meaning: =20 Acked-by: The Stakeholder # As primary user thanks, Mimi