From nobody Sat Feb 7 11:31:43 2026 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 331692E8B66 for ; Wed, 31 Dec 2025 02:55:31 +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=1767149733; cv=none; b=ZWYk6BfrdsX0+AsqELE+zZ4MBh+5SuwXqYHoNIq9xGwQlBrmp4OzqwtHD/8meWbQ//1vTFtNzMNsDwSoem6uEYuxUq9urM7qkamwVINShFAaD9XtAW+DnKdsaucYMH4p2eP++PQPUjNywPzsNEaqJlrfR9jW8W3Ue5bmR5hcwO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767149733; c=relaxed/simple; bh=2MYN99jAWMQpINhvGeEWth578u35RLmt80tvIG1rBvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sWMKMweJY73ht7YUVUTd1aID+sDCC9CD0lqjwsgp3Zkta5a1CuAS+Rk41JOmyBBxhVtAkZfmwsPQlXZHinIG0X3jow0to0U/booxmrktCrdrk+t9ZkGV8ge/iOrpakbLWUCq4UY2j3xzpJpGwhUwIWjBGGEvJdhJpY8y8KeWnKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xw5O2WZq; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xw5O2WZq" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-7aab061e7cbso14133818b3a.1 for ; Tue, 30 Dec 2025 18:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767149730; x=1767754530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WD8xYCq07j/aj+WegcGPJWer+Tc/bnFPxdD4Wp5XP0Y=; b=Xw5O2WZqu+0d8OEAuJi4mL3abvMp2lybFKx4CXtYiBTZtP1EDq2Rnq8qyvcoa+AzDY T54bl6tkq+MWXAQFn92cbGBUTu49Fz94EWk9ROgKTXCRhmfboxXnxcG4onOmzlV1S6Yo ORjlJamX6xTw6YoiqSRCWwccx3p4I8ejzLoyYQqdvAEqlDVPPG4gVeiWNChPm3SMg5oi Xmw+futbmadY39MucZk0QLh4v6gWY5mXXKoInubl8+cI93o6luY41Vh8f2SXB4BIpcP6 bBe/4Pk93hv6wxcY2d7qE3XxN6n0Bc2KblFDNoJJllWbgLSx5kjin/77PyrlS3+PmcaY G5Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767149730; x=1767754530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WD8xYCq07j/aj+WegcGPJWer+Tc/bnFPxdD4Wp5XP0Y=; b=Sv8bpamjPQGUZQ5sh9ksoma1v5T1/PYF/ndiXbX+Wjr9nE62rLM2dQ0so+yXVXVPb6 fdgdJa1H9D6QfYObT8EqphCsdPfuR+4qKBq0NzBeOKpZg6HzZ3AB6Z315ag/xCjL6EwU ABMjrXJT1noz1lxCdvzGMOIptaEpJ2EWKKKH/XDISACq50MbH/sdwaVfiG7ZsqRRGesm wK9bMX89C8RicFfDslwOAQv9+e3Pj2iOe0f/giMd9OzPkeoiJzQMxBfG4nMarCDN4vv4 11ew/WncA8CFgwHy68DEEQidz818+P+JXrZqpKAihKXGIwMJND2QoFE0zh8IA2XnbIl9 Zwvg== X-Forwarded-Encrypted: i=1; AJvYcCVBDu5U2/EsYbIMhj4HI/3vt2PSHoeR4/8srU9hkVGkllpEUzYxiS79f5C5/D7lmp3XtSU5ou006uzzXSw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzji5tcojJZRJgqEpcOgmsHClFEXRC/hvCnpdZXtZM0VLDq4jHP HDflDu7SQiL78YXCUizk3AgpXHzepm6Ia+fgBt+14dTOu10ci5kdwckdEHeKIQ== X-Gm-Gg: AY/fxX6TYscPvCkOcUCeCxJYWWMsCfjLNE0/Ml7uhATyNpisvTp2JoLx56BySD+LxFu pNW/yRcS4H19tCwrag2KtF2Z58g9C0ndutr2d3oAHl4x7wc0wMiYC0rXt76LfyG1RiLV6QrRvQe 5Oq6edVWNTnIDM6hA5BpSl70cZqCfPcFEG83CdX0HUmlYBVP3bVF8/biS+efmZJlwZbYmEacCmx im1ofvZorYwfTSqwoTX+Lkmjol6eOhP0kPvCvqFoe34AMvLeeAPc/G7wbFg1sDq+cpXVIW534Vz YOF4t5ope/Aj439nPX/MPWSIIU8QofDa7mmZsScs6AWCscuUfgfFlrxA53cHxfdmEE0FuzmMinV Ow+ceXhYp+jKH2/Pvgtd33GraoaVwKJW+9cujqyWIJXLxEP7QypC389AiED2sijPJTXpxQmrdM1 f59w== X-Google-Smtp-Source: AGHT+IF3Z5kgxOEyZ8TlUQEufDwaKzpJsoPdOR1wRnbEP5UUX7ilO8guI8waAq1O8VB1kpQTu9fn1Q== X-Received: by 2002:a05:6a00:ab0d:b0:7e8:4433:8fa4 with SMTP id d2e1a72fcca58-7ff6607e208mr29157334b3a.44.1767149730562; Tue, 30 Dec 2025 18:55:30 -0800 (PST) Received: from celestia ([69.9.135.12]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e892926sm33623646b3a.66.2025.12.30.18.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 18:55:30 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards , stable@vger.kernel.org Subject: [PATCH 3/5] ceph: Free page array when ceph_submit_write fails Date: Tue, 30 Dec 2025 18:43:14 -0800 Message-ID: <20251231024316.4643-4-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251231024316.4643-1-CFSworks@gmail.com> References: <20251231024316.4643-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If `locked_pages` is zero, the page array must not be allocated: ceph_process_folio_batch() uses `locked_pages` to decide when to allocate `pages`, and redundant allocations trigger ceph_allocate_page_array()'s BUG_ON(), resulting in a worker oops (and writeback stall) or even a kernel panic. Consequently, the main loop in ceph_writepages_start() assumes that the lifetime of `pages` is confined to a single iteration. The ceph_submit_write() function claims ownership of the page array on success. But failures only redirty/unlock the pages and fail to free the array, making the failure case in ceph_submit_write() fatal. Free the page array in ceph_submit_write()'s error-handling 'if' block so that the caller's invariant (that the array does not outlive the iteration) is maintained unconditionally, allowing failures in ceph_submit_write() to be recoverable as originally intended. Fixes: 1551ec61dc55 ("ceph: introduce ceph_submit_write() method") Cc: stable@vger.kernel.org Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 2b722916fb9b..91cc43950162 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1466,6 +1466,13 @@ int ceph_submit_write(struct address_space *mapping, unlock_page(page); } =20 + if (ceph_wbc->from_pool) { + mempool_free(ceph_wbc->pages, ceph_wb_pagevec_pool); + ceph_wbc->from_pool =3D false; + } else + kfree(ceph_wbc->pages); + ceph_wbc->pages =3D NULL; + ceph_osdc_put_request(req); return -EIO; } --=20 2.51.2