Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3295366pxf; Mon, 5 Apr 2021 08:20:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoAJ7jHcmWn09xfQ95/FduQVOq0dnrsWVxUuN6kIMlohjllQw5idV+UoktapRQqgB7T1HQ X-Received: by 2002:a92:c54f:: with SMTP id a15mr7014523ilj.193.1617636036321; Mon, 05 Apr 2021 08:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617636036; cv=none; d=google.com; s=arc-20160816; b=pYunnwAcr18J/ZRiUuRYnCGS7EFPidSzTbo1vTnvgWtVplBBmh1cVvP+942PSOq+6o odXlKWQbnizcr/5He9gybuN0a/tq/ccUuTwawbDa8QqrPLnGZsUyK4MxRckWesWgHqpY Iooq0OHCxuYU635JpzkoiNNfKsfI+UrRZEKlj9fqb1rHlWSl4HxUuO0FtB164+KLWuPY WfRZhDF9ubHxKAlF4ExPzgNpYWgH4aKLVBX7VWwcoilIviOaKBe8vxa+oL2yTfdBK+gn 06hx65sVOLpLDWkfXdg+H8507SoNENUjOtFNJV7PET0wS2MmI5qdugMbAwwQwp9gBGkY 6j3g== 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=NnSOG6J0mq3pOwhVufBwWRco1mAaninnAcmCAU2mXSGJgvzhAQU+545cn/3WJIQYaI FzqTek4Wswaczqf8ARB1+7KsYR9u9YuB3H1HSkgTlsZqi2wIkgVl0yIpMMSui+qeR+5C ONzuU3JBG0rC77r8S7+AVowujKDK1rfxQRHu6aGRkXJSRV8H/uR1lXkux5iEyxdSXkIw lDuoX5WcSLMS0Br6G4aLr4pwdWJCNOngWPIZAc98WPiSBe3cvjh+EOPcPp9oV5uhf2Re QWEmf+reV8XdcuLeCMhpQFnh3zpdKxZZebDvQge59TazJAeNftxjtHtHzAFsPDhejdi6 cm5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HY32JicA; 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 o19si14584173ilt.113.2021.04.05.08.20.24; Mon, 05 Apr 2021 08:20:36 -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=HY32JicA; 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 S237891AbhDEJHz (ORCPT + 99 others); Mon, 5 Apr 2021 05:07:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238706AbhDEJFy (ORCPT ); Mon, 5 Apr 2021 05:05:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A09A613A0; Mon, 5 Apr 2021 09:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617613548; bh=uW6oDUm5OGgrAlcJAqE/N3uUNnNkdl5IGSMnsyGW+o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HY32JicAiO6btfoSjo1TCxagLU7/EOj8RSuC8RYlenDj9YBPeEZ+Pai3wRxj/YucX xcqqacRqKwq/hdpF3oMJk58Mo7WFTKK1FpalzyTC0lMQfnC7oLjrlVn23o/+I1qjsY XCD936WmcdFLZ+yjIcNXZ7Px34U1u0YHijgAacmI= 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 5.4 53/74] reiserfs: update reiserfs_xattrs_initialized() condition Date: Mon, 5 Apr 2021 10:54:17 +0200 Message-Id: <20210405085026.462964923@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085024.703004126@linuxfoundation.org> References: <20210405085024.703004126@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))