From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A1733CF032 for ; Thu, 11 Jun 2026 10:30:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781173809; cv=none; b=YMwab+TSyg7uNHqMgP2MNhdqSSkjPY6pV1eODlAT6/CvXsXDQFjS3yl2yr4HTViE3mRmFi4/+QGJB0qkzR7Co/EoeGqJJq/qsyC7FTnfQvphEzK1+OXyhEF2IIsZxMoc9GI2X7tWQaWUoTTxM4m6WvI4fFZsfMTD8dY6A0CSWyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781173809; c=relaxed/simple; bh=hNcass1OLdJeaOXtGbmhbupe53X3mEETCYDfb3cQBtM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=l0KjIQVKq+1iRkkawk6Z6EQPW5j4eBlnJSvDiQHptvHYU7y2TSqSHjl6KZLbqmslmYvFxV1yN9O9Ia55Llgj1NuRrxCdEb92LrYdy9yHtvKRokireUwnZcYI27XWKKgEe7HggARXMNC+PCtm6lFZyWvkj96fvwdnnFi7V3s/eWY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tarunsahu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oqqubzNK; arc=none smtp.client-ip=209.85.218.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tarunsahu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oqqubzNK" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-beb1f622263so807018166b.0 for ; Thu, 11 Jun 2026 03:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781173806; x=1781778606; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=8qeOP9gDnHU3nT685H+Q/iHqCKFCSLfAQAt+As3buPc=; b=oqqubzNKp+ixmUU6JnshnFpEdaX89Iu6PO1IGsWj/rY1nRSFTlKzoFT0PMAbpYgq8j FMI5XqK7j8mHlHQyXyF0dgOIy1NSMsfT2P/OUEDhPGuopSy7LI6rrWjn8iIJFPa45r10 vUc4UY6K9v8X9FGjzoRHefk3AiwKW1qsoNENJBrjbvmt6X8+2JTu33Drx7fs2c1BbwdS BK95uJSXCw/MTYg6a0ahvUWQmQWm0jHeuHRVe2kOmxzFIASOYCzLNdNkbrB+S7S1pbQd mGnMKoEQpzsVRp6isZtRQcpyEBCVaZQRKOWR5AyPYFMpFAe9AM8+2phG4QXQlqMqrwdZ U1hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781173806; x=1781778606; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8qeOP9gDnHU3nT685H+Q/iHqCKFCSLfAQAt+As3buPc=; b=O6b61C7CxkSFyO+ZYWZqgCJlHyvwL98qBfBLs+KKwCtdTtKDeNGpWR7ISqyI4oufkZ sMc5zxfO1laNqkD/trJmu0beqz7kE2iyskeNXqQJAE5bA5C7C3QNnl5kI4j7I2SOgVnF Dp5NX4RYvaX9AP0skqHFuYjlpKKCy+5epEnAhNYppibOkCxjc+h/eep/tGkof5opXHxb J08kTHA9bER/Cj/qEK4nWZNShYbs/uQCoqAekewRBThTL2nRcl1WfeYoC9eJlDfY/TrT kMVyuAWLKVTz/BFSbSJTwcOOpr44unbHu5IsKmgPRwPlrOf4rbL3OgDA/vpOEZDFo5dh KjWw== X-Gm-Message-State: AOJu0YxtgXWhwckA9yHmssrEARwvXYNoyDkyJVtXkRl23IFVEuKOa1ZY d4NQlSfiBQEloKr0XpjPKfiLFvua1CRuR6NywyZpHZmTR+Nca8Ziiqc/qwXKGr7PNhiAlX7/mQp CuYwUQu/Mo0IeBGUebA== X-Received: from ejdbe10.prod.google.com ([2002:a17:906:f40a:b0:bec:3aa5:9928]) (user=tarunsahu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:2e0d:b0:be2:cf3b:acb0 with SMTP id a640c23a62f3a-bfc8595c7fbmr65138666b.12.1781173805724; Thu, 11 Jun 2026 03:30:05 -0700 (PDT) Date: Thu, 11 Jun 2026 10:30:03 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1099.g489fc7bff1-goog Message-ID: Subject: [PATCH] mm/memfd_luo: validate serialized_data before conversion From: Tarun Sahu To: Pasha Tatashin , Mike Rapoport , Pratyush Yadav , Andrew Morton Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, Tarun Sahu Content-Type: text/plain; charset="UTF-8" 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) 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