mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
fanotify: distinguish between fid encode error and null fid
In fanotify_encode_fh(), both cases of NULL inode and failure to encode ended up with fh type FILEID_INVALID. Distiguish the case of NULL inode, by setting fh type to FILEID_ROOT. This is just a semantic difference at this point. Remove stale comment and unneeded check from fid event compare helpers. Link: https://lore.kernel.org/r/20200716084230.30611-4-amir73il@gmail.com Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
103ff6a554
commit
6ad1aadd97
1 changed files with 4 additions and 10 deletions
|
@ -34,10 +34,6 @@ static bool fanotify_fh_equal(struct fanotify_fh *fh1,
|
||||||
if (fh1->type != fh2->type || fh1->len != fh2->len)
|
if (fh1->type != fh2->type || fh1->len != fh2->len)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Do not merge events if we failed to encode fh */
|
|
||||||
if (fh1->type == FILEID_INVALID)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return !fh1->len ||
|
return !fh1->len ||
|
||||||
!memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len);
|
!memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len);
|
||||||
}
|
}
|
||||||
|
@ -56,10 +52,7 @@ static bool fanotify_fid_event_equal(struct fanotify_fid_event *ffe1,
|
||||||
static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
|
static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
|
||||||
struct fanotify_name_event *fne2)
|
struct fanotify_name_event *fne2)
|
||||||
{
|
{
|
||||||
/*
|
/* Do not merge name events without dir fh */
|
||||||
* Do not merge name events without dir fh.
|
|
||||||
* FAN_DIR_MODIFY does not encode object fh, so it may be empty.
|
|
||||||
*/
|
|
||||||
if (!fne1->dir_fh.len)
|
if (!fne1->dir_fh.len)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -290,8 +283,10 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode,
|
||||||
void *buf = fh->buf;
|
void *buf = fh->buf;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
fh->type = FILEID_ROOT;
|
||||||
|
fh->len = 0;
|
||||||
if (!inode)
|
if (!inode)
|
||||||
goto out;
|
return;
|
||||||
|
|
||||||
dwords = 0;
|
dwords = 0;
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
|
@ -326,7 +321,6 @@ static void fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode,
|
||||||
type, bytes, err);
|
type, bytes, err);
|
||||||
kfree(ext_buf);
|
kfree(ext_buf);
|
||||||
*fanotify_fh_ext_buf_ptr(fh) = NULL;
|
*fanotify_fh_ext_buf_ptr(fh) = NULL;
|
||||||
out:
|
|
||||||
/* Report the event without a file identifier on encode error */
|
/* Report the event without a file identifier on encode error */
|
||||||
fh->type = FILEID_INVALID;
|
fh->type = FILEID_INVALID;
|
||||||
fh->len = 0;
|
fh->len = 0;
|
||||||
|
|
Loading…
Reference in a new issue