Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp973786ybg; Mon, 27 Jul 2020 04:47:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZjcbzeIw39EAP0+a1bJbPrYjTVf5HXkHL2qKxBHQunh3COMdqTI3bxbJqz8qvooEAKl+4 X-Received: by 2002:a17:906:c8d2:: with SMTP id gc18mr2584007ejb.24.1595850468102; Mon, 27 Jul 2020 04:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595850468; cv=none; d=google.com; s=arc-20160816; b=N+Gekpt1cTajrSpTQQq48WIxRrCmWURHHtYaJhzfhMzXK6dwkjhtYvWQgDflAjRYNt DDtgzS2VEN2WzOSDvkrCcDVvkWpvIdrNwu8Akpcma5s9R2l2SLozTyZrt0cplr14K8QV kJuVYg3vakVtaRW9lNuIgOZRVlt1kaCU4ht3mSgboQBMDuCtCTqcipTZmyQ7bjJxBVfp FTSxq1wSs6Jp0n9qzuEOG1JWQCl2CKjwX/hFpKzU7/OMXAGttNHddRLx5oEm7F4caRag VL4EYKp7K1lCTI83sltl+o37RcMRCLMtgmjTpc5iQiHUL85i+lbLwNZ8s9aGFqXHG2L9 I/tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=tohtirRHrZHfT2VIwepZOelObXoRfxb6YX6rdlVIcTI=; b=vGtIFZIipvWXGUAhfdGEgyZhgBMxqUzE3zvr06zZaC0CTERkEAmuuf9y9oNdEwC4+7 3HigdI++K9zb5JAWWSv97Cix6G9iCUD8yd/F/ff+KZDS3UVpf9DjQzYHSpmCbm741GZu Ll3MgwBchBM9GcGdavvkY0i6TwCeq0IeKCqBlAGhneUME6zJTrTsjFsArONMZgtwu6+S PjzLvO/uglGbU6C8hKp3I2t0oWp6vFVxsItuineEebvvzJMjJLCg3+nehb8TLMfTCNjr pjlTbxKf2msqun5gVTGDodz9rAZBMkcrdRL2sYbHLhz6Aapa7vIH4z6/T1xHml68FAnW 1u+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e20si5448970edv.26.2020.07.27.04.47.25; Mon, 27 Jul 2020 04:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbgG0Lof (ORCPT + 99 others); Mon, 27 Jul 2020 07:44:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:45954 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728051AbgG0Lod (ORCPT ); Mon, 27 Jul 2020 07:44:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 00729B695; Mon, 27 Jul 2020 11:44:40 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 5E6A51E12CF; Mon, 27 Jul 2020 13:44:30 +0200 (CEST) From: Jan Kara To: Ted Tso Cc: , Lukas Czerner , Jan Kara Subject: [PATCH 5/6] ext4: Handle add_system_zone() failure in ext4_setup_system_zone() Date: Mon, 27 Jul 2020 13:44:28 +0200 Message-Id: <20200727114429.1478-6-jack@suse.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200727114429.1478-1-jack@suse.cz> References: <20200727114429.1478-1-jack@suse.cz> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org There's one place that fails to handle error from add_system_zone() call and thus we can fail to protect superblock and group-descriptor blocks properly in case of ENOMEM. Fix it. Reported-by: Lukas Czerner Signed-off-by: Jan Kara --- fs/ext4/block_validity.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c index 9c40214f31f9..2d008c1b58f2 100644 --- a/fs/ext4/block_validity.c +++ b/fs/ext4/block_validity.c @@ -235,10 +235,13 @@ int ext4_setup_system_zone(struct super_block *sb) for (i=0; i < ngroups; i++) { cond_resched(); if (ext4_bg_has_super(sb, i) && - ((i < 5) || ((i % flex_size) == 0))) - add_system_zone(system_blks, + ((i < 5) || ((i % flex_size) == 0))) { + ret = add_system_zone(system_blks, ext4_group_first_block_no(sb, i), ext4_bg_num_gdb(sb, i) + 1, 0); + if (ret) + goto err; + } gdp = ext4_get_group_desc(sb, i, NULL); ret = add_system_zone(system_blks, ext4_block_bitmap(sb, gdp), 1, 0); -- 2.16.4