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 8DE5929827E for ; Thu, 16 Apr 2026 09:44:40 +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=1776332680; cv=none; b=NsKKzQN0XB56VtURseRynVeGU5OAoF4gkpSl42HZVMkqEZy3KLKguxAAQVdfIDqTa6133B+40pnFmFsBhvzYs6HoKIR9KyAn6DZLoNll+DqykgzDvu0dy+Tr+DQctauFzcUqrrKdC6EGD5t6cWnalwe2QetITCrMfJ9gQLsJsS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776332680; c=relaxed/simple; bh=C1B6Q/ycpGRJxXWmx7rnSJOiJwKESH8P+kjhI/iqoEM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=RL2n+C8yEqQK3Q+FHrnc/ehCWUzipCOQ2dvX6D5UWhAxcuDf+A5gznN2SgMhwRwX+dwKJzvE3/x16mlYsBGgnvaBvFCG8gupGuysgar1atGTUCpy7zZZqYCmreHgZcsCz+8dKnp2SvEdZXcZXA9tiUML5TsdBSDiDdqf3ia4h1I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QRqcfWwL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QRqcfWwL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C06BEC2BCAF; Thu, 16 Apr 2026 09:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776332680; bh=C1B6Q/ycpGRJxXWmx7rnSJOiJwKESH8P+kjhI/iqoEM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=QRqcfWwLVlutzlJWcd4eblfxvkeYGV3iLBwKV95VWeFGk2J41HWv4baV+wFuw4VbB pnt11u4k1tgYEBQv00NE1n70jfhHkmLi7ly6ZBfmLZEXbOT/xXPeUJIJ/aFIpsR0F/ ztICVLr2g32F9wQLjAPXTLUVtyWJoUMcixvJgNX6Ge4fVGm1ivQ/0IQLJj9D4pQMNQ 8n5ITpCgXMWKaYP+nkS0oawBOljImKzPm+ca7tAw6+CXV3sXltbHCrVPwY7qScXKJN Cb8+ZcVoGXuTIsl7tyT4BB7yFrtEcYbeVtfG7CqIHc7kGlQnU1Q/TiGI4Toa16ICvr AGbXCe5xaD+sg== From: Pratyush Yadav To: David Carlier Cc: Pasha Tatashin , Mike Rapoport , Pratyush Yadav , Andrew Morton , Chenghao Duan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/memfd_luo: report error when restoring a folio fails mid-loop In-Reply-To: <20260415052300.362539-1-devnexen@gmail.com> (David Carlier's message of "Wed, 15 Apr 2026 06:23:00 +0100") References: <20260415052300.362539-1-devnexen@gmail.com> Date: Thu, 16 Apr 2026 09:44:37 +0000 Message-ID: <2vxzik9r6xyy.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Apr 15 2026, David Carlier wrote: > memfd_luo_retrieve_folios() initialises err to -EIO, but the per-iteration > calls to mem_cgroup_charge(), shmem_add_to_page_cache() and > shmem_inode_acct_blocks() reuse and overwrite err. Once any iteration > completes successfully, err becomes zero. > > If a later iteration's kho_restore_folio() returns NULL, the failure path > jumps to put_folios without resetting err, so the function returns 0. > The caller memfd_luo_retrieve() then takes the success path, sets > args->file and reports the restore as successful, leaving userspace with > a partially populated memfd and no indication that anything went wrong. > > Set err to -EIO in the kho_restore_folio() failure branch so the error > is propagated to the caller. > > Signed-off-by: David Carlier Reviewed-by: Pratyush Yadav Please add these when applying: Cc: stable@vger.kernel.org Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd") [...] -- Regards, Pratyush Yadav