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 7CC004A8A3E for ; Thu, 3 Sep 2026 13:06:19 +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=1788440793; cv=none; b=lJShu/EqoCfpeyKmh7hLLJbRnRInsey7ir8DEHBjTFJIti5PpHtLxPQ1PCy4/H+kGibTowCdcbConPnlKoQpq6yfVyTGsS4hjo+HIbb3mCY+E4rGyawryHslirCa49PmAuy98XmJtpj7O+M1RLEqch1ZJ5QuLDwlJ3mrZYq8z6w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788440793; c=relaxed/simple; bh=Yp7NHdS1aG/rrgNBal2ZlRp8J20TBefcG9qugThO17I=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=ahGCa8RUv7Uo3nb8Ef5EdfcAxyfk4n2oVsodq+CczqmIX8H4FVkDbhi8g9p9qSFUnFAREfDbomBzCapxOryNWv89lTyoynwJZ9U/ar91LRd7aqTyvtGL+Dj94fPBHmcsFaWMMMB0jve6ciWwnj7CuKSy0xLhoyTwfOoeXJXJmhM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YQ5Q5TwK; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="YQ5Q5TwK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E41901F000E9; Thu, 3 Sep 2026 13:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788440779; bh=6zE5FESGMP7KLUmSvlSIf8rVJZQzaigBvl/q/16j4bk=; h=Subject:To:Cc:From:Date; b=YQ5Q5TwKEcMRPswJsmjnPUJcT4ms59thuQm2nh9XmUw8I2wnKwcc3LIUBXlei9tv0 BOsf4JKKB2drl5tZVFafaSRTdz7sTF4UKIDnxFQURIn2arHxaLfG86rrMtYaxI7d+k imZ9IOv+mXwfUgUUV07dZlwbMyClV9O2hNvVGIwM= Subject: FAILED: patch "[PATCH] zram: fix out-of-bounds access in read_block_state()" failed to apply to 6.1-stable tree To: xialonglong@kylinos.cn,akpm@linux-foundation.org,axboe@kernel.dk,minchan@kernel.org,senozhatsky@chromium.org,stable@vger.kernel.org Cc: From: Date: Thu, 03 Sep 2026 15:00:53 +0200 Message-ID: <2026090353-upstart-iron-3320@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 391f057f44a51cc9418da5cba78b014324174264 # git commit -s git send-email --to '' --in-reply-to '2026090353-upstart-iron-3320@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 391f057f44a51cc9418da5cba78b014324174264 Mon Sep 17 00:00:00 2001 From: Longlong Xia Date: Tue, 4 Aug 2026 14:59:19 +0800 Subject: [PATCH] zram: fix out-of-bounds access in read_block_state() read_block_state() calculates nr_pages before taking dev_lock. If the device is reset and reinitialized with a smaller disksize before lock acquisition, nr_pages still describes the old table. The subsequent loop can then call slot_lock() past the end of the newly allocated table. Read disksize after acquiring dev_lock and checking that the device is initialized. The read lock then keeps the table and its bound stable for the duration of the scan. Link: https://lore.kernel.org/20260804065919.3970386-3-xialonglong2025@163.com Fixes: c0265342bff4 ("zram: introduce zram memory tracking") Assisted-by: Codex:gpt-5.6-sol Signed-off-by: Longlong Xia Reviewed-by: Sergey Senozhatsky Cc: Jens Axboe Cc: Minchan Kim Cc: Signed-off-by: Andrew Morton diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 2be5c20e3f14..82b78e6e55b2 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1543,7 +1543,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf, char *kbuf; ssize_t index, written = 0; struct zram *zram = file->private_data; - unsigned long nr_pages = zram->disksize >> PAGE_SHIFT; + unsigned long nr_pages; kbuf = kvmalloc(count, GFP_KERNEL); if (!kbuf) @@ -1555,6 +1555,8 @@ static ssize_t read_block_state(struct file *file, char __user *buf, return -EINVAL; } + nr_pages = zram->disksize >> PAGE_SHIFT; + for (index = *ppos; index < nr_pages; index++) { int copied;