From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 C029B3A1A23 for ; Tue, 4 Aug 2026 08:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785832952; cv=none; b=KF7xXJtqaZhS49SaHohiyGtWlGS8mG4e8LByzre+11xhaPrFOrU0e+L9RIZ21PAsIg5cLHzxCMIjxySPCBnSq4Y7GKHVIR4QGV9xR8bOxMbcmqNIItovlieDwGf5+dS/a4Q5Ah5jCPWaEQ9z/ZqVLiDlGUi5FaWjcruWsYrPEow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785832952; c=relaxed/simple; bh=+t9We9CHhq5QIISRp6hFIb2HR/+6MY+ToLEhAlYRB8w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u8X8OMLzXqDWnxX4fMFS2VYx9rmxeTH8tage60w6/XfyOKf3komUMtYUuOcpjzItntKw19RHLcOmTb2ku9U4VAr9Im/GEbBS7OJAlM2D0+hIUn1BnF0THOZFCSdYXYpyBsdIs9BapubvSX0te2eiXrcpv3rfX6mfqT4D/jlo49w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=JLFMkr8B; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JLFMkr8B" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-8486ac3f347so754057b3a.1 for ; Tue, 04 Aug 2026 01:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1785832950; x=1786437750; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Msf4BCiiq7h8sHc+GDuq/av89v8kUaD3jKqA6c2u6wo=; b=JLFMkr8BJcz3cfAuglwhBaNDDfVRhFMmg0016XMxPxAjtEekh0j6Zjd596K901Re0J Gx5Agtl5gfiqbMlcAU3umbrt4A0p2DrEcegf1JvZQQkLV/HrMuSeRq+VjA201rD7zBLa QECvhmEc+6XVBu947abshUAjjmdqkv5g8kTCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785832950; x=1786437750; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Msf4BCiiq7h8sHc+GDuq/av89v8kUaD3jKqA6c2u6wo=; b=osfFHPPEbkJMlBQjgO5NqA27c1s9ODvJFAf3ZEyBfBdi5qfmKbNP3VC5+T8XIWBkhR rBhvWBNDSaEGslRltmcnaD14xPdN3seQ9bzKs88aNLcozc/KACzmFFeeP+K2Ur0b7/+7 wgpWhSLp0M4Fs4tylkgXWTj9Bs4dH33ojzC+rRrYFbx8INYzBpJQeFajv/N2oQix6TlL mxUYjvsWIIz+46+lP/e1Cmp1CXN7Fruk9L3wk+DKJR4BpzmJntho1zVC9UXEYCq+eepz R9CCNhDmGXkVUSnPCTGkrwQVnk2SYaZJROtk1EymuzAQgcX5EfY8S/2yogbdLGuQIJxl +v/A== X-Forwarded-Encrypted: i=1; AHgh+RrgF+nT5N9Q0VcRR1uBlAyJ9u0jufChakqbIzX5pxeHUNvHHnxoOCxa+E91M/VbdDH2dbGwCegmPcJnH/U=@vger.kernel.org X-Gm-Message-State: AOJu0YxZLthmnW+oGDFkgBMh50saAJqDeisGngbBYPF0JxPWUyx+EWNc D7d3Um12gI7JJ5rM9vcj0puvpmU83zXBpQ6oHSN9w6s9+6GLZxgVEkmJ8hkbaBPq+w== X-Gm-Gg: AR+sD13RmaQxziAoNdKW0yqWWR6OeUtdKmyOuUFQE5kP5P0WBV/jEVwvEE+NTwHTZBl BUZmtm9dliMdZi3ocnr1aV7U5L8djaHrHeVwJepCZEnydlY7G+fkLtJTGDHfcQ/ojh5r9ASh5B+ N4OulcBoqB5DxK84kY8tHY68u2KkPofRWtqC4gsQRxBOtVCDW39o6wE3qh8Z6c1zuwSPrxCO9wt RXYgcg0pMLeWacExxqIyo+HS1PxSEcDe1Us8WXcNjm9m7h0i+6/q3Zwj5+6muw98HU2n7ecn2wu dkPwVBCJaPNYYXP+xM3CGFryE5CLSL8KNyWa7PDSh1teaoycVkB5NJSMvCQY5ihJcacDfP9AAD2 NPSCWAwcGgRlROZnH5MTmSScaznSKg6AuIr9OhNvUv1HR1ujeQHOqqmvjHaUWBQ4tJTVCBjRsMu EX7uGM8SfNcjwdeTWsyrMGVAkIU1YEpvpSeV9u6PUSCW4nyWFmWwL+LjL5n9k4fJmqwwwewm6lJ SM+PP4q7udHINFsnk8ib7om1fls X-Received: by 2002:a05:6a00:4fd4:b0:847:b45b:fef3 with SMTP id d2e1a72fcca58-84f1cb227b4mr2528791b3a.27.1785832950153; Tue, 04 Aug 2026 01:42:30 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:32eb:b46b:e9eb:65c5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84edbd35a4esm4854159b3a.10.2026.08.04.01.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 01:42:29 -0700 (PDT) Date: Tue, 4 Aug 2026 17:42:26 +0900 From: Sergey Senozhatsky To: Longlong Xia , Andrew Morton Cc: Minchan Kim , Sergey Senozhatsky , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Longlong Xia , stable@vger.kernel.org Subject: Re: [PATCH 2/2] zram: fix out-of-bounds access in read_block_state() Message-ID: References: <20260804065919.3970386-1-xialonglong2025@163.com> <20260804065919.3970386-3-xialonglong2025@163.com> 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: <20260804065919.3970386-3-xialonglong2025@163.com> On (26/08/04 14:59), Longlong Xia wrote: > 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. > > Fixes: c0265342bff4 ("zram: introduce zram memory tracking") > Cc: > Assisted-by: Codex:gpt-5.6-sol > Signed-off-by: Longlong Xia Reviewed-by: Sergey Senozhatsky