From nobody Sun Feb 8 07:25:29 2026 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 98C8628726D for ; Mon, 26 Jan 2026 02:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394469; cv=none; b=bp/KByLn3WtiJ3KNpQmqN0q0FAge/TN5CbPufTfFtAgY28SyElktfAzLnCIrjQshnD7/DlNeZCFWP+B4kNkT8EsvgUzenFEK52Y8Dx0Lu91p+taJIiK87Zv+AyjdRYqtpXQpDC6TK+JBzRjWh+97KU7V0Ga3wVvUiEFro0VRz9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394469; c=relaxed/simple; bh=elLdawZdiNF3T78K+DA6DMPmbUn63JQVKocXOMorMwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KSxX+uhRZ82i80mew0xweaD7dsegc41sxjVwW3oWEtD9yodVLcYxZ4578HwhI+ljPkiZBVZmZ0E+ERkJq0WAXxcS58iYVICBIElBMeau1dAXUi3cOfKYZUgHYXBG7lnoEaMoQrjvlu2qO3hEPjuzxlybwF0W3gbWd/Y/hadOqFk= 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=KSPmH/sM; arc=none smtp.client-ip=74.125.82.45 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="KSPmH/sM" Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-12448c4d404so3978371c88.1 for ; Sun, 25 Jan 2026 18:27:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769394468; x=1769999268; 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=yuyRS9NwFd3elvIRvYUasvxQvQ9+X8/Y2dmyuDNlfJI=; b=KSPmH/sMAr/HOFG43/OysDUyiVMiYdgbkVnXZKOPH8d7a0c13eW8OeQ70FZe7+lnPE X2xVsgTqrz0QWmhQj6gMRK8ipTh2v8zbBEhvDtL3m6b8uQKmR0qEAApsq4CY9UMwEyW6 McNXdbzayMYeR0mVKUS7vQZvv8DENwON3kwbgQjKHrANXFDwLSKg26Ydl/vWvsJA6gbG wYwjbK3ikxsUbDtop2i/EWSpwLCjbk70Wy+lrxEqaTC6wbzTAwZs43fQWgN+xyIDqiuh YXBNhSm7RjQcrsxwArChGWdarK2rTRVb+0aLh49p5/gmqYmnM8KCZZ7ZzHhp/6VuS9Vz L1rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769394468; x=1769999268; 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=yuyRS9NwFd3elvIRvYUasvxQvQ9+X8/Y2dmyuDNlfJI=; b=jp99vEEGS3CB5lUreo9idKDZcGXx2Gl1h1pLN77Tw+tY7Z366sL2SLJZirlgBu96F3 AYDvfYsk5RFHkWUKtv8VBqC7HXbUa1yQcE97hfsUFK2iQpjvGjXgzFNxSb9ejz8hz4Fv yxxHB/eFrLU300AlKFEggTwW4RmZYdIK7BTDPa+LTfAxvnrxywUHBiSRGbQwuOoXAHrD FLiiCQMPCouY6SNkZtfvR551ml+45fBNcehelKS4QvDuIWH9fDF081+rMZSUmnYGxU/v OA4gZzoLauzFgeSnUC4LWxPZR0NfFLXhgGDMtykZ9qLxgxvqa5OQbQVh6u+6odgS+LhV U5Lg== X-Forwarded-Encrypted: i=1; AJvYcCXp3b9K2CAAl6rgeMUfMKRwDpUcTJSmlp8kmdPFwFusw25MozaI3kGc2rtPNO4J8+5Bbz6Yw+gCKVCePCM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/TAKJ/mjY3PNIhTyPrISprRKIdwnWLVzVy7OYARQO/uBqORxa 9ksWlpua3PDgM27o+tmEAPqlakN5L3EDJI437Gzq9sh+mRrXs3tsWB5w X-Gm-Gg: AZuq6aKAJLUnopIQpOKPZwO3h6vsm3zmmEnF5EUq1s60/EsozVcQDypZP/ravJYpqPI zsSBSeUc+9FmLnv4hNjoIgzo2sPpIsoy4Fnl3cBB/LnUYjpKVHIDi9xfAbhMG4A3AtsOkTDFQw4 CxS8IyIVgi+QBJGPkJaSxMN6W/uEHJRs7BEYJEQxY0n66Whx1OjUIBsr11AeTGO/ApEeO6uLKHT atlY3X9LD31A4sAV9g+yN8KYubvtb8kbyqBJaNnQsbbuBkiF44NE0UBnpJJRchsmNuppsckIKmb BLvL5FUpCYk4uIKZ2EFFJEFpjdjeXnn+EMHPJxCX54qffFeDuxvtVipn+NMrFetQwAUN4J7X3O9 Z+bdf+e2OcvTkknxoCAePY9MCwRFhM1Qx8HDDk2aj116VzQuu3umtikes8fuzmyid6zsUH1T4/Y al4Wa/XZbIOupaqVnuTUhuNvaJXIx8JmLWbGnsbgMgzyg7amPY1aDa X-Received: by 2002:a05:7022:497:b0:11d:f44c:ad97 with SMTP id a92af1059eb24-1248ec6916cmr1706255c88.24.1769394467722; Sun, 25 Jan 2026 18:27:47 -0800 (PST) Received: from luna.turtle.lan (static-23-234-93-211.cust.tzulo.com. [23.234.93.211]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1247d90cda6sm15266037c88.1.2026.01.25.18.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 18:27:47 -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 1/2] ceph: free page array when ceph_submit_write() fails Date: Sun, 25 Jan 2026 18:27:14 -0800 Message-ID: <20260126022715.404984-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126022715.404984-1-CFSworks@gmail.com> References: <20260126022715.404984-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 (it is later freed when the write concludes). 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 (and reset locked_pages) in ceph_submit_write()'s error-handling 'if' block so that the caller's invariant (that the array does not remain in ceph_wbc) is maintained unconditionally, making failures in ceph_submit_write() 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 63b75d214210..c3e0b5b429ea 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1470,6 +1470,14 @@ 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_wbc->locked_pages =3D 0; + ceph_osdc_put_request(req); return -EIO; } --=20 2.52.0