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 39F6C14B950 for ; Thu, 11 Jun 2026 14:28:57 +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=1781188139; cv=none; b=cPRzEAfS+9TnRk4KgSA6KWy2CWqNdARlmO82lleGuAb0cUw0R56DttB3c8WUbmVOAs1IUq/OMXEgKAUJ3ngCrZbC/S/ycmVPIGRtYUaaQyhBtI1TFAwrTfq5/+H79h63aig+hXpAjLw0yR4ijx6xa0W7G3S5GYkcSOYYvj0qOtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781188139; c=relaxed/simple; bh=6xwRuqV5fy9qFfMr9wQrHpN4Hq9AuZ4Ot8IBLPSadvY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pfff1F76g9brHm45+lAEJKnCl6R5L8xPrg4NM9B26NtK3f91y8dEsh/Dhq3pZprizzJrB5jn100qSF9N6YA5VonXftwp8med++6lvDGWHmsBMz8MbK2UhbPUdJmOgi817B2sxnHzkw8A7s5Zz8EKuc9iqO072inQDBzOM7j0LwY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IisiybxO; 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="IisiybxO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 754091F00893; Thu, 11 Jun 2026 14:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781188137; bh=vilZoDQISoe1jlePuvDDEKBItD7TBlXWXWHI2v7ALUU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=IisiybxOoGQs9Wo+hB/KOZUyBLt+NgYjVM4mvhXQBQC17BlI3E/2ywsHXeARxYD+I HWseCM+NPPqlBpteLd+pE9e7Ak2d62iN48+RojGh3QpXhwSQKUPhcqezEgseYge7XX qeoDRsE/9l0+RR+v2C+nekuULwqCcaegZ8eY6+pGTgjUnpl9bQmK/1Ww9qWmwmfVVq ucfNUNGAzSxoxg61LYDYvnFBlylzrwx/zPNBbaS7lzxz1ojen3wJw+jZvJndhAB8ol iDWjS5h3d56vh6cgBswDE7dfXZ2aBkH7eqhtXiQXZx3JS/2niwrFYf+9+8uJ8NCLdT aQ3EUajXXtwZg== Date: Thu, 11 Jun 2026 17:28:50 +0300 From: Mike Rapoport To: Pratyush Yadav Cc: Tarun Sahu , Pasha Tatashin , 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: <2vxzmrx1qjuf.fsf@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: <2vxzmrx1qjuf.fsf@kernel.org> On Thu, Jun 11, 2026 at 03:37:12PM +0200, Pratyush Yadav wrote: > On Thu, Jun 11 2026, Mike Rapoport wrote: > > > 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 > > Hmm, that would also be a good idea. I suppose then it would be a better > to directly convert to using KHOSER_PTR() instead of this patch? Makes sense. > -- > Regards, > Pratyush Yadav -- Sincerely yours, Mike.