Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp465896pxj; Tue, 18 May 2021 07:21:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLlffM9KzZYcxEM9EM4cQ8tIkwzq4IqDmQhTDqnMLaXeuQJ+qHrgj4O7u6KP1Y/NKvJWzV X-Received: by 2002:a05:6402:34c5:: with SMTP id w5mr7425975edc.237.1621347682854; Tue, 18 May 2021 07:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621347682; cv=none; d=google.com; s=arc-20160816; b=bvf/B4cFhx4xOtTA+ScU+r+bvfJRG3tq8WYTsO6PW7p0yKfsoSwKfyoT7H8UqPePtJ VUAm3/0WtRg6eivwuqxoaDGHziBj06L8ZP8AoVmcAiXr2mlwer7BHATeDPkCv0cF9L2M qgLshq8SEEyEWoyVRVdGo3kCJWsTGoA1V9rkh8Wh0NryASKzluBH3L2UnAQ+zfgcN/3S jO8wsX4Sm9T/GQGZP2vt3ysIM0EPWLQB805qZkP/+bPzim6s6j2QMCqWHHhDF998+GE5 LqotxptoBVjHx9xH4I1NnEs39CQ1Vmp8IVJUIHDuQ/nBm02vk3sWwkMASx2ah/dnhc7a Ra4A== 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=RwHN6qvgZ9uhLcMNrVEjawfWYD9+R/AKJo1+CqXArlI=; b=zevw4ssc194lXjaaE/1fKRlI6ULXTuzSiUL48W+L74ZJKmN9T9vzjiLpcX7z+/TxEB CaHMgJ3VzYgwCACcJW7d1a0gdjKzSr91iV7UQOPqEHY0uT5BJoZBx5VQByrs2nVQPv6c zWQDa6tiWELJvl8v+qgmDWu0h/jlx+YOleecXq1DWG9z0piDfPG4GrSLKxl9CcGwCSN8 /DcAM0Jc2nNj75jHp1UHXiX9+lgpvakQLijXJFdXRLIvj3KYKSVahx+YWPUU4+txmxDC YsK2V5KDzKuXhyO50bbIhfvlo66Ah2AWOycipsa8XjmFNMqLu2+16XjnumLLFH/v/vOg 9+rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="g7/mWIcO"; 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 s14si11516280ejx.539.2021.05.18.07.20.59; Tue, 18 May 2021 07:21:22 -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="g7/mWIcO"; 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 S1344521AbhEQPo6 (ORCPT + 99 others); Mon, 17 May 2021 11:44:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:55422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244822AbhEQP2k (ORCPT ); Mon, 17 May 2021 11:28:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A0A861931; Mon, 17 May 2021 14:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262238; bh=7GQ9d/NA/jG23TAEWUeUrr5usm8s4sDa+11gvcze7JA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7/mWIcO2Im1Ss0baQ/xf0ohUfpSrC/FlmJ+uHg/c5rOhpdHYZYu/KlQUvsPL/Ex+ Ux58VtnM1CJVpheMJ7EG5hfyTxmJqX01UCz9i0Gq1lDiPSiWMgLA78bXqgnOrJnaSQ ySUj2pnyXmbdOOhNPfcsLb4KdWE7dFL6H91iU6sc= 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.10 114/289] f2fs: fix to avoid accessing invalid fio in f2fs_allocate_data_block() Date: Mon, 17 May 2021 16:00:39 +0200 Message-Id: <20210517140309.010449104@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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: Chao Yu [ Upstream commit 25ae837e61dee712b4b1df36602ebfe724b2a0b6 ] Callers may pass fio parameter with NULL value to f2fs_allocate_data_block(), so we should make sure accessing fio's field after fio's validation check. Fixes: f608c38c59c6 ("f2fs: clean up parameter of f2fs_allocate_data_block()") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 1c264fd5a0dd..d04b449978aa 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3407,12 +3407,12 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, f2fs_inode_chksum_set(sbi, page); } - if (F2FS_IO_ALIGNED(sbi)) - fio->retry = false; - if (fio) { struct f2fs_bio_info *io; + if (F2FS_IO_ALIGNED(sbi)) + fio->retry = false; + INIT_LIST_HEAD(&fio->list); fio->in_list = true; io = sbi->write_io[fio->type] + fio->temp; -- 2.30.2