Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3263294pxf; Mon, 5 Apr 2021 07:34:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycKdMZlKiqLq0gwTtFdNdkuCe/l4n4gNIGKS1APhCfOW8Tzdu9Yh5FM3aBCGnIZFgCh/CT X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr32178915edu.364.1617633240707; Mon, 05 Apr 2021 07:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617633240; cv=none; d=google.com; s=arc-20160816; b=Y+5Y3VDZ05D4fVX8MfmkUUkQbCXu8LEhA6Dku3EiJa+WFy8QT1XyoGMBvFovCUP5rn XV7jgqiOxMMrzKfVvwsYJ1tk9ftR3cO9nOVVObRUN7tj/n2Tm/5wF6WKZmad8uei3lsQ XQai3geULSatTbB7VvNSppbSzUrRQU1mjd+hFio7cgeCu/Rxa8iHCKcIleEMUAT5mf84 t5rmAX4ihL/htPC8WivGwbtr4tT5XswyQ4TzM5IOYV4tyuCBCbGCGiaejD+/PPuHAcXD IbwpSFtN1VJjftMXO5/AbzJLt1ePglm26rDGFiPmqav2y1ymV5or0bTO1A116fUFnMrT 3Gqg== 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=Arjh7V9gXKIJoPGFrloHX8sRZLKyLn2e9yed3vlju5Q=; b=LIDjPNOPhwX2gntJ/aIkMRfmTD/3hPyWbhrAeiJ0+INAJmXBnp76Tk2JwLdWGsW3zj FvdleSP4S6mVz4HCASAv5kJTDeM1rutnY+9i1iGXEjSSs2/Wj4K3TjtrIEr3yYb9cPNv WdRFEPJ868AAOgLC7EY6TXFL7qjOejxZJq8AnMlMDbL1ZV5O3I4IPOzvBCvLxbbZbUBi K6QFGyLptN+cdH+XqBIPZY3QVdPZQ0misy00lM6CftQcoNuMd3NzGya9fgZqi2/2hIF3 B+SQwMuiqdELYrH3I00Sfnp60Hhe9CD9wPqECB1EHiuRCL72fL/eOseg9UgSGEneoxFM 0PKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WkGKNxFQ; 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 b99si8314485edf.68.2021.04.05.07.33.37; Mon, 05 Apr 2021 07:34:00 -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=WkGKNxFQ; 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 S237727AbhDEJDo (ORCPT + 99 others); Mon, 5 Apr 2021 05:03:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:43804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237332AbhDEJCC (ORCPT ); Mon, 5 Apr 2021 05:02:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 443A9613B9; Mon, 5 Apr 2021 09:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617613286; bh=uW6oDUm5OGgrAlcJAqE/N3uUNnNkdl5IGSMnsyGW+o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WkGKNxFQAJwAoE+kSmFkkUC0PA1X4qmYa8RaMDdFI49RH0wELX4pkA7EHDob1hwK/ guFzED5tSRs9aYnwG+bObgcGiOb38l2UWIbwMtNu5QJTDX3N5zv/Olcqeblnuagd9e sa8c0mQNnaxxLtCqwY6WiIbq3iSBsrYS9v0luwlw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Jeff Mahoney , Jan Kara , Linus Torvalds , syzbot Subject: [PATCH 4.19 38/56] reiserfs: update reiserfs_xattrs_initialized() condition Date: Mon, 5 Apr 2021 10:54:09 +0200 Message-Id: <20210405085023.748250633@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085022.562176619@linuxfoundation.org> References: <20210405085022.562176619@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: Tetsuo Handa commit 5e46d1b78a03d52306f21f77a4e4a144b6d31486 upstream. syzbot is reporting NULL pointer dereference at reiserfs_security_init() [1], for commit ab17c4f02156c4f7 ("reiserfs: fixup xattr_root caching") is assuming that REISERFS_SB(s)->xattr_root != NULL in reiserfs_xattr_jcreate_nblocks() despite that commit made REISERFS_SB(sb)->priv_root != NULL && REISERFS_SB(s)->xattr_root == NULL case possible. I guess that commit 6cb4aff0a77cc0e6 ("reiserfs: fix oops while creating privroot with selinux enabled") wanted to check xattr_root != NULL before reiserfs_xattr_jcreate_nblocks(), for the changelog is talking about the xattr root. The issue is that while creating the privroot during mount reiserfs_security_init calls reiserfs_xattr_jcreate_nblocks which dereferences the xattr root. The xattr root doesn't exist, so we get an oops. Therefore, update reiserfs_xattrs_initialized() to check both the privroot and the xattr root. Link: https://syzkaller.appspot.com/bug?id=8abaedbdeb32c861dc5340544284167dd0e46cde # [1] Reported-and-tested-by: syzbot Signed-off-by: Tetsuo Handa Fixes: 6cb4aff0a77c ("reiserfs: fix oops while creating privroot with selinux enabled") Acked-by: Jeff Mahoney Acked-by: Jan Kara Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/reiserfs/xattr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/reiserfs/xattr.h +++ b/fs/reiserfs/xattr.h @@ -43,7 +43,7 @@ void reiserfs_security_free(struct reise static inline int reiserfs_xattrs_initialized(struct super_block *sb) { - return REISERFS_SB(sb)->priv_root != NULL; + return REISERFS_SB(sb)->priv_root && REISERFS_SB(sb)->xattr_root; } #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))