From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 192A6286417 for ; Mon, 16 Feb 2026 21:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771278250; cv=none; b=G1i/JKiuPgJ4IzYYjpivKrffOgyLDd8mkDw8X7mKzNWsnfrl33CWg65IiO7o9uZZvCaGfVOo94497DdgXKrNL3L67/aSxY+wy2XCFsunfoPY0b3INhZUH9IdK569pgbD04U34IBhFo8PU6Ys7jAlR20uubXHz97CKij80VzAL8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771278250; c=relaxed/simple; bh=VAzTqo4vbXr8m49U0BBWa9rngxeDz0Euqj4DoptU4AI=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ACZt3QNlJktzEeUo2qKa1bFmOjSJO+EckGJjoGQxQM9sagMLodkX91u6cyARrMcAw45LdeA9ayOkjLu4iCB5Y4u10GJeVA6j6Z6N9ZLihzhaJOZTI5eiCK9BDkJymkXOWyyV+ZzJXVJWUUh6FobO6am9ikYFZ4+Vc/ZtyinRr0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=wb1aDObO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="wb1aDObO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82656C116C6; Mon, 16 Feb 2026 21:44:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1771278249; bh=VAzTqo4vbXr8m49U0BBWa9rngxeDz0Euqj4DoptU4AI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=wb1aDObOR6kZtDVklaYqXKOyTC68B6P70UEyjS6i9y3eIK3GQ7aMVowE0aDVZ3SoV PUhkBB1jy46mv6fOpH1GEsu/8F3Ejs0RerUQYnScDkpyIF8tO5Byj2rTTgVyXt+paO zbDz1VRsZ07ajfOkozUx1EDnfLEH7+Z7drW7vJo8= Date: Mon, 16 Feb 2026 13:44:08 -0800 From: Andrew Morton To: Pratyush Yadav Cc: Pasha Tatashin , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] liveupdate: luo_file: remember retrieve() status Message-Id: <20260216134408.12dc6f88f7139054f9e34637@linux-foundation.org> In-Reply-To: <20260216132221.987987-1-pratyush@kernel.org> References: <20260216132221.987987-1-pratyush@kernel.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Mon, 16 Feb 2026 14:22:19 +0100 Pratyush Yadav wrote: > From: "Pratyush Yadav (Google)" > > LUO keeps track of successful retrieve attempts on a LUO file. It does > so to avoid multiple retrievals of the same file. Multiple retrievals > cause problems because once the file is retrieved, the serialized data > structures are likely freed and the file is likely in a very different > state from what the code expects. > > The retrieve boolean in struct luo_file keeps track of this, and is > passed to the finish callback so it knows what work was already done and > what it has left to do. > > All this works well when retrieve succeeds. When it fails, > luo_retrieve_file() returns the error immediately, without ever storing > anywhere that a retrieve was attempted or what its error code was. This > results in an errored LIVEUPDATE_SESSION_RETRIEVE_FD ioctl to userspace, > but nothing prevents it from trying this again. > > The retry is problematic for much of the same reasons listed above. The > file is likely in a very different state than what the retrieve logic > normally expects, and it might even have freed some serialization data > structures. Attempting to access them or free them again is going to > break things. > > For example, if memfd managed to restore 8 of its 10 folios, but fails > on the 9th, a subsequent retrieve attempt will try to call > kho_restore_folio() on the first folio again, and that will fail with a > warning since it is an invalid operation. > > Apart from the retry, finish() also breaks. Since on failure the > retrieved bool in luo_file is never touched, the finish() call on > session close will tell the file handler that retrieve was never > attempted, and it will try to access or free the data structures that > might not exist, much in the same way as the retry attempt. > > There is no sane way of attempting the retrieve again. Remember the > error retrieve returned and directly return it on a retry. Also pass > this status code to finish() so it can make the right decision on the > work it needs to do. > > This is done by changing the bool to an integer. A value of 0 means > retrieve was never attempted, a positive value means it succeeded, and a > negative value means it failed and the error code is the value. > > Fixes: 7c722a7f44e0 ("liveupdate: luo_file: implement file systems callbacks") Should we backport this into 6.19.1?