From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88A8E2ECD3A for ; Fri, 6 Feb 2026 20:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770408421; cv=none; b=cemgh5klQfTCusyvmGdsc30QrRwAcM4oAQO9grm0nDGirFQw0nTOg0FWowDSM8qiUGFRLUM82E9h0Z0EGM9MsLy+fU01TLtGm1uYCSAo/vthL7Lp7R06Ffv9nqPmqzRx8i1coxUqHL2TOIlqBFgHUXApPs0qGmwfmqB8I7fK/ck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770408421; c=relaxed/simple; bh=J9VSf4GFSRnCeM/zRTTO3OcekKEgf2VSDADW3OuMymE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OoSRZbPz9MwuxS8EWA8tBHwK/h/9BAodE8fOzLfRz8NO81HiC77z2qQ/l8c2pE1Apieq8kPx9avMty0Zha4Wg6jt5aDOeKoBZS1k3OK5O3yqHWCqRbx6uEiGUYvHtUUOZft9jq9yyPhDeTNDUjzF6jlpgQTorIVMiANudnDjdI4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=T60VaSKU; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="T60VaSKU" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-7d195166b2cso1929312a34.3 for ; Fri, 06 Feb 2026 12:07:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1770408420; x=1771013220; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=u3wE/nOGLvc3QkX9UGDprKILAWky/nGcYsK1Fu7jX+4=; b=T60VaSKUIsAO9mkrJBLF5+7rAumRBGzDL/ZOfvAFJzzAnw7DWHKRCmiScn+gxyBlUA nyJWvwW+PrD4scXR7zmwXOT4f0daQMnxXtMqmG3gqaVVp9tYJ23xDjat13C8ia48qeQe M4/B/2eSeiahhOVjKMjvDtQuu4jIhhYBB3H7wvBOs3YuS0hyRkP3jecTk9Cro0m8LCeG 2vhM20XT7MtzFxTz/g3B3EfY3JZ1NC71LgwaYVo/KhfOh9+ZfUPPRFCqRHrZ1VFwV5Cw C7sy4FuFd4YwIkAq5o2cPrBAuudVNsR3BiTyo+SwovRIVd8qf8LaslTt6rKhqeyCxCzk yf3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770408420; x=1771013220; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u3wE/nOGLvc3QkX9UGDprKILAWky/nGcYsK1Fu7jX+4=; b=phLszzIM1QK/Hcuzim9aqo3kmFd3fmftF0UE4N4Q9x26IlwSlzjTI09/PrGF+6RavA ySfMqXaeby5zEtYMYhnux8rtJWmL4WAOV1jSl7mtjTvvmF2yeP3WQKDgTDiq3U7LiuQ6 VsZLUAzCdJbQujtYlOq6K3zfhiG8QkeeDIWamEAg7Gu6irsAXxw8lTly3KNEKFjZr0AW gAbGmTb4s2DqF9jbHY4k7bkG0fLa3RXrodGyMtnCL8w7hCxu7LHkIQUjShm1hyoN4UOX KMhCKtBPU4yCxH+KhubPKr023fjNTcI0glXK/EzTQ/Q1ScIHWvmsYws7ZrNK6a29EG16 V65w== X-Forwarded-Encrypted: i=1; AJvYcCW8PtaHKculp2gwF2n0A//KqNUel4f4bWT9i8yniexYiOMA7EnbcsVJvcky80krjfMx5Sbw/Escabx6LjQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyZQvCXqIw2vxfo750wAsxvse1r+xK+Fj4maWboGpRNfEzuvvz2 4DvL/o5lLzma9HM6NC8oUGsWgRmxc5WRUrpGCiRpfIOyJw/VyzJ9i8CxM7JERKLgjJE= X-Gm-Gg: AZuq6aLWLdZjFArrUBjwndMKoX68g8Wiqu7dPIQW1ksJArH93WcVSifJlsHYFSoz7z5 tTDbjub41txz1VDVe3vLqTdO0FjkGeckG/BQmxaanm5bW83ZRlCq2jdodVgFb2NeSb33eMDq2NP WRbUrgkpkifrwTfuNBqoBsEitcBUIF03SLjea1ffAOUCrpov1UwJ9eckm92MYBDbdZO3VlumJV6 1pYLE81MtpdeaPF2H6HCARtNQ0OOI3pxIR7tkh29guWlULHeuDrgVY2iuGlP1TczpcjjVWiFqBB liB4KTI1Lv0GZD/xlrSE/NbmlB6oBwj7om6laRZ7JiPbHCp8QNYhQRHDKiJxQvnbpxOy4rqN9Vd etNgR6UThgjpQWZ4uisMQ4Hrs8BQF7KW+uF/ojxHVIbe0e95clPmNlDnuzmSJpJDXtA== X-Received: by 2002:a05:6830:6f47:b0:7c7:6043:dd87 with SMTP id 46e09a7af769-7d4643ebfb8mr2045525a34.6.1770408420345; Fri, 06 Feb 2026 12:07:00 -0800 (PST) Received: from CMGLRV3 ([2a09:bac5:947d:4e6::7d:6a]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d46470da04sm2246603a34.7.2026.02.06.12.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 12:06:59 -0800 (PST) Date: Fri, 6 Feb 2026 14:06:57 -0600 From: Frederick Lawler To: Mimi Zohar Cc: Roberto Sassu , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Paul Moore , James Morris , "Serge E. Hallyn" , "Darrick J. Wong" , Christian Brauner , Josef Bacik , Jeff Layton , linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, kernel-team@cloudflare.com Subject: Re: [PATCH v5 3/3] ima: Use kstat.ctime as a fallback change detection for stacked fs Message-ID: References: <20260130-xfs-ima-fixup-v5-0-57e84ea91712@cloudflare.com> <20260130-xfs-ima-fixup-v5-3-57e84ea91712@cloudflare.com> <6f82d5dc6b499ecd03c985d6de20de94fea04cfe.camel@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f82d5dc6b499ecd03c985d6de20de94fea04cfe.camel@linux.ibm.com> On Wed, Feb 04, 2026 at 11:26:27PM -0500, Mimi Zohar wrote: > On Wed, 2026-02-04 at 15:22 -0600, Frederick Lawler wrote: > > That said, I think Mimi pointed out in an email [2] where multi-grain > > file systems are impacted regardless of stacked fs or not due to the last > > writer check. > > > > I don't recall coming across that in my tests, but perhaps I did that > > specific test wrong? To be sure, I created the C program, and on the VM, > > created a XFS disk, mounted it on loopback, ran the rdwr program on > > "somefile" multiple times, and only got 1 audit log for it, until I > > mutated it with touch, and only got 2 hits: original + after mutation > > after running the program multiple times. > > > > I'm not sure what's going on there, so I'll look into that a bit more, > > but so far the impact is stacked file systems & multigrain ctime AFAIK. > > Make sure you're testing without your patch set applied or at least the last > patch. > I'm still not sure what went wrong with my test suite, but spinning up a VM similar to Mimi's, I was able to reproduce the last writer issue. I used patch 1 as a baseline because that's noop from base 6.19, and used that function as a convenient trace point. And, then running the attached example test for stacked FS works as expected on both patches 1 (multiple log messages) & 3 (just one log message). I left out the dump_stack() in integrity_inode_attrs_stat_change() for readability in these results. For Mimi's test, we just see calls into ima_check_last_writer(), and for the attached sample in 0/0, we get the calls straight from process_measurement() for stacked fs. Running Mimi's and then attached in that order, I get double the logs because the FILE_CHECK is hitting the last writer, and we get the process_measurement() for the binary run. Based on all of this, I can drop the stacked FS wording in the patch descriptions, and keep it all focused that the change_cookie semantics have been changed for multigrain file systems. Results: PATCH 1/3 [root@localhost ~]# ./mimi.sh filename: /usr/bin/date-20260206140427 filename: /usr/bin/date-20260206140427 filename: /usr/bin/date-20260206140427 FAIL: Expected 1 audit event, but found 3. [ 26.033572] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=0 change_cookie=0 [ 26.034372] ima: fred: ima_check_last_writer: must measure file: "/usr/bin/date-20260206140427" [ 26.037453] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=0 change_cookie=0 [ 26.038425] ima: fred: ima_check_last_writer: must measure file: "/usr/bin/date-20260206140427" [ 26.039821] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=0 change_cookie=0 [ 26.041383] ima: fred: ima_check_last_writer: must measure file: "/usr/bin/date-20260206140427" [root@localhost fred-tests]# ./simple-fedora.sh 314572800 bytes (315 MB, 300 MiB) copied, 0.132908 s, 2.4 GB/s Fri Feb 6 14:56:18 EST 2026 Fri Feb 6 14:56:18 EST 2026 Fri Feb 6 14:56:18 EST 2026 Fri Feb 6 14:56:18 EST 2026 FAIL: Expected 1 audit event, but found 4. Note: Does not have dmesg output because this patch didn't put the trace function into integrity_inode_attrs_changed(). PATCH 3/3 [root@localhost ~]# ./mimi.sh filename: /usr/bin/date-20260206140141 filename: /usr/bin/date-20260206140141 filename: /usr/bin/date-20260206140141 PASS: Found exactly 1 audit event. [ 17.191235] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=1770404501462431821 change_cookie=0 [ 17.192213] fred: integrity_inode_attrs_stat_changed result_mask=128 (ctime) version=1770404501462431821 ctime=1770404501462431821 [ 17.196325] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=1770404501462431821 change_cookie=0 [ 17.197380] fred: integrity_inode_attrs_stat_changed result_mask=128 (ctime) version=1770404501462431821 ctime=1770404501462431821 [ 17.199750] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=1770404501462431821 change_cookie=0 [ 17.200682] fred: integrity_inode_attrs_stat_changed result_mask=128 (ctime) version=1770404501462431821 ctime=1770404501462431821 [root@localhost fred-tests]# ./simple-fedora.sh Fri Feb 6 14:53:30 EST 2026 Fri Feb 6 14:53:30 EST 2026 Fri Feb 6 14:53:30 EST 2026 Fri Feb 6 14:53:30 EST 2026 PASS: Found exactly 1 audit event. [ 23.315358] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=1770407920086616962 change_cookie=0 [ 23.328978] fred: integrity_inode_attrs_stat_changed result_mask=128 (ctime) version=1770407920086616962 ctime=1770407920086616962 [ 23.332122] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=1770407920086616962 change_cookie=0 [ 23.347162] fred: integrity_inode_attrs_stat_changed result_mask=128 (ctime) version=1770407920086616962 ctime=1770407920086616962 [ 23.352931] fred: integrity_inode_attrs_stat_changed result_mask=0 (change cookie) version=1770407920086616962 change_cookie=0 [ 23.368026] fred: integrity_inode_attrs_stat_changed result_mask=128 (ctime) version=1770407920086616962 ctime=1770407920086616962 Note that the in stacked FS case, process_measurement() skipped the check for attrs changed, and skipped to measuring. Subsequent calls into process_measurement() hits the integrity_inode_attrs_stat_changed().