From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796021768; b=uoW6qd5sZK1cUk9HUMePCEZrSuf59BOM0z9YC2IF/mS/La3MWwpB3kY0zzWm5tSdj9vW CCJBcPccc88xGqS3WdpkhCQLPK4D0qws8tlXnuhC+e0xdLcVaL0fHVVmqIxwEJ7fPac1H oJyFFmI8oIugkc/OoX+LsXONwgMWMch20KB08oZ2XhBV1J+r+2ivp0Jc9OAn57EnQvilA T8opV4RHV4OQ1u8gHLEiUdJYq8Z/6e4bk5/+jilWd/o2oLsyMKWxpbx7t0exCUZu1x9T0 MSGLDZkRuj+z6n2o+RpiR8txRM+U5nlpqb8T/StOyqxcjZzODwh8fg2YBWLCbh5kp0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796021768; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=0j217IwFUFotmT/CA4XxIx+FQFLCx8YeCgYRZcYAggo=; b=OwVrEgcRDmmKpq2yGNOavmfXPcWACTva3703alYzulDa99Vl8+M2zuNY3lwnOIPVEP6V fS7aigOdOO/DkgZ55gyAoE+l8UyjiwQGfZRFF/sHKnr9ENypD/KZQZEsH+ow/eaZyjKtg zxtHG0x4FHgnrGLK3faEVPFKS1ChGFaz02IAlCsjyz6yz0Vg1RitMTVlceo0B1D6e1Cpk dFkFumfHarKDes4sXIw7hJNFrbyOO52evLJpBiGtR92+EPB2ajgf9JdTP1InZNNhxjQBC onHDVFqdFSVaCoSmkRkYJzeVmb5g8DpIbEUyCqhVlNlWyBWr1wse8kXa5QQPThDvi4Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iBDctZeW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7449A606A31C for ; Mon, 30 Nov 2026 06:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iBDctZeW Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF7931F00897; Mon, 30 Nov 2026 06:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796021768; bh=0j217IwFUFotmT/CA4XxIx+FQFLCx8YeCgYRZcYAggo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=iBDctZeWIa7y53xSPpParl1oxGM8FrSB5B44Uy17kwx6yW6E1Yg4k8SpEuS7gy5DI CUJmIKl+8BwQgLhqmBam9U/6tnSjm7zd5+brSzyQfDZIAkj2LkuSSubEejA3phQLRh n01T1AXDCS7pu7bJtt7859R4DXB1XY0gqFqM2HyT7eCPiWAbPh0/tamNFC33yYI8hs DSshUYXJLvQgZ888CGKqk8vCGVusOXm4cDNSGBu/Kp4/CJTuOkLijotwDIuVjbfPQf wYyXYdJbMTDkRh70zCPDbV94RdToom0TOc27W0m00SUaUWp4SDaCXlZq2RbbrtC9RQ jMk6iTXS8W4bg== Date: Mon, 30 Nov 2026 08:56:02 +0200 From: Mike Rapoport To: "Baek Kyu, Kim" Cc: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 RESEND] mm/secretmem: Keep locked memory accounting until inode eviction Message-ID: References: <179600882107.30666.13893484586058179051.c113-v4-resend@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <179600882107.30666.13893484586058179051.c113-v4-resend@gmail.com> On Mon, Nov 30, 2026 at 12:20:21PM +0900, Baek Kyu, Kim wrote: > A secretmem inode can outlive its original file. An O_PATH descriptor > opened through /proc/self/fd keeps the inode and its unevictable folios > alive after the mapping and original descriptor are closed. The file > release path nevertheless drops the locked-memory charge, allowing the > same user to reuse RLIMIT_MEMLOCK while those folios remain allocated. > > Move private-state and locked-memory accounting cleanup to inode eviction, > after truncating the page cache. Keep secretmem_users active over the same > lifetime so the hibernation guard covers retained secret pages. > > Initialize private state after creating the secure inode. The filesystem > root and an inode evicted before state attachment have no private state, > so skip private cleanup in those cases. Once state is attached, iput() > handles file-creation failures and releases the user reference on eviction. > > Fixes: 97d34aa65c29 ("mm/secretmem: properly account locked pages") > Signed-off-by: Baek Kyu, Kim Reviewed-by: Mike Rapoport (Microsoft) > --- > mm/secretmem.c | 30 +++++++++++++++++------------- > 1 file changed, 17 insertions(+), 13 deletions(-) -- Sincerely yours, Mike.