Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3192240pxf; Mon, 5 Apr 2021 05:51:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG33Dn6ccalPo29ZRZQ4y2R6zD88n4ehSIUEBGPm3DQ+fqLBXAy4p1SrkNsWq8o1Vpm9OL X-Received: by 2002:a05:6e02:b2c:: with SMTP id e12mr220190ilu.161.1617627109610; Mon, 05 Apr 2021 05:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617627109; cv=none; d=google.com; s=arc-20160816; b=JE2Gt/R8ELbdTfoNaqgtPNXsYMdlS4oL8JcgFwIoNh2C2K3JNSkhmHWMv5jdDduDGo 8EMB90Itl3UiUf9FIUAvU6euRqxEPktqwEcmGZWKhnggy6CvTBMhdeEa7zwX2W+yMNNm wV9LCl4QjOzdIkLvo9P6bNh8QO5Qb6gPu6rPFd/o2ZmJoSXAfztzywaTLkEt7/8Ygikv YBfCSYjhjwYvmerDZL0+vYCmNecq31s0LuropQ8wvA614uXVCJKnTuZmRLMU2IQOLewb mLEn60shD25+6ExXAtKxC/HNroc5XXfgc6cz3MuhNXLJyKUDzp/WdK+ephNpAdsp3iH4 kDdg== 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=YML1EdUSUyeSPtvNLHv7fvXhDAvPxCq6IqU0wHmmLmJ6CAP0x2agQBGZxuWlsMgR7y aE7OoU7m7oq4dX1fG0zRTwnvUxht+gdH06iQOl5bME0bld2QJSHLCMOLBx8O2vT0V6Ay fE7Bpgoj9sUbyLu/CoXYa8pVln10IR7Uu3DRkQ+PRq+jhcycgprxKkIb4iPltw7u51m4 3clejrPW9l3DTVa/MC/jlYWlRifcKUI5hP1RpmTpm7qOggHdTI0/w4pJ8Tpg1M8eo9EU /j+/SosRN1ZnwTQ569OGnkTg4FaI4Qo5bQ5TMhJXDg8kTvoZajprjyexzgo4Fk0Px7RL 3UPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d+32Xq8e; 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 g12si5855767ilq.129.2021.04.05.05.51.38; Mon, 05 Apr 2021 05:51:49 -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=d+32Xq8e; 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 S234330AbhDEJAo (ORCPT + 99 others); Mon, 5 Apr 2021 05:00:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:41330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237122AbhDEJAD (ORCPT ); Mon, 5 Apr 2021 05:00:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DD6D60238; Mon, 5 Apr 2021 08:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617613197; bh=uW6oDUm5OGgrAlcJAqE/N3uUNnNkdl5IGSMnsyGW+o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+32Xq8evYl9OntgNcZHQURroJI3uL6V1q3qKhYCOI5Yrd/gRyWZg3ysegmCKYDTB N3+2r07KmLsfp0RdaZaYM2aJIy+KFO0CtExjB1xHKnwXvbPXkygytzohHZBXELjovZ DBIoww5A5M1Lp0jthusil8D1DzhlIcX3A2WKzD4E= 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.14 31/52] reiserfs: update reiserfs_xattrs_initialized() condition Date: Mon, 5 Apr 2021 10:53:57 +0200 Message-Id: <20210405085022.999630262@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085021.996963957@linuxfoundation.org> References: <20210405085021.996963957@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))