Hello, overlayfs doesn't work well with the fanotify mechanism. Fanotify first probes for the required buffer size for the file handle, but overlayfs currently bails out without passing the size back. That results in errors in the kernel log, such as: [527944.485384] overlayfs: failed to encode file handle (/, err=-75, buflen=0, len=29, type=1) [527944.485386] fanotify: failed to encode fid (fsid=ae521e68.a434d95f, type=255, bytes=0, err=-2) Lubos Signed-off-by: Lubos Dolezel <lubos@xxxxxxxxxxxx> --- fs/overlayfs/export.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c index 475c61f53..0068bf3a0 100644 --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -231,12 +231,9 @@ static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen) if (IS_ERR(fh)) return PTR_ERR(fh); - err = -EOVERFLOW; len = OVL_FH_LEN(fh); - if (len > buflen) - goto fail; - - memcpy(fid, fh, len); + if (buflen >= len) + memcpy(fid, fh, len); err = len; out: @@ -255,6 +252,7 @@ static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len, { struct dentry *dentry; int bytes = *max_len << 2; + int bytes_used; /* TODO: encode connectable file handles */ if (parent) @@ -264,12 +262,14 @@ static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len, if (WARN_ON(!dentry)) return FILEID_INVALID; - bytes = ovl_dentry_to_fid(dentry, fid, bytes); + bytes_used = ovl_dentry_to_fid(dentry, fid, bytes); dput(dentry); - if (bytes <= 0) + if (bytes_used <= 0) return FILEID_INVALID; - *max_len = bytes >> 2; + *max_len = bytes_used >> 2; + if (bytes_used > bytes) + return FILEID_INVALID; return OVL_FILEID_V1; } -- 2.26.2