Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3058623pxf; Mon, 5 Apr 2021 01:58:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi/+40yRDdba09YbpvjRrF/J1WXwP0KffY/siDBCZx88ztgGgfJ8G0mjgbIxPXBkK3K0x0 X-Received: by 2002:a05:6638:2591:: with SMTP id s17mr22344844jat.87.1617613089849; Mon, 05 Apr 2021 01:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617613089; cv=none; d=google.com; s=arc-20160816; b=MYr5VyJJPTZGaA69CAMG/eKgNXFeraaXCawCUBXAZ9T1k9jcEzsVzbrGL6XtS0ymiA SJ2gSi3CZX/E7sLXHOb1NXlnTG9B2HOi279FWBWz0P6DC1nb/0F3mszklwczQm/w38qB rtCZafidiWea+wol5rVn53yNIxz9sW4Ncvq5veUouPwKiXV+9tWgXtAb9aIln0j/HT2O I2Al10AjeBLcgORRH3NUIhJ2K1sJZ3POO+5zPAem/oA+AD9pSQGRHVKe8wOl8zAVyqbq OesgW0MhJsvWNcLfZxXl97xq4J1t/5RhA2J9B84MtM4P4zyLXtGwFpSjhPYvvHlYCG42 6OrA== 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=sgc+u+ibUrIoDZSHhfWrqNiEtvFkBoEo/491pl5JBig=; b=KEhu1XuPoORfRoM8MWiM8cY/2mENIaKJs8WLUAFCx1OKu9tcWEXLppy7ZHrUnUvFo4 2IZkysKvABqIap06m8nKPize7rs3INlTlLTb/YOdvjGctZuymwMsZm1N73h1KuREd5Ye iGl7mjM0JuNTd31YFH3H0LEnsSMzj3p/WlCfwwNGfTCxpnP7FKpgFq9riYK1VwPrhv4y RDHAwD666DT+PXlS4pWYleAB2EU0gZX0d7fYEhH7EbKWexsFNzsRrbZw9MVGD+yne6G6 OcK0PfQf4/HlAvtqBwvVKK+y5aGC95Iasdi0H+u5NsnTyYOUMZVidmw+bObTEgaxH5Pc ie2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pjds1HdH; 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 u11si13592386ilq.137.2021.04.05.01.57.57; Mon, 05 Apr 2021 01:58:09 -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=pjds1HdH; 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 S232705AbhDEIzr (ORCPT + 99 others); Mon, 5 Apr 2021 04:55:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:33896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbhDEIzr (ORCPT ); Mon, 5 Apr 2021 04:55:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9DC4F61245; Mon, 5 Apr 2021 08:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617612941; bh=+G1nIWpSHU94vCQ9fb72m3Rs0yzzURXDuCG2wYhjzNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pjds1HdHH5irVHbthuR3Lk1qh0ZXnz8I0geD2acGx7h0e7dbLO86L19tZKVUCzR4j 6auzPl1FKw0pHIzARxAPcyp/Qdwuln8UxN9FghNBjlOYNdv8Itx0F6PcUFbhZRypgy RXdGpGYSxZkMpbfG0xjVqDFBAc+S9mw4o2N7r/+k= 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.4 19/28] reiserfs: update reiserfs_xattrs_initialized() condition Date: Mon, 5 Apr 2021 10:53:53 +0200 Message-Id: <20210405085017.627051799@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085017.012074144@linuxfoundation.org> References: <20210405085017.012074144@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 @@ -42,7 +42,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))