From patchwork Mon Oct 24 11:27:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp478240wru; Mon, 24 Oct 2022 07:17:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vvgwL1RoTZZX3jZPnxTNWfYJICc4E+8/PdNaW+k1JaPvkrF0BeBa7uCaGHH+1TETzyter X-Received: by 2002:a05:6402:3548:b0:45d:6506:990a with SMTP id f8-20020a056402354800b0045d6506990amr31136508edd.218.1666621022050; Mon, 24 Oct 2022 07:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621022; cv=none; d=google.com; s=arc-20160816; b=Db+auvQFjyEIvEkzYKcnKi5WgWKB/sZ6baVEmWfmd/4zzjiwqm1Qsgwo334R1TQSkc qDoJ6YBDbSU85yu+XvQActAXrcWQsZiMm/J5vgWFjSkaolnVA9r6L6RximnbuN75IMHE VsewLxOXevke8YPWPWuuEMZ8dLGXTKuCNHqzwA5Djq4pV2I7BpYQmBx3iOVF4SlOx5db nND6O+N7lhlUPip7xh4Pk/j1tvDlKAGWVc1Z74g7L2KtSyNTSw+ACrhid+/P0jh0yGLS jV8HWavvV/M4+m0/VAXsZ6PqhhzzwHluHxsQs7B7iXv/2iORtdXUDEIXOwNU6VI59pLj 1KHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KDN0Q2R4dKq06tkiDRWSjZK+IYROnp4qZtR+qD7XMeg=; b=pkAjYElJIFqpp6D2+JbzhhgBWr/IeiKpZHQbaEcWuuBBhP7uIX+tgoU73XvWhBF+YP Zcn+9TnV5xbH9TpKCg4Wfs0eLHH+KRW8ZOuoYiw8UI0DE4z6N1vYkS2XzgGeBI/84s52 Q6B4hsUnAIz7l6cjqWKciacqRZABW/85krB2KHptxtbvWV7kK1Op2Ipu8i7//uRMC72X rcV87hIM1EVSpwqI7VYaNPGZaM73r3uWKdmVrT8F+nBQ3CRVoa7eIVZI7RKw4jDT+X/9 dOu4+WbQE/Ath7So+40/BsOxHKpqaLYvQfov5kRIitOx2Uy5w0qnXQdFfv7SIp3xBfXK So2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GISi8huX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a056402358a00b00461a98a20cbsi4933957edc.187.2022.10.24.07.16.37; Mon, 24 Oct 2022 07:17:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GISi8huX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232001AbiJXOGj (ORCPT + 99 others); Mon, 24 Oct 2022 10:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235516AbiJXOCu (ORCPT ); Mon, 24 Oct 2022 10:02:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F94480510; Mon, 24 Oct 2022 05:48:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1932E61297; Mon, 24 Oct 2022 12:36:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29DD9C433D6; Mon, 24 Oct 2022 12:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615015; bh=dQ1FrTEtjY+nOpJPZkZ19Nk4MsjhXPguPPae1bpJD18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GISi8huXxz9sQOP1Xcv2h1cUWZhezWqrovBUQOw1kS0wpSTThy1tOQquV9BubcVsy r/zRWuOxfCB5zINE96cM++y2WiE6966NHgOj0goF860UaNri/rF4DbglnHiUhZs4j+ Wndq0xrkW9cEtF41ecyIhsmS8td/qQuHU2eQPijw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Ye Bin , Jan Kara , Theodore Tso Subject: [PATCH 5.15 089/530] jbd2: fix potential buffer head reference count leak Date: Mon, 24 Oct 2022 13:27:13 +0200 Message-Id: <20221024113049.039697524@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747578804740503226?= X-GMAIL-MSGID: =?utf-8?q?1747578804740503226?= From: Ye Bin commit e0d5fc7a6d80ac2406c7dfc6bb625201d0250a8a upstream. As in 'jbd2_fc_wait_bufs' if buffer isn't uptodate, will return -EIO without update 'journal->j_fc_off'. But 'jbd2_fc_release_bufs' will release buffer head from ‘j_fc_off - 1’ if 'bh' is NULL will terminal release which will lead to buffer head buffer head reference count leak. To solve above issue, update 'journal->j_fc_off' before return -EIO. Cc: stable@kernel.org Signed-off-by: Ye Bin Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20220914100812.1414768-2-yebin10@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/journal.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -926,8 +926,14 @@ int jbd2_fc_wait_bufs(journal_t *journal wait_on_buffer(bh); put_bh(bh); journal->j_fc_wbuf[i] = NULL; - if (unlikely(!buffer_uptodate(bh))) + /* + * Update j_fc_off so jbd2_fc_release_bufs can release remain + * buffer head. + */ + if (unlikely(!buffer_uptodate(bh))) { + journal->j_fc_off = i; return -EIO; + } } return 0;