Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp457960pxb; Mon, 16 Aug 2021 09:13:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzESXQ5guuqIB8vPRRnk6N+MfMiiM+rsvHTELDGMe7Y/0Ice61CYafbBfNZPiOYOeZZbnTS X-Received: by 2002:aa7:d547:: with SMTP id u7mr20860289edr.28.1629130397763; Mon, 16 Aug 2021 09:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629130397; cv=none; d=google.com; s=arc-20160816; b=XkXPzwc1+OBFNFJpJEg61GZivkeaaGM/8eceeqfUSsEU94x6wHLEbkkMsiDZAonZsl Vl+7/yUkP2T4B1jNBPYfvx0sc0ZmLRzzHL8tz/uBVcpdard73bQtBBI4vQRDV5ohDyXZ kzERikmGrswBhIs6kPfDSzLu9ippxXSiYg6En604guJTjsciIsalConfM+cNQynIlh8f aPn4oLmhcouWxPTaIcwye69QQ7Dlnh+jTu5vm32itTro5I24wLcyswpmUPDt/1upGKh2 7N/oaWyCkK9aTi/JWZljB6QYnjT+rubHLT/u9I/fj8HxPOBlUcpZ52Y296QGBLWgp7Z7 4AmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=V7D2Rou1vicTgUvdFxy/dJsujRrKhPDwxoEsMczEVOQ=; b=Nofmi0MklRKO7EXPU3T440vEwXpns8b8J6fFo0GJJkVf8w/Hx40IM3slIRAa5BoVNg ytcAnCyH0q0SJ/GH34s/H9HQ8aNktw8QpMCy+aMVxI/4aRm/109BvsA2j0jvKO4KpPxP j5ewHcLcOB1oKjtpPKynj/zuR5IkKU673laSzT3E26mGLlUWG3f+/KNhLgy9VPB8UTgf b6jFnKdJYY0Evpt7mG2uMY4qir/CGbrwr277kRQ7Y8iGUFBrVNinPNtATItIxUZPvFZA EiU2o2vmhchnY2sgN2CoA+jDr57msZ3exuTouqNxpCYDLirgSgGOK+/v5PlAL37x2sO9 Mh5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lzWBdZVy; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=o4IeOzGp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si7561254edz.297.2021.08.16.09.12.48; Mon, 16 Aug 2021 09:13:17 -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=@suse.cz header.s=susede2_rsa header.b=lzWBdZVy; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=o4IeOzGp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbhHPQMU (ORCPT + 99 others); Mon, 16 Aug 2021 12:12:20 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:44602 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbhHPQMU (ORCPT ); Mon, 16 Aug 2021 12:12:20 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4A7921FF92; Mon, 16 Aug 2021 16:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1629130307; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=V7D2Rou1vicTgUvdFxy/dJsujRrKhPDwxoEsMczEVOQ=; b=lzWBdZVys7J4/xRH4cyem2qHUbEJQJTV0QA4W4UmTlT+e5DzZtMFs6wT4HvSCZpXYhP3mE 8YQBykhCqPZhDsac6fb5RAyGNcjwzTaSycbTQ80vbg7JG5m1s4SKqkYg5kD90evvIXbM8V cG+no2/urqGOfD4sYkr/pTKEZhGT7Fw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1629130307; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=V7D2Rou1vicTgUvdFxy/dJsujRrKhPDwxoEsMczEVOQ=; b=o4IeOzGpfehIyua9llXjd5Y9W5slD9tVO5tCKn3ur3TvdEkiwccPK1unZ1jQLy4UiKXDA+ IfFNjYlnbnvHvICg== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 1E678A3B87; Mon, 16 Aug 2021 16:11:47 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id DFE701E0426; Mon, 16 Aug 2021 18:11:43 +0200 (CEST) Date: Mon, 16 Aug 2021 18:11:43 +0200 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Gabriel Krisman Bertazi , Jan Kara , Linux API , Ext4 , linux-fsdevel , Khazhismel Kumykov , David Howells , Dave Chinner , Theodore Tso , "Darrick J. Wong" , Matthew Bobrowski , kernel@collabora.com Subject: Re: [PATCH v6 12/21] fanotify: Encode invalid file handle when no inode is provided Message-ID: <20210816161143.GG30215@quack2.suse.cz> References: <20210812214010.3197279-1-krisman@collabora.com> <20210812214010.3197279-13-krisman@collabora.com> <20210816140657.GE30215@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 16-08-21 18:54:58, Amir Goldstein wrote: > On Mon, Aug 16, 2021 at 5:07 PM Jan Kara wrote: > > Dunno, it still seems like quite some complications (simple ones but > > non-trivial amount of them) for what is rather a corner case. What if we > > *internally* propagated the information that there's no inode info with > > FILEID_ROOT fh? That means: No changes to fanotify_encode_fh_len(), > > fanotify_encode_fh(), or fanotify_alloc_name_event(). In > > copy_info_to_user() we just mangle FILEID_ROOT to FILEID_INVALID and that's > > all. No useless padding, no specialcasing of copying etc. Am I missing > > something? > > I am perfectly fine with encoding "no inode" with FILEID_ROOT internally. > It's already the value used by fanotify_encode_fh() in upstream. > > However, if we use zero len internally, we need to pass fh_type to > fanotify_fid_info_len() and special case FILEID_ROOT in order to > take FANOTIFY_FID_INFO_HDR_LEN into account. > > And special case fanotify_event_object_fh_len() in > fanotify_event_info_len() and in copy_info_records_to_user(). Right, this will need some tweaking. I would actually leave fanotify_fid_info_len() alone, just have in fanotify_event_info_len() something like: - if (fh_len) + if (fh_len || fanotify_event_needs_fsid(event)) and similarly in copy_info_records_to_user(): - if (fanotify_event_object_fh_len(event)) { + if (fanotify_event_object_fh_len(event) || + fanotify_event_needs_fsid(event)) { And that should be all that's needed as far as I'm reading the code. Honza -- Jan Kara SUSE Labs, CR