Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp128970pxb; Mon, 18 Oct 2021 22:35:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwno/W6eB6odOlAbYfFykuxm+ADhgphQ2K0rucmLR+W9x4wYR6/bTarv7muCgripl/hUyEO X-Received: by 2002:a17:906:e2cf:: with SMTP id gr15mr34955000ejb.468.1634621734452; Mon, 18 Oct 2021 22:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634621734; cv=none; d=google.com; s=arc-20160816; b=g9jaT7LKkfFX2ykkFxIgKLlaGqKRImNrSxOipdaKZCbZ99sXt8tABue3C4Ujl1rs0n lbnISlsNyTpHv/LNJP0bvw8egPEEagFi/a3sNCUT9ZIXODcPKSbqh66FeeKHpkrKHGHf rkxS2cTeiZnsZbOl8TWsfu4R+oGOVU3DN4i+mR7NQpK5PNXaYsrY1SVD2pkN3ADyUOCY VDicFypuYiv8Q+O1VZddNQqmh+aalMMhpegXpYU8CdvGevd6oBTTVlOxwUYOF210MJ6h r9eDRmLlNN5K2AKgIP6rGJ38ajlDm/d3VtM060rvN9k7pSXRoSzJWlhrjXve4zzLuYCC MYaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZaruljHe7kDR6dP+QS54XPWAlkN8SFW2qWKy+H3YQEw=; b=BqToI/9B4CLSfN2clebA/yn7/zvTt2oOd7DgSGENT5vGchleS5YScQNCuMc64DP/AK k21nnlJaLMwjLzH4BqAy61JV7Tucul/eXGHkTRCCHPo0YJDd83OSEJjBqxB1riPL3+NX B16ClC4VM8X6hvPdiX7To96lvUeIfiERT+rYO7CX2MzmZLKs4q4rZ5QcVnYPqRQSvBO9 ujUPGl/YAG4Lc/vwyLWE7tXB8xzuT5ZEKc280RW3fbyzIgi2MHDbGEBPtgJ3Q/jc1ysw jaOsjcIqgvmzQ9i9JdChK0E1mzmbfZAedL36IU27vstjZbdu5/xIi/dmR/0mdBveBaSc fghg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=os9Ab4GJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc27si21271571edb.455.2021.10.18.22.34.59; Mon, 18 Oct 2021 22:35:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=os9Ab4GJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233058AbhJSFhG (ORCPT + 99 others); Tue, 19 Oct 2021 01:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbhJSFhF (ORCPT ); Tue, 19 Oct 2021 01:37:05 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79817C06161C; Mon, 18 Oct 2021 22:34:53 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id z69so15856352iof.9; Mon, 18 Oct 2021 22:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZaruljHe7kDR6dP+QS54XPWAlkN8SFW2qWKy+H3YQEw=; b=os9Ab4GJHujvQJO7/jacPvhQUobs6+64FPp4pACq91J7nQ2NZlHrRDLwDU1vfKvGUN laXmLIg3f5nOVSQFSd78jQFLvX7YfWSLKhwcipeemY5zWy4UZvhIjHRUJxFhw+AgW0DQ H7nNCSEpHRPDfiTlHfbPPCqg7+TTcWZxx7Jid+J8guq3qrukv/6tHsdKy/C//jyRboQK q/K2Rn/OluHw2tziZjeYi6R70zhJ4x0lmyPm2zqG0xWTKu7mNoZlJGB5razbRA2+n0h0 hZ2zXpcf6jMoWdcK8rW3HE/bJn1axswvggFXfTxO9lx9iQ6LqpyzhfmfY/aOf8p3aBJ/ fgFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZaruljHe7kDR6dP+QS54XPWAlkN8SFW2qWKy+H3YQEw=; b=uAh+/IV8CPcKpnDSWhDZqF6G5DgqnLbQcgc3T5oCo+FMTq1BKMzdYlfg2Ns89bhxOe lGOVMX2GWzXLJcOx2txRoHOlJ+Bp3iCShNFXW/BC0rlmeiHoxK/N7/1g741jUwUpR9kQ KL+Q0DHFjzZK6A1xCZDrffU/KtoLxH+LkirFmKVjlQcBEr8pnamBsz7HGxFO748sTwT1 GR6QTxP8ugCepm2n2iwVRe6GVEDcDvizfPa4Nx7d8Vb2fVzf2htSik8SJTJILfNb6zwP osOYeS9Uw9+WIL54f9uUe//LKbz0OIRasSymnBrz2INGT3J8+0t/DQJfQIJxH4dfkUgc tglQ== X-Gm-Message-State: AOAM5323z4S4kvB/QLPeS51vboZWcaQpae72AfPVqsT2ByflmQU4tNAk 8JPzaQbEQFyKietSi5jnutWMJgrY6lgBhzD9tGmzj4feAFk= X-Received: by 2002:a6b:b5d8:: with SMTP id e207mr17065356iof.52.1634621692844; Mon, 18 Oct 2021 22:34:52 -0700 (PDT) MIME-Version: 1.0 References: <20211019000015.1666608-1-krisman@collabora.com> <20211019000015.1666608-12-krisman@collabora.com> In-Reply-To: <20211019000015.1666608-12-krisman@collabora.com> From: Amir Goldstein Date: Tue, 19 Oct 2021 08:34:41 +0300 Message-ID: Subject: Re: [PATCH v8 11/32] fsnotify: Protect fsnotify_handle_inode_event from no-inode events To: Gabriel Krisman Bertazi Cc: Jan Kara , "Darrick J. Wong" , Theodore Tso , Dave Chinner , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 , Linux API , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Oct 19, 2021 at 3:01 AM Gabriel Krisman Bertazi wrote: > > FAN_FS_ERROR allows events without inodes - i.e. for file system-wide > errors. Even though fsnotify_handle_inode_event is not currently used > by fanotify, this patch protects this path to handle this new case. > > Suggested-by: Amir Goldstein > Signed-off-by: Gabriel Krisman Bertazi > --- > fs/notify/fsnotify.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c > index fde3a1115a17..47f931fb571c 100644 > --- a/fs/notify/fsnotify.c > +++ b/fs/notify/fsnotify.c > @@ -252,6 +252,9 @@ static int fsnotify_handle_inode_event(struct fsnotify_group *group, > if (WARN_ON_ONCE(!ops->handle_inode_event)) > return 0; > > + if (!inode) > + return 0; > + Sigh.. the plot thickens. There are three in-tree backends that implement the ->handle_inode_event() interface. inotify and dnotify can take NULL inode and the above will make the CREATE events on kernfs vanish, so we cannot do that. Sorry for not noticing this earlier when I asked for this change. nfsd_file_fsnotify_handle_event() can most certainly not take NULL inode, but nfsd does not watch for CREATE events. I think what we need to do is (Jan please correct me if you think otherwise): 1. Document the handle_inode_event() interface that either inode or dir must be non-NULL 2. WARN_ON_ONCE(!inode && !dir) instead of just (!inode) above 3. Add WARN_ON_ONCE(!inode) before trace_nfsd_file_fsnotify_handle_event() in nfsd_file_fsnotify_handle_event() Apologies, Gabriel, for having to cleanup our mess ;-) Thanks, Amir.