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,URIBL_BLOCKED,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 676D1C47254 for ; Fri, 1 May 2020 13:56:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 423762051A for ; Fri, 1 May 2020 13:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588341400; bh=9tc8fPx4MlbTBY/4o/GxMr3ZbiC4JW1ibenV4AKQe6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=A4MZTybfs2ozpKcFTOUTmZvtZqXOCh70mJJwBB9XtbYP/ze60hG08TgrDpkwflBSn DUqE4tt2eptLemTeGK/Mlk5EeUEiXfGQoXvonwxp1eo6emsHjZFddVJDzgkTttW/Yt v4tgiIwHhdmLz4EbX76PO0GNcG5eWw9TqsFccPWk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbgEAN4g (ORCPT ); Fri, 1 May 2020 09:56:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:57278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729728AbgEANcY (ORCPT ); Fri, 1 May 2020 09:32:24 -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 73FFA216FD; Fri, 1 May 2020 13:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588339942; bh=9tc8fPx4MlbTBY/4o/GxMr3ZbiC4JW1ibenV4AKQe6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S4770NtZj+ILwToS+STBCsMJOZA9WBaZ8wnroVEufpbiVPMdQyJ2L+JjZyFMxEJPp EQ3aDT8qIwc+c6Dc/VgLo3ziioHQMs+BnXnLIIOhm/7FBf1NlVCYv5U1G9CbiffqQc 9ej5O3XD5w3+46Zl/Yps0tAVQTHB9KZH1/FE0gfI= 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.14 042/117] fs/namespace.c: fix mountpoint reference counter race Date: Fri, 1 May 2020 15:21:18 +0200 Message-Id: <20200501131549.790734364@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131544.291247695@linuxfoundation.org> References: <20200501131544.291247695@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -3216,8 +3216,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) {