From patchwork Tue Oct 30 21:58:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 991130 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42l52m5p37z9sC2 for ; Wed, 31 Oct 2018 08:58:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbeJaGyI (ORCPT ); Wed, 31 Oct 2018 02:54:08 -0400 Received: from relay.sw.ru ([185.231.240.75]:46020 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725743AbeJaGyH (ORCPT ); Wed, 31 Oct 2018 02:54:07 -0400 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gHc2H-0003hQ-Vl; Wed, 31 Oct 2018 00:58:54 +0300 From: Vasily Averin Subject: [PATCH v2 11/11] ext4: access to uninitialized bh fields in ext4_xattr_set_handle() To: linux-ext4@vger.kernel.org, Theodore Ts'o Cc: Andreas Dilger , linux-kernel@vger.kernel.org References: Message-ID: Date: Wed, 31 Oct 2018 00:58:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On-stack initialization does not guarantee zeroying of unintialized fields. So is.iloc.bh and bs.bh can be contain garbage of old stack conent. Errors in the beginning of ext4_xattr_set_handle() function lead to jump to "cleanup:" label where brelse(is.iloc.bh) and brelse(bs.bh) can access uninitialized bh fields of on-stack located "is" and "bs" structures. Issue was inherited from ext3 and was present in first ext4 commit. Fixes ac27a0ec112a ("ext4: initial copy of files from ext3") # 2.6.19 Signed-off-by: Vasily Averin --- fs/ext4/xattr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index dc1aeab06dba..aae12425597e 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2303,9 +2303,11 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, }; struct ext4_xattr_ibody_find is = { .s = { .not_found = -ENODATA, }, + .iloc = { .bh = NULL, }, }; struct ext4_xattr_block_find bs = { .s = { .not_found = -ENODATA, }, + .bh = NULL, }; int no_expand; int error;