From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 8D9E5221FCF for ; Thu, 11 Dec 2025 21:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765487570; cv=none; b=bS+PB+6hhZHucIP9rD8B1vHZ2ob2wtE9v7vuJ7GHB3oy8beSCfJ/C5YWvkmVXRprTfRPcnq/o7tt6Du9Lr+ecFC/5yRGPL5k/t55k1Y4gD1+GfWULJfzLgEmeTSXL7JrmEpFJj8mXdCmkAGN7gXTIG9tTo5BPLyp8+xR4kqCBMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765487570; c=relaxed/simple; bh=2StT5fey7xO/gGkRoOza1EpEfTzayi0kGne6NOjJklE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HJXNDft3AUo/O31UqwsQwO0UGuFRC8cdTqnjj1zf42gS0HfY6QTSxD70DXnAx6L65K+Datd/nFBSICSCmkS1OIUphjz0R9L1UKmtbo+xvpP8LNRaDmX61EHyeQ+evg9sTSrSf9M/bq0+/MS2O7OYD6DwRBSJ3vcH/KAAjlvODCg= 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=PEswLXfr; arc=none smtp.client-ip=209.85.210.54 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="PEswLXfr" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7c71cca8fc2so382807a34.1 for ; Thu, 11 Dec 2025 13:12:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1765487568; x=1766092368; 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=3XheekkRDFybc7x85IgNduTzuOzvtB/yxFRw2uL5q9I=; b=PEswLXfrSpSYFs+imbUCO7CZiwM8N13f6CVVXN7NKXyA37AYWVaUPlg5ZDF/hEmTbl 5bs/kv4TBHUovzZAhevOfmzUo3e3GWBnN1pqyN9wVtcX7WkW1+cKvw6GdpZMZecIwu84 KsihdwxIjQu1Fl165OMI9z/HaN3ZvECHHe7J0BjdS6CPHubrZ/Id6gg+JLpgI3kNekWx 4lC3EOYpLGz6vlxWsSlrXYe9PwUip7NLm35cUO/9oL2G0IJJKp42z13Vh2cSGfEW4eWs Za+er2+TDji0GuMFx5dFJv6uhplRBO8cvAgqYW3mGwq9EUh+4XdwjGjGIsNxPUF2u7wC 5heg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765487568; x=1766092368; 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=3XheekkRDFybc7x85IgNduTzuOzvtB/yxFRw2uL5q9I=; b=ZvQiCOLHq25Ahy9Z9TF/zh5YYk2HCIMOQHE/54BQ0LyfQrBgUSB9E5qkILB3JtCy+z EvyW/UGKgBt1aqs/j9VeYZpd1fTjsy17p9+cr7d/zeWXwj4594fxj3lAHgOBXvu5AM+h 4iGoZOfi+nr+hVtD4G71+2bXxbpjoKPrk7cLJeAgjgT8JXWbLA3uxrn/mQljgEXTv1Mw BEvfbEY2+RUvSmybW6O9zsnhYk7IbeHrDAyUd/nFP0v3VemspJMNtFGyWVPInMrcjJP1 qdiSVoaDuP81jjwxN5TrRt/fW7m/wkHYVRdtk7aSh+/n87+70nJ1Hgx20hg9hQZ0Tzok MgVg== X-Forwarded-Encrypted: i=1; AJvYcCXaoOendC6DJskLWupmLzl3lgREzcYkJFFUGP7jT7nAh3u0XOKUK0lLYvFTeIxK7rBTRWaSAnpzsu6yiH0=@vger.kernel.org X-Gm-Message-State: AOJu0YyuRbEdqZgfw6xrIvC/JjRmq8jiY+68/1IeOTRLFGWQXuZf99Dv nkgd9CKy+9CWhWI118i8aAo8wvOk8DDoMHt9h9nFROFWcd+MUvYxRXuwml7igBHE2s0= X-Gm-Gg: AY/fxX7GtecvljjdOtBo54aWERDs2OfKpXOlMVvPRzy6fVz3fNDMiRp854VGRB4EVgm Beu+w9frNKMui1L2RaAXOV+Dvpdqjom4nlTJAMZRl5w7sjXWurSx1lVZsKvSRGyyKv7dduPdj0H AYa13oAleV+fDHPgw1zKUwi6uAFYJkzCcVpA/jZKfnjQ0f/wvOf8f4nPjysO8AnCDRc5HQnQm/X 1Iu3UvZeA88lTgv2tdwykVMCabzxIgumFLSFrpYtX/EZFqNoCGyBEX3msToVo5mE1IVRuT5ZnMs IC0/RPQcFPlCQ+xrGXfLkdI+AoQ1D7IdzgyYlgkcE5XmHGMDky2UakY8jkTH7xM0i9x9Tl3Vuu8 vidCLiQA5T10Ps/eiExbZI/rtusKjF4gIUcSPgInmVE+ojoXOfn/Oqhig1kC4NKhpTzk= X-Google-Smtp-Source: AGHT+IFSOsvPqHBXCLwDMa/o2UaxQjPew98a3AmxZA3+OsFsZN55l1zZO8FFLZh/lYirNNidSm4pnQ== X-Received: by 2002:a05:6830:4c08:b0:7c7:6da2:6d67 with SMTP id 46e09a7af769-7caceba996emr3989412a34.3.1765487567654; Thu, 11 Dec 2025 13:12:47 -0800 (PST) Received: from CMGLRV3 ([2a09:bac5:947d:1b37::2b6:8]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cadb1d0facsm2218090a34.3.2025.12.11.13.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 13:12:47 -0800 (PST) Date: Thu, 11 Dec 2025 15:12:45 -0600 From: Frederick Lawler To: Jeff Layton Cc: Christian Brauner , "Darrick J. Wong" , Josef Bacik , Carlos Maiolino , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, Roberto Sassu , kernel-team@cloudflare.com Subject: Re: xfs/ima: Regression caching i_version Message-ID: References: <2b193b5ccd696420196ae9059f83dcc8b3f06473.camel@kernel.org> 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: <2b193b5ccd696420196ae9059f83dcc8b3f06473.camel@kernel.org> On Fri, Dec 12, 2025 at 05:55:45AM +0900, Jeff Layton wrote: > On Thu, 2025-12-11 at 14:29 -0600, Frederick Lawler wrote: > > Hi Jeff, > > > > While testing 6.18, I think I found a regression with > > commit 1cf7e834a6fb ("xfs: switch to multigrain timestamps") since 6.13 > > where IMA is no longer able to properly cache i_version when we overlay > > tmpfs on top of XFS. Each measurement diff check in function > > process_measurement() reports that the i_version is > > always set to zero for iint->real_inode.version. > > > > The function ima_collect_measurement() is looking to extract the version > > from the cookie on next measurement to cache i_version. > > > > I'm unclear from the commit description what the right approach here is: > > update in IMA land by checking for time changes, or do > > something else such as adding the cookie back. > > > > > > What we probably want to do is switch to using the ctime to manufacture > a change attribute when STATX_CHANGE_ATTRIBUTE is not set in the statx > reply. > > IIRC, IMA doesn't need to persist these values across reboot, so > something like this (completely untested) might work, but it may be > better to lift nfsd4_change_attribute() into a common header and use > the same mechanism for both: I agree lifting nfsd4_change_attribute(), if anything else, a consistent place to fetch the i_version from. Am I correct in my understanding that the XOR on the times will cancel out and result in just the i_version? IMA is calling into inode_eq_iversion() to perform the comparison between the cached value and inode.i_version. > > diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c > index c35ea613c9f8..5a71845f579e 100644 > --- a/security/integrity/ima/ima_api.c > +++ b/security/integrity/ima/ima_api.c > @@ -272,10 +272,14 @@ int ima_collect_measurement(struct ima_iint_cache *iint, struct file *file, > * to an initial measurement/appraisal/audit, but was modified to > * assume the file changed. > */ > - result = vfs_getattr_nosec(&file->f_path, &stat, STATX_CHANGE_COOKIE, > + result = vfs_getattr_nosec(&file->f_path, &stat, STATX_CHANGE_COOKIE | STATX_CTIME, > AT_STATX_SYNC_AS_STAT); > - if (!result && (stat.result_mask & STATX_CHANGE_COOKIE)) > - i_version = stat.change_cookie; > + if (!result) { > + if (stat.result_mask & STATX_CHANGE_COOKIE) > + i_version = stat.change_cookie; > + else if (stat.result_mask & STATX_CTIME) > + i_version = stat.ctime.tv_sec ^ stat.ctime.tv_nsec; > + } > hash.hdr.algo = algo; > hash.hdr.length = hash_digest_size[algo]; >