Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1916005pxb; Thu, 16 Sep 2021 20:09:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEgnAb5NyMAy5FhuyCQcsu09eqjh+ZCgUgzcVtrtV/xw3XtSmmv3JaqL27YXe5tKcG6nLz X-Received: by 2002:a17:906:4ccf:: with SMTP id q15mr10012653ejt.9.1631848157361; Thu, 16 Sep 2021 20:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631848157; cv=none; d=google.com; s=arc-20160816; b=ZNFoMvX3LLOO+1uuleKYhZSPPXSfFfYdo1numq9TH8qaa6Y/sYPcsvOCvjxEAjafkI zAG7j2Mgi+G+ashpJqmV3exyNv0PwUr+RtkfEXiH9o8Yizqvx7WbJNHBjpHobTd8y9Py /W3UdronkDdmbQ/mm5R03u6ZqFfPnKIlYTbtU2wjNySHvB3hg41MXMC77jONqxm1CCQK LS8mJBVXKLtUkm/vsQrmfzBceRxVQfIjWgNNd1mw/tN9ZFtoK6tkvx3or+U3wcfL8k1K B2ctitVVTpDXuD3+xdOGFraX+aBTV0SozcLAcdf+Vlqlvv4v+FhDq4Trpu2JxMb6tZ2E kOJA== 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=9zksN5ZoACz2cbGqFMayO4FEeOA3w124s/BKiAYLgTY=; b=IHsJ1rXcjvbzfJ8gZskaSW1uIx+dEtIkLZTjZ19y8j2yPiiWooRu8JbpDzXR8w3hHz V6G+bWQ44bS9M4ZbbYSxtCIP/eRmcZkznBjc9rY5ZHoSBa28G4J07+4XPvz1z7mE1zxO CIiB87Vdtx7W9KJSa9YivxxM4NM9XjffEJOyRlr5qRl//7oYAek9go5UKea1Ks4Bazka Xscvwcx5HCctorFE68ozdaYql6Gx8dONjiqID/xvJBs1VoaVHzECyND0SxoYVThLAcAn JAvMFQ7je7OYunwdta4xxR9IGtdriUnHHa8q+TfBwN1L7sA01FEYSNskUno9ny+W6tO9 C8Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H3mLVPT3; 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 v8si7226600ede.567.2021.09.16.20.08.53; Thu, 16 Sep 2021 20:09:17 -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=H3mLVPT3; 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 S1348003AbhIPR1B (ORCPT + 99 others); Thu, 16 Sep 2021 13:27:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:41429 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346358AbhIPRSJ (ORCPT ); Thu, 16 Sep 2021 13:18:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0DEC961465; Thu, 16 Sep 2021 16:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810471; bh=4ggBm5arhjpp62tQSXrqdcllxGMKJ/pddBBVXOK155I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3mLVPT3X9ViUtN4E3RcsGBbSS4d4imaFhYAiFL1vVQzJ8eNtyZ6KHHf6TxXvc4Gh 9RM9WjCb7n5Lh/LkP8G/i4D2Ol/NUQg9U0gAjdfBKrd8PLQl0Z0JuVlkwowEBoGRoF /PA2y8+ePD61V8Ti7BdW/YA8pXV8GiS5tV9q4ets= 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.14 153/432] f2fs: should put a page beyond EOF when preparing a write Date: Thu, 16 Sep 2021 17:58:22 +0200 Message-Id: <20210916155815.927384213@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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 f2498e4ad89d..a86f004c0c07 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2153,6 +2153,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