From nobody Thu Apr 2 20:27:03 2026 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52DCA426EB2; Thu, 26 Mar 2026 17:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.23 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774546292; cv=none; b=EB21+pNvbLumbg/Ysa8FYsol3RC4mnUQFZFAtcddNJ8Ya9OgPaHx1/hjsoT1vE2tAVYt+gxQCTI4uNXkDmEEUekGO3CMzUHBJ1ubeI3XPGbgmijdVt8BEz+yWhA3eG4QX3QYY6dUGkRHPGBt3pD8UGuh2M7WJ8bgYGZ7hjQd2Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774546292; c=relaxed/simple; bh=3ASW5h9Qjj/PBWMoihRtUZCUgJ9yLdTRrgCN/5L4wck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R2QCmZ8qvRjn519D2Hvvh9OFchnnlxc/H0y7r5CmzF0lcBBG1gPuVrpTF7ZJmONq1wbzIZGJubT/DmN/ddR6qiUJqM6P0I0HSP0BxwC0N+jdGwnl4vAKQ2onlf8HTIx9qiUqOn091NuwdgRX/09pNo7z5l1S6GBqc2Ic5CIT26U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.224.235]) by frasgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fhW1h5Kqdz1HBts; Fri, 27 Mar 2026 01:27:36 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id 07B9340560; Fri, 27 Mar 2026 01:31:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.204.63.22]) by APP1 (Coremail) with SMTP id LxC2BwB3Yu84bcVppGUvAQ--.1881S7; Thu, 26 Mar 2026 18:31:23 +0100 (CET) From: Roberto Sassu To: corbet@lwn.net, skhan@linuxfoundation.org, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, gregorylumen@linux.microsoft.com, chenste@linux.microsoft.com, nramas@linux.microsoft.com, Roberto Sassu Subject: [PATCH v4 05/13] ima: Introduce _ima_measurements_start() and _ima_measurements_next() Date: Thu, 26 Mar 2026 18:30:03 +0100 Message-ID: <20260326173011.1191815-6-roberto.sassu@huaweicloud.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260326173011.1191815-1-roberto.sassu@huaweicloud.com> References: <20260326173011.1191815-1-roberto.sassu@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: LxC2BwB3Yu84bcVppGUvAQ--.1881S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kry8Jw4fAryrGFWxZw1xGrg_yoW5JFyxpa sxua4rCF4kJ3yxWF1xGrWDWr4ru3sag3WDWrWUJ34vvF1UJr1v9r43Aw12vrn0y348Xr1v vr90gr45Cw4FyaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPlb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E 14v26r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrV C2j2WlYx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE 7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwCY1x0262 kKe7AKxVWrXVW3AwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s02 6c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GF v_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvE c7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aV AFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZF pf9x07jhXo7UUUUU= X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAgAEBGnEnS4T6AAAsn Content-Type: text/plain; charset="utf-8" From: Roberto Sassu Introduce _ima_measurements_start() and _ima_measurements_next(), renamed from ima_measurements_start() and ima_measurements_next(), to include the list head as an additional parameter, so that iteration on different lists can be implemented by calling those functions. No functional change: ima_measurements_start() and ima_measurements_next() pass the ima_measurements list head, used before. Link: https://github.com/linux-integrity/linux/issues/1 Signed-off-by: Roberto Sassu --- security/integrity/ima/ima_fs.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_f= s.c index 79b0f287c668..9a8dba14d82a 100644 --- a/security/integrity/ima/ima_fs.c +++ b/security/integrity/ima/ima_fs.c @@ -72,14 +72,15 @@ static const struct file_operations ima_measurements_co= unt_ops =3D { }; =20 /* returns pointer to hlist_node */ -static void *ima_measurements_start(struct seq_file *m, loff_t *pos) +static void *_ima_measurements_start(struct seq_file *m, loff_t *pos, + struct list_head *head) { loff_t l =3D *pos; struct ima_queue_entry *qe; =20 /* we need a lock since pos could point beyond last element */ rcu_read_lock(); - list_for_each_entry_rcu(qe, &ima_measurements, later) { + list_for_each_entry_rcu(qe, head, later) { if (!l--) { rcu_read_unlock(); return qe; @@ -89,7 +90,13 @@ static void *ima_measurements_start(struct seq_file *m, = loff_t *pos) return NULL; } =20 -static void *ima_measurements_next(struct seq_file *m, void *v, loff_t *po= s) +static void *ima_measurements_start(struct seq_file *m, loff_t *pos) +{ + return _ima_measurements_start(m, pos, &ima_measurements); +} + +static void *_ima_measurements_next(struct seq_file *m, void *v, loff_t *p= os, + struct list_head *head) { struct ima_queue_entry *qe =3D v; =20 @@ -101,7 +108,12 @@ static void *ima_measurements_next(struct seq_file *m,= void *v, loff_t *pos) rcu_read_unlock(); (*pos)++; =20 - return (&qe->later =3D=3D &ima_measurements) ? NULL : qe; + return (&qe->later =3D=3D head) ? NULL : qe; +} + +static void *ima_measurements_next(struct seq_file *m, void *v, loff_t *po= s) +{ + return _ima_measurements_next(m, v, pos, &ima_measurements); } =20 static void ima_measurements_stop(struct seq_file *m, void *v) --=20 2.43.0