Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Stefan Berger <stefanb@linux.ibm.com>,
	Petr Vorel <pvorel@suse.cz>,
	Roberto Sassu <roberto.sassu@huawei.com>,
	Mimi Zohar <zohar@linux.ibm.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 008/101] ima: limit the number of ToMToU integrity violations
Date: Wed, 17 Sep 2025 14:33:51 +0200	[thread overview]
Message-ID: <20250917123337.070995002@linuxfoundation.org> (raw)
In-Reply-To: <20250917123336.863698492@linuxfoundation.org>

6.6-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Mimi Zohar <zohar@linux.ibm.com>

[ Upstream commit a414016218ca97140171aa3bb926b02e1f68c2cc ]

Each time a file in policy, that is already opened for read, is opened
for write, a Time-of-Measure-Time-of-Use (ToMToU) integrity violation
audit message is emitted and a violation record is added to the IMA
measurement list.  This occurs even if a ToMToU violation has already
been recorded.

Limit the number of ToMToU integrity violations per file open for read.

Note: The IMA_MAY_EMIT_TOMTOU atomic flag must be set from the reader
side based on policy.  This may result in a per file open for read
ToMToU violation.

Since IMA_MUST_MEASURE is only used for violations, rename the atomic
IMA_MUST_MEASURE flag to IMA_MAY_EMIT_TOMTOU.

Cc: stable@vger.kernel.org # applies cleanly up to linux-6.6
Tested-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
[ adapted IMA flag definitions location from ima.h to integrity.h ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/integrity/ima/ima_main.c |   16 +++++++++++-----
 security/integrity/integrity.h    |    3 ++-
 2 files changed, 13 insertions(+), 6 deletions(-)

--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -128,16 +128,22 @@ static void ima_rdwr_violation_check(str
 		if (atomic_read(&inode->i_readcount) && IS_IMA(inode)) {
 			if (!iint)
 				iint = integrity_iint_find(inode);
+
 			/* IMA_MEASURE is set from reader side */
-			if (iint && test_bit(IMA_MUST_MEASURE,
-						&iint->atomic_flags))
+			if (iint && test_and_clear_bit(IMA_MAY_EMIT_TOMTOU,
+						       &iint->atomic_flags))
 				send_tomtou = true;
 		}
 	} else {
 		if (must_measure)
-			set_bit(IMA_MUST_MEASURE, &iint->atomic_flags);
-		if (inode_is_open_for_write(inode) && must_measure)
-			send_writers = true;
+			set_bit(IMA_MAY_EMIT_TOMTOU, &iint->atomic_flags);
+
+		/* Limit number of open_writers violations */
+		if (inode_is_open_for_write(inode) && must_measure) {
+			if (!test_and_set_bit(IMA_EMITTED_OPENWRITERS,
+					      &iint->atomic_flags))
+				send_writers = true;
+		}
 	}
 
 	if (!send_tomtou && !send_writers)
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -74,7 +74,8 @@
 #define IMA_UPDATE_XATTR	1
 #define IMA_CHANGE_ATTR		2
 #define IMA_DIGSIG		3
-#define IMA_MUST_MEASURE	4
+#define IMA_MAY_EMIT_TOMTOU	4
+#define IMA_EMITTED_OPENWRITERS	5
 
 enum evm_ima_xattr_type {
 	IMA_XATTR_DIGEST = 0x01,



  parent reply	other threads:[~2025-09-17 12:54 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17 12:33 [PATCH 6.6 000/101] 6.6.107-rc1 review Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 001/101] kunit: kasan_test: disable fortify string checker on kasan_strings() test Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 002/101] mm: introduce and use {pgd,p4d}_populate_kernel() Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 003/101] kasan: fix GCC mem-intrinsic prefix with sw tags Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 004/101] nfsd: Fix a regression in nfsd_setattr() Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 005/101] NFSD: nfsd_unlink() clobbers non-zero status returned from fh_fill_pre_attrs() Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 006/101] media: i2c: imx214: Fix link frequency validation Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 007/101] net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod Greg Kroah-Hartman
2025-09-17 12:33 ` Greg Kroah-Hartman [this message]
2025-09-17 12:33 ` [PATCH 6.6 009/101] flexfiles/pNFS: fix NULL checks on result of ff_layout_choose_ds_for_read Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 010/101] SUNRPC: call xs_sock_process_cmsg for all cmsg Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 011/101] NFSv4: Dont clear capabilities that wont be reset Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 012/101] NFSv4: Clear the NFS_CAP_FS_LOCATIONS flag if it is not set Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 013/101] NFSv4: Clear the NFS_CAP_XATTR flag if not supported by the server Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 014/101] tracing: Fix tracing_marker may trigger page fault during preempt_disable Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 015/101] ftrace/samples: Fix function size computation Greg Kroah-Hartman
2025-09-17 12:33 ` [PATCH 6.6 016/101] fs/nfs/io: make nfs_start_io_*() killable Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 017/101] NFS: Serialise O_DIRECT i/o and truncate() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 018/101] NFSv4.2: Serialise O_DIRECT i/o and fallocate() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 019/101] NFSv4.2: Serialise O_DIRECT i/o and clone range Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 020/101] NFSv4.2: Serialise O_DIRECT i/o and copy range Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 021/101] NFSv4/flexfiles: Fix layout merge mirror check Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 022/101] tracing: Silence warning when chunk allocation fails in trace_pid_write Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 023/101] s390/cpum_cf: Deny all sampling events by counter PMU Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 024/101] bpf: Tell memcg to use allow_spinning=false path in bpf_timer_init() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 025/101] tcp_bpf: Call sk_msg_free() when tcp_bpf_send_verdict() fails to allocate psock->cork Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 026/101] proc: fix type confusion in pde_set_flags() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 027/101] rcu-tasks: Maintain lists to eliminate RCU-tasks/do_exit() deadlocks Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 028/101] rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 029/101] rcu-tasks: Maintain real-time response in rcu_tasks_postscan() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 030/101] KVM: SVM: Set synthesized TSA CPUID flags Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 031/101] EDAC/altera: Delete an inappropriate dma_free_coherent() call Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 032/101] Revert "SUNRPC: Dont allow waiting for exiting tasks" Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 033/101] compiler-clang.h: define __SANITIZE_*__ macros only when undefined Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 034/101] mptcp: sockopt: make sync_socket_options propagate SOCK_KEEPOPEN Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 035/101] ocfs2: fix recursive semaphore deadlock in fiemap call Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 036/101] i2c: i801: Hide Intel Birch Stream SoC TCO WDT Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 037/101] net: usb: asix: ax88772: drop phylink use in PM to avoid MDIO runtime PM wakeups Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 038/101] mtd: rawnand: stm32_fmc2: avoid overlapping mappings on ECC buffer Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 039/101] mtd: rawnand: stm32_fmc2: fix ECC overwrite Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 040/101] fuse: check if copy_file_range() returns larger than requested size Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 041/101] fuse: prevent overflow in copy_file_range return value Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 042/101] mm/memory-failure: fix VM_BUG_ON_PAGE(PagePoisoned(page)) when unpoison memory Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 043/101] mm/damon/core: set quota->charged_from to jiffies at first charge window Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 044/101] drm/mediatek: fix potential OF node use-after-free Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 045/101] drm/amdgpu/vcn: Allow limiting ctx to instance 0 for AV1 at any time Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 046/101] drm/amdgpu/vcn4: Fix IB parsing with multiple engine info packages Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 047/101] mtd: nand: raw: atmel: Fix comment in timings preparation Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 048/101] mtd: nand: raw: atmel: Respect tAR, tCLR in read setup timing Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 049/101] libceph: fix invalid accesses to ceph_connection_v1_info Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 050/101] mm/damon/sysfs: fix use-after-free in state_show() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 051/101] mm/damon/reclaim: avoid divide-by-zero in damon_reclaim_apply_parameters() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 052/101] mm/damon/lru_sort: avoid divide-by-zero in damon_lru_sort_apply_parameters() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 053/101] btrfs: use readahead_expand() on compressed extents Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 054/101] btrfs: fix corruption reading compressed range when block size is smaller than page size Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 055/101] mm/khugepaged: convert hpage_collapse_scan_pmd() to use folios Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 056/101] mm/khugepaged: fix the address passed to notifier on testing young Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 057/101] cifs: fix pagecache leak when do writepages Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 058/101] kernfs: Fix UAF in polling when open file is released Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 059/101] Input: iqs7222 - avoid enabling unused interrupts Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 060/101] Input: i8042 - add TUXEDO InfinityBook Pro Gen10 AMD to i8042 quirk table Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 061/101] Revert "net: usb: asix: ax88772: drop phylink use in PM to avoid MDIO runtime PM wakeups" Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 062/101] tty: hvc_console: Call hvc_kick in hvc_write unconditionally Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 063/101] serial: sc16is7xx: fix bug in flow control levels init Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 064/101] dt-bindings: serial: brcm,bcm7271-uart: Constrain clocks Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 065/101] USB: serial: option: add Telit Cinterion FN990A w/audio compositions Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 066/101] USB: serial: option: add Telit Cinterion LE910C4-WWX new compositions Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 067/101] Disable SLUB_TINY for build testing Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 068/101] net: fec: Fix possible NPD in fec_enet_phy_reset_after_clk_enable() Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 069/101] net: bridge: Bounce invalid boolopts Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 070/101] tunnels: reset the GSO metadata before reusing the skb Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 071/101] docs: networking: can: change bcm_msg_head frames member to support flexible array Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 072/101] igb: fix link test skipping when interface is admin down Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 073/101] i40e: fix IRQ freeing in i40e_vsi_request_irq_msix error path Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 074/101] can: j1939: j1939_sk_bind(): call j1939_priv_put() immediately when j1939_local_ecu_get() failed Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 075/101] can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() fails Greg Kroah-Hartman
2025-09-17 12:34 ` [PATCH 6.6 076/101] can: xilinx_can: xcan_write_frame(): fix use-after-free of transmitted SKB Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 077/101] net: hsr: Add support for MC filtering at the slave device Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 078/101] net: hsr: Add VLAN CTAG filter support Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 079/101] hsr: use rtnl lock when iterating over ports Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 080/101] hsr: use hsr_for_each_port_rtnl in hsr_port_get_hsr Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 081/101] dmaengine: idxd: Remove improper idxd_free Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 082/101] dmaengine: idxd: Fix refcount underflow on module unload Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 083/101] dmaengine: idxd: Fix double free in idxd_setup_wqs() Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 084/101] dmaengine: ti: edma: Fix memory allocation size for queue_priority_map Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 085/101] regulator: sy7636a: fix lifecycle of power good gpio Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 086/101] hrtimer: Remove unused function Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 087/101] hrtimer: Rename __hrtimer_hres_active() to hrtimer_hres_active() Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 088/101] hrtimers: Unconditionally update target CPU base after offline timer migration Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 089/101] RISC-V: Remove unnecessary include from compat.h Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 090/101] xhci: fix memory leak regression when freeing xhci vdev devices depth first Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 091/101] USB: gadget: dummy-hcd: Fix locking bug in RT-enabled kernels Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 092/101] usb: gadget: midi2: Fix missing UMP group attributes initialization Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 093/101] usb: gadget: midi2: Fix MIDI2 IN EP max packet size Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 094/101] dmaengine: qcom: bam_dma: Fix DT error handling for num-channels/ees Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 095/101] dmaengine: dw: dmamux: Fix device reference leak in rzn1_dmamux_route_allocate Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 096/101] phy: tegra: xusb: fix device and OF node leak at probe Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 097/101] phy: ti-pipe3: fix device leak at unbind Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 098/101] ksmbd: fix null pointer dereference in alloc_preauth_hash() Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 099/101] net: mdiobus: release reset_gpio in mdiobus_unregister_device() Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 100/101] drm/amdgpu: fix a memory leak in fence cleanup when unloading Greg Kroah-Hartman
2025-09-17 14:35   ` Deucher, Alexander
2025-09-17 14:44     ` Greg Kroah-Hartman
2025-09-17 12:35 ` [PATCH 6.6 101/101] drm/i915/power: fix size for for_each_set_bit() in abox iteration Greg Kroah-Hartman
2025-09-17 18:04 ` [PATCH 6.6 000/101] 6.6.107-rc1 review Hardik Garg
2025-09-17 20:08 ` Jon Hunter
2025-09-18  0:47 ` Peter Schneider
2025-09-18  5:17 ` Brett A C Sheffield
2025-09-18 12:59 ` [PATCH 6.6 000/101] " Ron Economos
2025-09-18 13:25 ` Anders Roxell
2025-09-18 17:36 ` Florian Fainelli
2025-09-18 20:11 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250917123337.070995002@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=patches@lists.linux.dev \
    --cc=pvorel@suse.cz \
    --cc=roberto.sassu@huawei.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefanb@linux.ibm.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox