From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,LONGWORDS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F07D9C83000 for ; Tue, 28 Apr 2020 18:36:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA4A9208E0 for ; Tue, 28 Apr 2020 18:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099009; bh=V/z9nYtkNN3czXQhqwf7MYTQj/NZF5QlMLIlsp40KV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TiBN6yXJx2rxzVCqJsT7QbGAOJNzLO3RpntTxIE/WWQZn05kkSdhuLcK+Xxn51+wd OFhg/JnvJLyCha4igD73f4d1ZXMr+IOzuVkhD4DDC+qIgb9Emi7HFUdALGZCLLm7Tz 7yH+mPFhmgLbrNuOGQ12fun/4taOH85uZFpML+s8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729951AbgD1Sgt (ORCPT ); Tue, 28 Apr 2020 14:36:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:54296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730394AbgD1Sgn (ORCPT ); Tue, 28 Apr 2020 14:36:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF8032085B; Tue, 28 Apr 2020 18:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099003; bh=V/z9nYtkNN3czXQhqwf7MYTQj/NZF5QlMLIlsp40KV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nMqxtI7q6laBNLkdNCjv9uDfBT/hb6lEfXdTGrpwOTCSZGBluNe7OvEI6dhuJNZky P8/tNw9J8fE6LlHWThxemnKRv+9PSLBcQpv3cxuc5BwSvT126hlGcUBFb89VHssSBy dgobOFHUB25gzIjqoUIzO9y9UnDjLVY1GXBxxdM4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, greg@kroah.com Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Piotr Krysiuk , Al Viro Subject: [PATCH 4.19 084/131] fs/namespace.c: fix mountpoint reference counter race Date: Tue, 28 Apr 2020 20:24:56 +0200 Message-Id: <20200428182235.475417804@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182224.822179290@linuxfoundation.org> References: <20200428182224.822179290@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Piotr Krysiuk A race condition between threads updating mountpoint reference counter affects longterm releases 4.4.220, 4.9.220, 4.14.177 and 4.19.118. The mountpoint reference counter corruption may occur when: * one thread increments m_count member of struct mountpoint [under namespace_sem, but not holding mount_lock] pivot_root() * another thread simultaneously decrements the same m_count [under mount_lock, but not holding namespace_sem] put_mountpoint() unhash_mnt() umount_mnt() mntput_no_expire() To fix this race condition, grab mount_lock before updating m_count in pivot_root(). Reference: CVE-2020-12114 Cc: Al Viro Signed-off-by: Piotr Krysiuk Signed-off-by: Greg Kroah-Hartman --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3142,8 +3142,8 @@ SYSCALL_DEFINE2(pivot_root, const char _ /* make certain new is below the root */ if (!is_path_reachable(new_mnt, new.dentry, &root)) goto out4; - root_mp->m_count++; /* pin it so it won't go away */ lock_mount_hash(); + root_mp->m_count++; /* pin it so it won't go away */ detach_mnt(new_mnt, &parent_path); detach_mnt(root_mnt, &root_parent); if (root_mnt->mnt.mnt_flags & MNT_LOCKED) {