Re: [RFC][PATCH] fanotify: allow to set errno in FAN_DENY permission response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 13, 2023 at 09:09:30PM +0200, Amir Goldstein wrote:
> On Wed, Dec 13, 2023 at 7:28 PM Jan Kara <jack@xxxxxxx> wrote:
> >
> > On Fri 08-12-23 10:01:35, Amir Goldstein wrote:
> > > With FAN_DENY response, user trying to perform the filesystem operation
> > > gets an error with errno set to EPERM.
> > >
> > > It is useful for hierarchical storage management (HSM) service to be able
> > > to deny access for reasons more diverse than EPERM, for example EAGAIN,
> > > if HSM could retry the operation later.
> > >
> > > Allow userspace to response to permission events with the response value
> > > FAN_DENY_ERRNO(errno), instead of FAN_DENY to return a custom error.
> > >
> > > The change in fanotify_response is backward compatible, because errno is
> > > written in the high 8 bits of the 32bit response field and old kernels
> > > reject respose value with high bits set.
> > >
> > > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> >
> > So a couple of comments that spring to my mind when I'm looking into this
> > now (partly maybe due to my weak memory ;):
> >
> > 1) Do we still need the EAGAIN return? I think we have mostly dealt with
> > freezing deadlocks in another way, didn't we?
> 
> I was thinking about EAGAIN on account of the HSM not being able to
> download the file ATM.
> 
> There are a bunch of error codes that are typical for network filesystems, e.g.
> ETIMEDOUT, ENOTCONN, ECONNRESET which could be relevant to
> HSM failures.
> 
> >
> > 2) If answer to 1) is yes, then there is a second question - do we expect
> > the errors to propagate back to the unsuspecting application doing say
> > read(2) syscall? Because I don't think that will fly well with a big
> > majority of applications which basically treat *any* error from read(2) as
> > fatal. This is also related to your question about standard permission
> > events. Consumers of these error numbers are going to be random
> > applications and I see a potential for rather big confusion arising there
> > (like read(1) returning EINVAL or EBADF and now you wonder why the hell
> > until you go debug the kernel and find out the error is coming out of
> > fanotify handler). And the usecase is not quite clear to me for ordinary
> > fanotify permission events (while I have no doubts about creativity of
> > implementors of fanotify handlers ;)).
> >
> 
> That's a good question.
> I prefer to delegate your question to the prospect users of the feature.
> 
> Josef, which errors did your use case need this feature for?
> 
> > 3) Given the potential for confusion, maybe we should stay conservative and
> > only allow additional EAGAIN error instead of arbitrary errno if we need it?
> >
> 
> I know I was planning to use this for EDQUOT error (from FAN_PRE_MODIFY),
> but I certainly wouldn't mind restricting the set of custom errors.
> I think it makes sense. The hard part is to agree on this set of errors.
> 

I'm all for flexibility here.

We're going to have 2 classes of applications interacting with HSM backed
storage, normal applications and applications that know they're backed by HSM.
The normal applications are just going to crash if they get an error on read(2),
it doesn't matter what errno it is.  The second class would have different
things they'd want to do in the face of different errors, and that's what this
patchset is targeting.  We can limit it to a few errno's if that makes you feel
better, but having more than just one would be helpful.  Thanks,

Josef




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux