fanotify.c (9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e) fanotify.c (304e9c83e80d5cbe20ab64ffa1fac9fc51d30bc9)
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/fanotify.h>
3#include <linux/fdtable.h>
4#include <linux/fsnotify_backend.h>
5#include <linux/init.h>
6#include <linux/jiffies.h>
7#include <linux/kernel.h> /* UINT_MAX */
8#include <linux/mount.h>

--- 366 unchanged lines hidden (view full) ---

375static int fanotify_encode_fh_len(struct inode *inode)
376{
377 int dwords = 0;
378 int fh_len;
379
380 if (!inode)
381 return 0;
382
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/fanotify.h>
3#include <linux/fdtable.h>
4#include <linux/fsnotify_backend.h>
5#include <linux/init.h>
6#include <linux/jiffies.h>
7#include <linux/kernel.h> /* UINT_MAX */
8#include <linux/mount.h>

--- 366 unchanged lines hidden (view full) ---

375static int fanotify_encode_fh_len(struct inode *inode)
376{
377 int dwords = 0;
378 int fh_len;
379
380 if (!inode)
381 return 0;
382
383 exportfs_encode_inode_fh(inode, NULL, &dwords, NULL);
383 exportfs_encode_inode_fh(inode, NULL, &dwords, NULL, 0);
384 fh_len = dwords << 2;
385
386 /*
387 * struct fanotify_error_event might be preallocated and is
388 * limited to MAX_HANDLE_SZ. This should never happen, but
389 * safeguard by forcing an invalid file handle.
390 */
391 if (WARN_ON_ONCE(fh_len > MAX_HANDLE_SZ))

--- 46 unchanged lines hidden (view full) ---

438 goto out_err;
439
440 *fanotify_fh_ext_buf_ptr(fh) = ext_buf;
441 buf = ext_buf;
442 fh->flags |= FANOTIFY_FH_FLAG_EXT_BUF;
443 }
444
445 dwords = fh_len >> 2;
384 fh_len = dwords << 2;
385
386 /*
387 * struct fanotify_error_event might be preallocated and is
388 * limited to MAX_HANDLE_SZ. This should never happen, but
389 * safeguard by forcing an invalid file handle.
390 */
391 if (WARN_ON_ONCE(fh_len > MAX_HANDLE_SZ))

--- 46 unchanged lines hidden (view full) ---

438 goto out_err;
439
440 *fanotify_fh_ext_buf_ptr(fh) = ext_buf;
441 buf = ext_buf;
442 fh->flags |= FANOTIFY_FH_FLAG_EXT_BUF;
443 }
444
445 dwords = fh_len >> 2;
446 type = exportfs_encode_inode_fh(inode, buf, &dwords, NULL);
446 type = exportfs_encode_inode_fh(inode, buf, &dwords, NULL, 0);
447 err = -EINVAL;
448 if (!type || type == FILEID_INVALID || fh_len != dwords << 2)
449 goto out_err;
450
451 fh->type = type;
452 fh->len = fh_len;
453
454out:

--- 626 unchanged lines hidden ---
447 err = -EINVAL;
448 if (!type || type == FILEID_INVALID || fh_len != dwords << 2)
449 goto out_err;
450
451 fh->type = type;
452 fh->len = fh_len;
453
454out:

--- 626 unchanged lines hidden ---