From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 06C1B2F28FC for ; Thu, 11 Jun 2026 12:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781181612; cv=none; b=tLliHg6KyRlfrmpXWy5j3R9Yd/RV3bAIf0THWyQySzuOpT3Pnh8X86XOaWgMZWztudrddN6CeMcohxhSycsxfIwjXm+M6X4yAtW+sAQiZynVG3hhoNJbaXcnuX4HLTbCfGlUHkuQ/vii+HXyG1LXoHgPORp1HuR07lP295HydoU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781181612; c=relaxed/simple; bh=ejz6g0jF6g+TEi9rwCEpavRUzeu8sXAJK65wc2b8QNA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k5sG/fQFPEPHA0rGKZwQV4UhPH4tbzfM7gZclTiYhMDNtEnddjoUW9JoibYpKuHBhDedLIwerSnzXjtFZNdy9SHSdA0rPbI7UYICBm5SgqMbgQoCW6ymRfjjcjQmN//unHqPqQ6uEE+Tr0KFMCWx5A5iGc0MelIvlLF+JyrvO/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EeN5KasI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EeN5KasI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E54021F00893; Thu, 11 Jun 2026 12:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781181610; bh=aM4CFsjAfrgDrQU/fs6TDRb0SV1bxnyirTxwHZhtIEM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=EeN5KasIedx+VFynls428joJP2xO7wsQhXM+JE+dwrimD+izqGH64EN3R24ND7Bd8 WOsmQK2462wD4Nl6UUnx+TeQLe6jZmeJzCxGbJE9kCTym7Y7F2+lYe9uwBjylfGNin fBshJXlf3l7DuGg/RQu28awc0CrVkW8mx2eOtPM1j+sJIYkq+hMiZHCS3DMgBFSKIh UZ9jIkl1vc56xvDb60tgS/o8bQqCic4lJ6dXyW8gDjEs0YfzC+zxSu3nXvBUji9mvc HY3ddRBs0PSon87+zIP8x9gb9rd2JQWVK/rCIWQIaAcpRpmkv4nvWaHSnfMrNYUoSb khYH9VNVAPXKQ== Date: Thu, 11 Jun 2026 15:40:03 +0300 From: Mike Rapoport To: Tarun Sahu Cc: Pasha Tatashin , Pratyush Yadav , Andrew Morton , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH] mm/memfd_luo: validate serialized_data before conversion Message-ID: References: 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: On Thu, Jun 11, 2026 at 10:30:03AM +0000, Tarun Sahu wrote: > In memfd_luo_finish() and memfd_luo_retrieve(), phys_to_virt() was called > on args->serialized_data before checking if the physical address is valid. > Since physical address 0 does not map to virtual NULL (due to direct > mapping offsets), the subsequent check 'if (!ser)' was ineffective at > catching a missing serialized_data, leading to unsafe dereferences later. > > Validate that args->serialized_data is non-zero before calling > phys_to_virt(). > > Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd") > Signed-off-by: Tarun Sahu > --- > mm/memfd_luo.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/memfd_luo.c b/mm/memfd_luo.c > index 59de210bee5f..10f3983b0060 100644 > --- a/mm/memfd_luo.c > +++ b/mm/memfd_luo.c > @@ -397,10 +397,11 @@ static void memfd_luo_finish(struct liveupdate_file_op_args *args) > if (args->retrieve_status) > return; > > - ser = phys_to_virt(args->serialized_data); > - if (!ser) > + if (!args->serialized_data) We really should make args->serialized_data a KHOSER_PTR > return; > > + ser = phys_to_virt(args->serialized_data); > + > if (ser->nr_folios) { > folios_ser = kho_restore_vmalloc(&ser->folios); > if (!folios_ser) > @@ -522,10 +523,11 @@ static int memfd_luo_retrieve(struct liveupdate_file_op_args *args) > struct file *file; > int err; > > - ser = phys_to_virt(args->serialized_data); > - if (!ser) > + if (!args->serialized_data) > return -EINVAL; > > + ser = phys_to_virt(args->serialized_data); > + > /* Make sure the file only has seals supported by this version. */ > if (ser->seals & ~MEMFD_LUO_ALL_SEALS) { > err = -EOPNOTSUPP; > > base-commit: 9716c086c8e8b141d35aa61f2e96a2e83de212a7 > -- > 2.54.0.1099.g489fc7bff1-goog > -- Sincerely yours, Mike.