Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1784232pxb; Thu, 16 Sep 2021 15:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf2Zno9OATYd1H7UKp1I2ziVViThfLbTary/QUhSNteiTCN1Wzm0BsWmlJ7EOvt4f/275n X-Received: by 2002:a17:906:3fc1:: with SMTP id k1mr9087314ejj.44.1631832586446; Thu, 16 Sep 2021 15:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631832586; cv=none; d=google.com; s=arc-20160816; b=IeIzaHPHd0VYMucxpbsxqJEYjVFHO8+IJV6yZLwNeekIDCFkjG673a0021Q7BxpL6b Li07p6/kRdN0RBb1h1YN+QIYdYtjfKHZ/BQTnOSbg6PrXhDVnX2FBG9mV/n2I6hGf3CZ 5WWJqXsvqMJBFUwtBxqSupTuinwm154X6KtKXqLGIA2H9mhb20z62zJTLcWI9BgOPG7u J8W+ccOUoKCagH8839cORgs2bu2waZfPTSGgwy+xFG2obE7gjsLjO525SuichkOePXnu XBPvTBvkK3e/NQWdspdzkkAioH4Gmz/lAKG8wxCjuIGqdxrrf7CKnOI/OXFo9Lnr+Soj adNA== 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=K/w9JbVxlV6ZRh0q1vvIZRQNcKOQ2UT9XZm7T89mgpM=; b=W8liS2jOQp4+v1AsHDH9McRn+omxkUBbAaiFxtN7KCgoxrZQqNTTkB6FCKhAiywuTD gCLt+/sxg3kIZGnrVoIf9UlvT8y+eFHI+QtaBQSV8tX2xvmxsm7eAu5NpS2BccCPwlKR VbngOdpro45PAaPjlJLAGMXIRRws0C5Ne0MsgvJWKYBnsZiToFGKhkPUX2bBSYnK4+FI j1N+8MpAOqCS4giyXlbKLr++7k5YWIbynxTG2uvhl9Ljq1YVUpiHfmpZF8TJCB+9Sczm uwBkMbGCKS0znV6zProHdNo4rN+1s4qnlYiZt4Tv9hRs0kvfmhiCKs9vLXJ+NGQKIZ8d kfSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mWfO7QxK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp5si6143098ejc.447.2021.09.16.15.49.22; Thu, 16 Sep 2021 15:49:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mWfO7QxK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1344218AbhIPQow (ORCPT + 99 others); Thu, 16 Sep 2021 12:44:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:51468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244564AbhIPQjT (ORCPT ); Thu, 16 Sep 2021 12:39:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1AFB6140D; Thu, 16 Sep 2021 16:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809388; bh=SrWbsL2c+wTgUKVBk/2/fr0BKD/MEpUT2ZCFzwO+5tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mWfO7QxKUvU4RDoLuzHn18tdKzHlfT6tFZklAr8qj4NcpKfUhbwZjhqJz9AnL6NGO s3UHMuHP0lf9tyS5Ic1J4YTqVt+qldxchAdTAq+Lvo0JElQe7+ujo4DYraCzzrNGEa +oezw4oTeK8aINCd6jbs7kzhnl2OztH2r2DUsJNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.13 135/380] f2fs: should put a page beyond EOF when preparing a write Date: Thu, 16 Sep 2021 17:58:12 +0200 Message-Id: <20210916155808.633622396@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jaegeuk Kim [ Upstream commit 9605f75cf36e0bcc0f4ada07b5be712d30107607 ] The prepare_compress_overwrite() gets/locks a page to prepare a read, and calls f2fs_read_multi_pages() which checks EOF first. If there's any page beyond EOF, we unlock the page and set cc->rpages[i] = NULL, which we can't put the page anymore. This makes page leak, so let's fix by putting that page. Fixes: a949dc5f2c5c ("f2fs: compress: fix race condition of overwrite vs truncate") Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/data.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 3cd509b085f2..198e5ad7c98b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2151,6 +2151,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, continue; } unlock_page(page); + if (for_write) + put_page(page); cc->rpages[i] = NULL; cc->nr_rpages--; } -- 2.30.2