summaryrefslogtreecommitdiff
path: root/fs/ksmbd/vfs_cache.h
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2021-07-08 06:32:27 +0300
committerNamjae Jeon <namjae.jeon@samsung.com>2021-07-09 02:23:16 +0300
commit3867369ef8f760155da684e10d29e0bf9b733b48 (patch)
treea21de9c280e4ef703c08ced0fe7100aa13dbe552 /fs/ksmbd/vfs_cache.h
parenta9071e3c8659d777eb6527e1d377021381d1b5ec (diff)
downloadlinux-3867369ef8f760155da684e10d29e0bf9b733b48.tar.xz
ksmbd: change data type of volatile/persistent id to u64
This patch change data type of volatile/persistent id to u64 to make issue from idr_find and idr_remove(). !HAS_FILE_ID check will protect integer overflow issue from idr_find and idr_remove(). Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/vfs_cache.h')
-rw-r--r--fs/ksmbd/vfs_cache.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/ksmbd/vfs_cache.h b/fs/ksmbd/vfs_cache.h
index 543494f664cb..70e987293564 100644
--- a/fs/ksmbd/vfs_cache.h
+++ b/fs/ksmbd/vfs_cache.h
@@ -22,7 +22,7 @@
#define FILE_GENERIC_EXECUTE 0X1200a0
#define KSMBD_START_FID 0
-#define KSMBD_NO_FID (UINT_MAX)
+#define KSMBD_NO_FID (INT_MAX)
#define SMB2_NO_FID (0xFFFFFFFFFFFFFFFFULL)
struct ksmbd_conn;
@@ -62,8 +62,8 @@ struct ksmbd_inode {
struct ksmbd_file {
struct file *filp;
char *filename;
- unsigned int persistent_id;
- unsigned int volatile_id;
+ u64 persistent_id;
+ u64 volatile_id;
spinlock_t f_lock;
@@ -122,10 +122,8 @@ struct ksmbd_file_table {
struct idr *idr;
};
-static inline bool HAS_FILE_ID(unsigned long long req)
+static inline bool has_file_id(u64 id)
{
- unsigned int id = (unsigned int)req;
-
return id < KSMBD_NO_FID;
}
@@ -136,11 +134,11 @@ static inline bool ksmbd_stream_fd(struct ksmbd_file *fp)
int ksmbd_init_file_table(struct ksmbd_file_table *ft);
void ksmbd_destroy_file_table(struct ksmbd_file_table *ft);
-int ksmbd_close_fd(struct ksmbd_work *work, unsigned int id);
-struct ksmbd_file *ksmbd_lookup_fd_fast(struct ksmbd_work *work, unsigned int id);
-struct ksmbd_file *ksmbd_lookup_foreign_fd(struct ksmbd_work *work, unsigned int id);
-struct ksmbd_file *ksmbd_lookup_fd_slow(struct ksmbd_work *work, unsigned int id,
- unsigned int pid);
+int ksmbd_close_fd(struct ksmbd_work *work, u64 id);
+struct ksmbd_file *ksmbd_lookup_fd_fast(struct ksmbd_work *work, u64 id);
+struct ksmbd_file *ksmbd_lookup_foreign_fd(struct ksmbd_work *work, u64 id);
+struct ksmbd_file *ksmbd_lookup_fd_slow(struct ksmbd_work *work, u64 id,
+ u64 pid);
void ksmbd_fd_put(struct ksmbd_work *work, struct ksmbd_file *fp);
struct ksmbd_file *ksmbd_lookup_durable_fd(unsigned long long id);
struct ksmbd_file *ksmbd_lookup_fd_cguid(char *cguid);