From: Al Viro <viro@ftp.linux.org.uk>
To: Pekka J Enberg <penberg@cs.helsinki.fi>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [RFC/PATCH 2/5] revoke: core code
Date: Wed, 11 Jul 2007 10:42:51 +0100 [thread overview]
Message-ID: <20070711094251.GV21668@ftp.linux.org.uk> (raw)
In-Reply-To: <20070711093732.GU21668@ftp.linux.org.uk>
On Wed, Jul 11, 2007 at 10:37:33AM +0100, Al Viro wrote:
> On Wed, Jul 11, 2007 at 12:01:06PM +0300, Pekka J Enberg wrote:
> > From: Pekka Enberg <penberg@cs.helsinki.fi>
> >
> > The revokeat(2) and frevoke(2) system calls invalidate open file descriptors
> > and shared mappings of an inode. After an successful revocation, operations
> > on file descriptors fail with the EBADF or ENXIO error code for regular and
> > device files, respectively. Attempting to read from or write to a revoked
> > mapping causes SIGBUS.
> >
> > The actual operation is done in two passes:
> >
> > 1. Revoke all file descriptors that point to the given inode. We do
> > this under tasklist_lock so that after this pass, we don't need
> > to worry about racing with close(2) or dup(2).
>
> How does that deal with the following:
>
> task A gets its descriptor table cleansed
> task B sends a descriptor to task A via SCM_RIGHTS datagram
> task B gets its descriptor table cleansed
> task A receives the datagram and gets the descriptor installed
> task A does any kind of IO on that descriptor
> ->f_mapping gets replaced in the most inconvenient time.
>
> Come to think of that, what do you do if I create a socketpair,
> stuff the descriptor into SCM_RIGHTS datagram and send it to
> myself? Then receive it a day after you've called revoke() and
> voila - I've got an almost undamaged struct file back... At
> the very least, it allows me to fchmod(). Or fchdir() if that
> had been a directory...
>
> BTW, read() or write() in progress might get rather unhappy if your
> live replacement of ->f_mapping races with them...
Better: I have the only opened descriptor for foo. I send it to myself
as described above. I close it. revoke() is called, finds no opened
instances of foo in any descriptor tables and cheerfully does nothing.
I call recvmsg() and I have completely undamaged opened file back.
next prev parent reply other threads:[~2007-07-11 9:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-11 9:01 [RFC/PATCH 2/5] revoke: core code Pekka J Enberg
2007-07-11 9:37 ` Al Viro
2007-07-11 9:42 ` Al Viro [this message]
2007-07-11 9:50 ` Pekka J Enberg
2007-07-11 10:09 ` Al Viro
2007-07-11 10:54 ` Pekka J Enberg
2007-07-11 10:01 ` Pekka J Enberg
2007-07-11 10:18 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070711094251.GV21668@ftp.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.