From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 8B8144A35 for ; Wed, 5 Aug 2026 01:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785893300; cv=none; b=A1IYW/BY0HJnhi7ZmtZT33hn+CFSkm/3nvrijbzX6D38cUqYRHUWjIgyU2mrsnlqmOU09m2CBnuMxd/o4BmhebIK8NBVI4GruFFDXP0YxaOEOlg53dQ0dBIFd55OxKylycPXJTY577Vnc1mzQe5VxACH23ZWFHoxhftF6Fvmzpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785893300; c=relaxed/simple; bh=LP/CPsWWk7JdhdkRUgVX64RFY6Mb6ULuSPlD2yzQEHk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VWGXyp9TTdLPmN06zirWhfOFfqGRJ//oODvBaU8f/1HUiXDESRiOV47CQOUyXfnmKBvmc3SZxUhjzuaCBpzpPCnoo5U51TV8b5g5abQBcJm1Gf/G/3+FoN37kgFaYVrdC6maM8WCIjK/6Q0wFPMI22J7g7hB46GkN8F7ydFAo/Q= 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=hvADBIN7; arc=none smtp.client-ip=209.85.214.180 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="hvADBIN7" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2cf50c6f235so5869325ad.0 for ; Tue, 04 Aug 2026 18:28:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1785893299; x=1786498099; 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=hDRA8RaOryE0v7n4VH+L8tqsdWogJTvOgNRaAuqsLwI=; b=hvADBIN7rloNVJUcjZwSAi9T70JUdSa0z/QU4PX57XNrGiSXe/61ezs7CjBU5JwkcO KIpJUfnjj7UaaYLaJAf7f2zqFLKhLAwmMXknBvLrVtybaF6d4WEoL1Y4AvyQhnMCQxdB uQ4DbY182uXwI+CJAzKyJ1javMr2Es1Aeo2AM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785893299; x=1786498099; 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=hDRA8RaOryE0v7n4VH+L8tqsdWogJTvOgNRaAuqsLwI=; b=kmTIAjJ+nHZiqD1ixtgXTZ0ToDiY9qwClFK/6kMv+jlJ9XYgksCzL92vfyCBcOt566 wDsR6riQcRuV2i6kt/HrsnIMJUMgMq0XU6Rj69bStjeuYPrishh5LoCYt3s8elGDbO8m e27xgF3KB/gb1Rg00JY3X2y+btY3l0osGTourdC8+fWGknPEYpm3xR/Vq50bbrmi5GUZ ODZiNwwpYvAu+nr0gqdGUmoe46WbGq71OrYfH1RxbhayPuOVEgB3rRiISzKLwtddPISu YPJ8MmfgSek8kFGfi87vQwWyiXJPK1FZSVH2KUTJyK1R/pI5wJbXsGUWm+kk758P3DSA ibKg== X-Forwarded-Encrypted: i=1; AHgh+Rrj/xqfo7MG/DhiQRR4pmSbPYyfZO8jRkE5j1DKVUf4jDDfhG6A+9ZQs8OdB75n5059cNK00QkxWzAa940=@vger.kernel.org X-Gm-Message-State: AOJu0YyvMIE4q1GtzKXX3zn4NeEJSomAP8YIFQ+WjXbqKDvlCBLGvJLc 6AbquL2sY5xUsJk9WKqTt+wkejlpXSz8wsO/GGDGw3efusAM61bjUUR1Izt0ETgCUA== X-Gm-Gg: AR+sD11QUBJrzWKB+fh/242rDUUsfGwTR6Iud2ew5DBiccyjS3J53MD9XD9Ij5Mu0gg U/GqyczC+X266PFsomG17z9Xd2tPtAaxaCfFeArk73vVeM1pXgiYWxzT5WP3e0azsF4NZaiMliD jVIt1U3MWpwJlrglS5yvi9VhtGZXgFpdzsJeiFMwYWZ6abFV+oMmRdjhCX5n1Iv35rMFNAYwdLW wwcq1V5MnqVYVvnRNvKw6pkJs6C9S78HCeAO/4lpf/Q/j3/HFvr3lAxHF4NhGZTSQCvB4tQgpx8 Iu6yY5WmnjJK9tjhsTcH/IqCqzs9BbUzMSYm8/lciYPl3S5efz72FUJCvy/0SVRQlTawybOkDsk DSZreDhD0rlVLK7sttrrPyQKgqy0vmFpz6/j17D6kpmg+aKJJ4zNs1PS18NDjWJypeiMygfxJls Q1+zqIRwW3Ku/6WSWOi9fWJy8mszig3JCXx1ANrhzBQ3ORjEOs1D8hw5+x5X7O4fvva7uN57xHy sgE2JQiWF4OlDovbCflNFtD4gCO8xlsPTuZ6AA= X-Received: by 2002:a17:90b:5447:b0:380:83fc:4315 with SMTP id 98e67ed59e1d1-3903c66b3bfmr3047061a91.21.1785893298950; Tue, 04 Aug 2026 18:28:18 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:32eb:b46b:e9eb:65c5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3903d183dadsm554776a91.0.2026.08.04.18.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 18:28:18 -0700 (PDT) Date: Wed, 5 Aug 2026 10:28:14 +0900 From: Sergey Senozhatsky To: Longlong Xia , Andrew Morton Cc: minchan@kernel.org, senozhatsky@chromium.org, axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Longlong Xia Subject: Re: [PATCH 1/1] zram: reject disksizes that exceed slot index range Message-ID: References: <20260804143832.146129-1-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: <20260804143832.146129-1-xialonglong2025@163.com> On (26/08/04 22:38), Longlong Xia wrote: > zram uses u32 slot indexes, while disksize_store() accepts a u64 > size. On 32-bit systems, a disksize larger than U32_MAX pages is > truncated when zram_meta_alloc() assigns the page count to size_t. > array_size() then sees only the truncated count, so a small table can > be allocated while the original capacity is published. Valid I/O > within that capacity can subsequently access beyond zram->table. > > The same oversized capacity also lets full-device scanners compare a > u32 index with an upper bound larger than U32_MAX, so the index can > wrap instead of terminating. > > Reject disksizes larger than U32_MAX pages before aligning and > allocating the table. This keeps the table size, published capacity and > slot index range consistent. > > Fixes: 33863c21e69e ("Staging: zram: Replace ioctls with sysfs interface") > Cc: > Assisted-by: Codex:gpt-5.6-sol > Signed-off-by: Longlong Xia Reviewed-by: Sergey Senozhatsky