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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 8CC60C433FE for ; Wed, 9 Dec 2020 22:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DEDE239D1 for ; Wed, 9 Dec 2020 22:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgLIW7W (ORCPT ); Wed, 9 Dec 2020 17:59:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgLIW7W (ORCPT ); Wed, 9 Dec 2020 17:59:22 -0500 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA2C8C0613CF; Wed, 9 Dec 2020 14:58:40 -0800 (PST) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kn8Pl-000AsE-02; Wed, 09 Dec 2020 22:58:29 +0000 Date: Wed, 9 Dec 2020 22:58:28 +0000 From: Al Viro To: Matthew Wilcox Cc: "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Oleg Nesterov , Jann Horn Subject: Re: [PATCH] files: rcu free files_struct Message-ID: <20201209225828.GR3579531@ZenIV.linux.org.uk> References: <87r1on1v62.fsf@x220.int.ebiederm.org> <20201120231441.29911-15-ebiederm@xmission.com> <20201207232900.GD4115853@ZenIV.linux.org.uk> <877dprvs8e.fsf@x220.int.ebiederm.org> <20201209040731.GK3579531@ZenIV.linux.org.uk> <877dprtxly.fsf@x220.int.ebiederm.org> <20201209142359.GN3579531@ZenIV.linux.org.uk> <87o8j2svnt.fsf_-_@x220.int.ebiederm.org> <20201209194938.GS7338@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201209194938.GS7338@casper.infradead.org> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Dec 09, 2020 at 07:49:38PM +0000, Matthew Wilcox wrote: > On Wed, Dec 09, 2020 at 12:04:38PM -0600, Eric W. Biederman wrote: > > @@ -397,8 +397,9 @@ static struct fdtable *close_files(struct files_struct * files) > > set = fdt->open_fds[j++]; > > while (set) { > > if (set & 1) { > > - struct file * file = xchg(&fdt->fd[i], NULL); > > + struct file * file = fdt->fd[i]; > > if (file) { > > + rcu_assign_pointer(fdt->fd[i], NULL); > > Assuming this is safe, you can use RCU_INIT_POINTER() here because you're > storing NULL, so you don't need the wmb() before storing the pointer. fs/file.c:pick_file() would make more interesting target for the same treatment...