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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 61592C433DF for ; Thu, 15 Oct 2020 01:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1887A22257 for ; Thu, 15 Oct 2020 01:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388946AbgJOBe5 (ORCPT ); Wed, 14 Oct 2020 21:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728402AbgJOBeh (ORCPT ); Wed, 14 Oct 2020 21:34:37 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89C2BC05112F; Wed, 14 Oct 2020 16:09:00 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSptC-000OCK-41; Wed, 14 Oct 2020 23:08:58 +0000 Date: Thu, 15 Oct 2020 00:08:58 +0100 From: Al Viro To: Linus Torvalds Cc: Andrii Nakryiko , linux-fsdevel , kernel-team@fb.com, Linux Kernel Mailing List Subject: Re: [PATCH] fs: fix NULL dereference due to data race in prepend_path() Message-ID: <20201014230858.GL3576660@ZenIV.linux.org.uk> References: <20201014204529.934574-1-andrii@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Oct 14, 2020 at 02:49:18PM -0700, Linus Torvalds wrote: > On Wed, Oct 14, 2020 at 2:40 PM Andrii Nakryiko wrote: > > > > Fix data race in prepend_path() with re-reading mnt->mnt_ns twice without > > holding the lock. is_mounted() does check for NULL, but is_anon_ns(mnt->mnt_ns) > > might re-read the pointer again which could be NULL already, if in between > > reads one of kern_unmount()/kern_unmount_array()/umount_tree() sets mnt->mnt_ns > > to NULL. > > This seems like the obviously correct fix, so I think I'll just apply > it directly. > > Al? Holler if you have any issues with this.. See upthread. If you've already grabbed it, I'll just push a followup cleanup.