linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] fl_owner_t and use of filp_close() in nfs4_free_lock_stateid()
@ 2022-10-11 18:03 Al Viro
  2022-10-11 19:02 ` Miklos Szeredi
  0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2022-10-11 18:03 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Miklos Szeredi, Trond Myklebust, Jeff Layton

	In the original commit that introduced that thing, we have
a somewhat strange note in commit message:

    Use filp_close instead of open coding. filp_close does a bit more than
    just release the locks and put the filp. It also calls ->flush and
    dnotify_flush, both of which should be done here anyway.

How could dnotify_flush() possibly catch anything here?  In the current
form the value we pass as id is
	(fl_owner_t)lockowner(stp->st_stateowner)
and lockowner is container_of(so, struct nfs4_lockowner, lo_owner);

dnotify_flush() looks for matches on dn->dn_owner == id; anything
not matching is left alone.  And ->d_owner is set only by attach_dn(),
which gets the value from
        fl_owner_t id = current->files;

If we ever see a match here, we are in deep trouble - the same address
being used as struct files_struct * and struct nfs4_lockowner * at
the same time...

Another interesting question is about FUSE ->flush() - how is the
server supposed to use the value it gets from
        inarg.lock_owner = fuse_lock_owner_id(fm->fc, id);
in fuse_flush()?  Note that e.g. async write might be followed by
close() before the completion.  Moreover, it's possible to start
async write and do unshare(CLONE_FILES); if the descriptor table
used to be shared and all other threads exit after our unshare,
it's possible to get
	async write begins, fuse_send_write() called with current->files as owner
	flush happens, with current->files as id
	what used to be current->files gets freed and memory reused
	async write completes

Miklos, could you give some braindump on that?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-12  7:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-11 18:03 [RFC] fl_owner_t and use of filp_close() in nfs4_free_lock_stateid() Al Viro
2022-10-11 19:02 ` Miklos Szeredi
2022-10-11 20:45   ` Jeff Layton
2022-10-12  7:08     ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).