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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86469C04A95 for ; Sun, 25 Sep 2022 16:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232973AbiIYQwd (ORCPT ); Sun, 25 Sep 2022 12:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232947AbiIYQw3 (ORCPT ); Sun, 25 Sep 2022 12:52:29 -0400 Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4DF8F2CE36 for ; Sun, 25 Sep 2022 09:52:25 -0700 (PDT) Received: by cae.in-ulm.de (Postfix, from userid 1000) id 072E81402B4; Sun, 25 Sep 2022 18:52:23 +0200 (CEST) Date: Sun, 25 Sep 2022 18:52:22 +0200 From: "Christian A. Ehrhardt" To: Tetsuo Handa Cc: Greg Kroah-Hartman , Tejun Heo , syzbot , syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org, Hillf Danton Subject: Re: [PATCH] kernfs: fix UAF race condition in __kernfs_remove() Message-ID: References: <000000000000646c9605e714ec6e@google.com> <7f489b14-2fdc-3d91-c87e-6a802bd8592d@I-love.SAKURA.ne.jp> <83be5776-4038-90d5-f202-9a6e97b6d551@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sun, Sep 25, 2022 at 10:52:56PM +0900, Tetsuo Handa wrote: > On 2022/09/25 22:40, Greg Kroah-Hartman wrote: > > On Sun, Sep 25, 2022 at 10:20:27PM +0900, Tetsuo Handa wrote: > >> On 2022/09/25 22:13, Greg Kroah-Hartman wrote: > >>> Isn't this already handled by: > >>> https://lore.kernel.org/r/20220913121723.691454-1-lk@c--e.de > >>> > >>> that will show up in the next linux-next tree. > >> > >> Oh, I didn't know that patch. > >> > >> But is that patch complete, for there are three __kernfs_remove() callers? > >> > > > > syzbot seems to think it works :) > > syzbot's reproducer tested only kernfs_remove_by_name_ns() case. > I'm not sure whether e.g. __kernfs_remove() from kernfs_remove() is safe. I had an older version of the patch that was rejected by Tejun Heo on the grounds that external kernfs_remove callers must hold a reference on their own or the race can happen even befor kernfs_remoe takes the lock. See https://lore.kernel.org/all/20220907200811.654034-1-lk@c--e.de/ for the details. I did convince myself that other callers of kernfs_remove() have other means to ensure that there are no parallel removes for the same node. IMHO the kernfs interface's use of ref-counts is slightly unintuitive but I think it is safe, now. regards Christian