Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp144799imu; Wed, 7 Nov 2018 22:47:39 -0800 (PST) X-Google-Smtp-Source: AJdET5eM4XBdXAMbmAqqraY0sDmgKPedkhBHLEhv7+5rvbkrn/4clZZ4UWksyCdOLVpqIkPIS3Yp X-Received: by 2002:a63:164d:: with SMTP id 13-v6mr2856316pgw.103.1541659659191; Wed, 07 Nov 2018 22:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541659659; cv=none; d=google.com; s=arc-20160816; b=aOgH/dVVxaVYRb2i9pMJG9keBzkfWW+5vUs22UEGYRd8yeVyWEwElhNe91l4k/0GCk HDX+J42VR+w3vtYrV2lcDL6RZuw8Q9Yxk3JRJPYshONqAAjB0by9TP59EjM1tVT5Cz3Y sfeAd31tWh68i5y5rR1Fvado7vt9l1uJz4KO+XTtcWeoUsOvAZdoye0Nf6DeEP6i0cx/ VQmPDai9Yg19vXn5KVFXoWS5FJBxoX1t8uwoVbP/KnDN6H7UqTscNXnjwEDYyNFm3RRm 8nv84LgcOTnGgp9PZ9DmUbaGgGMy2l1TpdXSkS5gmJm53oUgRxrqnBeySomXEKD+xObU Xl2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=Ccu8npj7TvECiKvEoSmyPy+iUFAQ2eh73YiifgT9yVQ=; b=CA2/sDAnmEi73+V6EBBa90KtnC6ffedI4QjcfdkjZvtUnX2b4OIbbKeLtViB3Kmldc w3GgSjK6l61uUz1HK13JvyOwM2FJqiqDMHIZi6iOpGiV4hCDBfQCXFpYRPyWRjgEk75P n9TLZBTDTAqufAdcc5TDOlJ/6v/iYjzkM/3ZQnrR9Cv1sU0w/L5wt0Hi91m+2osDlEs6 DaZr06qrzfJ5FfXby5SvHPu2YHh8/ghF8WV3rCGtMZwFEqI3SdJL2K07E7V1VAhRoRa9 TJGD11LBs5QvGPgEliqlQTEkZAT2bauv1avopoIqTRRibI/v4LDJl2Xo4mW7QR2j6fnb FgfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si2897346pgl.528.2018.11.07.22.47.23; Wed, 07 Nov 2018 22:47:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbeKHQUf (ORCPT + 99 others); Thu, 8 Nov 2018 11:20:35 -0500 Received: from relay.sw.ru ([185.231.240.75]:60708 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbeKHQUf (ORCPT ); Thu, 8 Nov 2018 11:20:35 -0500 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gKe5H-0005Zg-IF; Thu, 08 Nov 2018 09:46:32 +0300 From: Vasily Averin Subject: [PATCH v2] ext4: missing !bh check in ext4_xattr_inode_write() To: linux-ext4@vger.kernel.org, Theodore Ts'o , Andreas Dilger Cc: linux-kernel@vger.kernel.org References: <20181107163346.GH9919@thunk.org> Message-ID: Date: Thu, 8 Nov 2018 09:46:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181107163346.GH9919@thunk.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to Ted Ts'o ext4_getblk() called in ext4_xattr_inode_write() should not return bh = NULL The only time that bh could be NULL, then, would be in the case of something really going wrong; a programming error elsewhere (perhaps a wild pointer dereference) or I/O error causing on-disk file system corruption (although that would be highly unlikely given that we had *just* allocated the blocks and so the metadata blocks in question probably would still be in the cache). Fixes e50e5129f384 ("ext4: xattr-in-inode support") Cc: stable@kernel.org # 4.13 Signed-off-by: Vasily Averin --- fs/ext4/xattr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 0b9688683526..415f73d4c9e6 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1384,6 +1384,12 @@ static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode, bh = ext4_getblk(handle, ea_inode, block, 0); if (IS_ERR(bh)) return PTR_ERR(bh); + if (!bh) { + WARN_ON_ONCE(1); + __ext4_error_inode(ea_inode, __func__, __LINE__, 0, + "ext4_getblk() return bh = NULL"); + return -EFSCORRUPTED; + } ret = ext4_journal_get_write_access(handle, bh); if (ret) goto out; -- 2.17.1