ksmbd: remove filename in ksmbd_file
Subsystems (2)
Namjae Jeon
maintainerPATCH RESEND 1/1 ksmbd: remove filename in ksmbd_file
If the filename is change by underlying rename the server, fp->filename and real filename can be different. This patch remove the uses of fp->filename in ksmbd and replace it with d_path().
--- fs/ksmbd/misc.c | 40 +++++++++++++++++++++++++++++++--------- fs/ksmbd/misc.h | 3 ++- fs/ksmbd/oplock.c | 30 ------------------------------ fs/ksmbd/oplock.h | 2 -- fs/ksmbd/smb2pdu.c | 21 +++++++-------------- fs/ksmbd/vfs.c | 6 ++---- fs/ksmbd/vfs_cache.c | 1 - fs/ksmbd/vfs_cache.h | 1 - 8 files changed, 42 insertions(+), 62 deletions(-)
fs/ksmbd/misc.c +31 -9
@@ -158,19 +158,41 @@ int parse_stream_name(char *filename, char **stream_name, int *s_type)* Return : windows path string or error */ -char *convert_to_nt_pathname (char *filename) +char *convert_to_nt_pathname (struct ksmbd_share_config *share, +struct path *path) { -char *ab_pathname; +char *pathname, *ab_pathname, *nt_pathname; +int share_path_len =strlen (share->path); -if (strlen (filename) ==0 ) - filename ="\\" ; + pathname =kmalloc (PATH_MAX ,GFP_KERNEL ); +if (!pathname) +return ERR_PTR (-EACCES ); - ab_pathname =kstrdup (filename,GFP_KERNEL ); -if (!ab_pathname) -return NULL ; + ab_pathname =d_path (path, pathname,PATH_MAX ); +if (IS_ERR (ab_pathname)) { + nt_pathname =ERR_PTR (-EACCES ); + goto free_pathname; + } + +if (strncmp (ab_pathname, share->path, share_path_len)) { + nt_pathname =ERR_PTR (-EACCES ); + goto free_pathname; + } + + nt_pathname =kzalloc (strlen (&ab_pathname[share_path_len]) +1 ,GFP_KERNEL ); +if (!nt_pathname) { + nt_pathname =ERR_PTR (-ENOMEM ); + goto free_pathname; + } +if (ab_pathname[share_path_len] =='\0' ) +strcpy (nt_pathname,"/" ); +strcat (nt_pathname, &ab_pathname[share_path_len]); + +ksmbd_conv_path_to_windows (nt_pathname); -ksmbd_conv_path_to_windows (ab_pathname); -return ab_pathname; +free_pathname: +kfree (pathname); +return nt_pathname; }int get_nlink (struct kstat *st)
fs/ksmbd/misc.h +2 -1
@@ -14,7 +14,8 @@ struct ksmbd_file;int match_pattern (const char *str,size_t len,const char *pattern);int ksmbd_validate_filename (char *filename);int parse_stream_name (char *filename,char **stream_name,int *s_type); -char *convert_to_nt_pathname (char *filename); +char *convert_to_nt_pathname (struct ksmbd_share_config *share, +struct path *path);int get_nlink (struct kstat *st);void ksmbd_conv_path_to_unix (char *path);void ksmbd_strip_last_slash (char *path);
fs/ksmbd/oplock.c +0 -30
@@ -1694,33 +1694,3 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,read_unlock (&lease_list_lock);return ret_op; } - -int smb2_check_durable_oplock (struct ksmbd_file *fp, -struct lease_ctx_info *lctx,char *name) -{ -struct oplock_info *opinfo =opinfo_get (fp); -int ret =0 ; - -if (opinfo && opinfo->is_lease) { -if (!lctx) { -pr_err ("open does not include lease\n" ); - ret = -EBADF ; - goto out; - } -if (memcmp (opinfo->o_lease->lease_key, lctx->lease_key, -SMB2_LEASE_KEY_SIZE )) { -pr_err ("invalid lease key\n" ); - ret = -EBADF ; - goto out; - } -if (name &&strcmp (fp->filename, name)) { -pr_err ("invalid name reconnect %s\n" , name); - ret = -EINVAL ; - goto out; - } - } -out: -if (opinfo) -opinfo_put (opinfo); -return ret; -}
fs/ksmbd/oplock.h +0 -2
@@ -124,6 +124,4 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,int find_same_lease_key (struct ksmbd_session *sess,struct ksmbd_inode *ci,struct lease_ctx_info *lctx);void destroy_lease_table (struct ksmbd_conn *conn); -int smb2_check_durable_oplock (struct ksmbd_file *fp, -struct lease_ctx_info *lctx,char *name);#endif /* __KSMBD_OPLOCK_H */
fs/ksmbd/smb2pdu.c +7 -14
@@ -2918,7 +2918,6 @@ int smb2_open(struct ksmbd_work *work) goto err_out; } - fp->filename = name; fp->cdoption = req->CreateDisposition; fp->daccess = daccess; fp->saccess = req->ShareAccess;
@@ -3270,14 +3269,13 @@ int smb2_open(struct ksmbd_work *work)if (!rsp->hdr.Status) rsp->hdr.Status =STATUS_UNEXPECTED_IO_ERROR ; -if (!fp || !fp->filename) -kfree (name);if (fp)ksmbd_fd_put (work, fp);smb2_set_err_rsp (work);ksmbd_debug (SMB ,"Error response: %x\n" , rsp->hdr.Status); } +kfree (name);kfree (lc);return 0 ;
@@ -3895,8 +3893,6 @@ int smb2_query_dir(struct ksmbd_work *work)ksmbd_debug (SMB ,"Search pattern is %s\n" , srch_ptr); } -ksmbd_debug (SMB ,"Directory name is %s\n" , dir_fp->filename); -if (srch_flag &SMB2_REOPEN || srch_flag &SMB2_RESTART_SCANS ) {ksmbd_debug (SMB ,"Restart directory scan\n" );generic_file_llseek (dir_fp->filp,0 ,SEEK_SET );
@@ -4390,9 +4386,9 @@ static int get_file_all_info(struct ksmbd_work *work,return -EACCES ; } - filename =convert_to_nt_pathname (fp->filename); -if (!filename) -return -ENOMEM ; + filename =convert_to_nt_pathname (work->tcon->share_conf, &fp->filp->f_path); +if (IS_ERR (filename)) +return PTR_ERR (filename); inode =file_inode (fp->filp);generic_fillattr (file_mnt_user_ns (fp->filp), inode, &stat);
@@ -5683,8 +5679,7 @@ static int set_file_allocation_info(struct ksmbd_work *work, size =i_size_read (inode); rc =ksmbd_vfs_truncate (work, fp, alloc_blks *512 );if (rc) { -pr_err ("truncate failed! filename : %s, err %d\n" , - fp->filename, rc); +pr_err ("truncate failed!, err %d\n" , rc);return rc; }if (size < alloc_blks *512 )
@@ -5714,12 +5709,10 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,* truncated range. */ if (inode->i_sb->s_magic !=MSDOS_SUPER_MAGIC ) { -ksmbd_debug (SMB ,"filename : %s truncated to newsize %lld\n" , - fp->filename, newsize); +ksmbd_debug (SMB ,"truncated to newsize %lld\n" , newsize); rc =ksmbd_vfs_truncate (work, fp, newsize);if (rc) { -ksmbd_debug (SMB ,"truncate failed! filename : %s err %d\n" , - fp->filename, rc); +ksmbd_debug (SMB ,"truncate failed!, err %d\n" , rc);if (rc != -EAGAIN ) rc = -EBADF ;return rc;
fs/ksmbd/vfs.c +2 -4
@@ -398,8 +398,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count, nbytes =kernel_read (filp, rbuf, count, pos);if (nbytes <0 ) { -pr_err ("smb read failed for (%s), err = %zd\n" , - fp->filename, nbytes); +pr_err ("smb read failed, err = %zd\n" , nbytes);return nbytes; }
@@ -875,8 +874,7 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work, err =vfs_truncate (&filp->f_path, size);if (err) -pr_err ("truncate failed for filename : %s err %d\n" , - fp->filename, err); +pr_err ("truncate failed, err %d\n" , err);return err; }
fs/ksmbd/vfs_cache.c +0 -1
@@ -328,7 +328,6 @@ static void __ksmbd_close_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp)kfree (smb_lock); } -kfree (fp->filename);if (ksmbd_stream_fd (fp))kfree (fp->stream.name);kmem_cache_free (filp_cache, fp);
fs/ksmbd/vfs_cache.h +0 -1
@@ -62,7 +62,6 @@ struct ksmbd_inode {struct ksmbd_file {struct file *filp; -char *filename;u64 persistent_id;u64 volatile_id;
Signature · 1 line
2.25.1
2022년 4월 13일 (수) 오전 7:57, Namjae Jeon <[email protected]>님이 작성:
Quoted 22 lines
If the filename is change by underlying rename the server,
fp->filenameand real filename can be different. This patch remove the uses offp->filenamein ksmbd and replace it withd_path().Signed-off-by Namjae Jeon <[email protected]>--- fs/ksmbd/misc.c | 40 +++++++++++++++++++++++++++++++--------- fs/ksmbd/misc.h | 3 ++- fs/ksmbd/oplock.c | 30 ------------------------------ fs/ksmbd/oplock.h | 2 -- fs/ksmbd/smb2pdu.c | 21 +++++++-------------- fs/ksmbd/vfs.c | 6 ++---- fs/ksmbd/vfs_cache.c | 1 - fs/ksmbd/vfs_cache.h | 1 - 8 files changed, 42 insertions(+), 62 deletions(-)fs/ksmbd/misc.c +0
-0
fs/ksmbd/misc.c int parse_stream_name(char *filename, char **stream_name, int *s_type) · line 165
Quoted 10 lines
fs/ksmbd/misc.c +4
-2@@ -158,19 +158,41 @@ int parse_stream_name(char *filename, char **stream_name, int *s_type)* Return : windows path string or error */ -char *convert_to_nt_pathname (char *filename) +char *convert_to_nt_pathname (struct ksmbd_share_config *share, +struct path *path) { -char *ab_pathname; +char *pathname, *ab_pathname, *nt_pathname; +int share_path_len =strlen (share->path);
We can use share->path_sz instead of calling strlen.
Quoted 18 lines
fs/ksmbd/misc.c +11
-5-if (strlen (filename) ==0 ) - filename ="\\" ; + pathname =kmalloc (PATH_MAX ,GFP_KERNEL ); +if (!pathname) +return ERR_PTR (-EACCES ); - ab_pathname =kstrdup (filename,GFP_KERNEL ); -if (!ab_pathname) -return NULL ; + ab_pathname =d_path (path, pathname,PATH_MAX ); +if (IS_ERR (ab_pathname)) { + nt_pathname =ERR_PTR (-EACCES ); + goto free_pathname; + } + +if (strncmp (ab_pathname, share->path, share_path_len)) { + nt_pathname =ERR_PTR (-EACCES );
fs/ksmbd/misc.c int parse_stream_name(char *filename, char **stream_name, int *s_type) · line 188
Quoted 10 lines
fs/ksmbd/misc.c +10
-0+ goto free_pathname; + } + + nt_pathname =kzalloc (strlen (&ab_pathname[share_path_len]) +1 ,GFP_KERNEL ); +if (!nt_pathname) { + nt_pathname =ERR_PTR (-ENOMEM ); + goto free_pathname; + } +if (ab_pathname[share_path_len] =='\0' ) +strcpy (nt_pathname,"/" );
If ab_pathname and share->path store the same string literal, the size of nt_pathname is 1 byte. Could this strcpy make buffer overrun?
Quoted 201 lines
fs/ksmbd/misc.c +6
-2+strcat (nt_pathname, &ab_pathname[share_path_len]); + +ksmbd_conv_path_to_windows (nt_pathname); -ksmbd_conv_path_to_windows (ab_pathname); -return ab_pathname; +free_pathname: +kfree (pathname); +return nt_pathname; }int get_nlink (struct kstat *st)fs/ksmbd/misc.h +2
-1@@ -14,7 +14,8 @@ struct ksmbd_file;int match_pattern (const char *str,size_t len,const char *pattern);int ksmbd_validate_filename (char *filename);int parse_stream_name (char *filename,char **stream_name,int *s_type); -char *convert_to_nt_pathname (char *filename); +char *convert_to_nt_pathname (struct ksmbd_share_config *share, +struct path *path);int get_nlink (struct kstat *st);void ksmbd_conv_path_to_unix (char *path);void ksmbd_strip_last_slash (char *path);fs/ksmbd/oplock.c +0
-30@@ -1694,33 +1694,3 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,read_unlock (&lease_list_lock);return ret_op; } - -int smb2_check_durable_oplock (struct ksmbd_file *fp, -struct lease_ctx_info *lctx,char *name) -{ -struct oplock_info *opinfo =opinfo_get (fp); -int ret =0 ; - -if (opinfo && opinfo->is_lease) { -if (!lctx) { -pr_err ("open does not include lease\n" ); - ret = -EBADF ; - goto out; - } -if (memcmp (opinfo->o_lease->lease_key, lctx->lease_key, -SMB2_LEASE_KEY_SIZE )) { -pr_err ("invalid lease key\n" ); - ret = -EBADF ; - goto out; - } -if (name &&strcmp (fp->filename, name)) { -pr_err ("invalid name reconnect %s\n" , name); - ret = -EINVAL ; - goto out; - } - } -out: -if (opinfo) -opinfo_put (opinfo); -return ret; -}fs/ksmbd/oplock.h +0
-2@@ -124,6 +124,4 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,int find_same_lease_key (struct ksmbd_session *sess,struct ksmbd_inode *ci,struct lease_ctx_info *lctx);void destroy_lease_table (struct ksmbd_conn *conn); -int smb2_check_durable_oplock (struct ksmbd_file *fp, -struct lease_ctx_info *lctx,char *name);#endif /* __KSMBD_OPLOCK_H */ fs/ksmbd/smb2pdu.c +7
-14@@ -2918,7 +2918,6 @@ int smb2_open(struct ksmbd_work *work) goto err_out; } - fp->filename = name; fp->cdoption = req->CreateDisposition; fp->daccess = daccess; fp->saccess = req->ShareAccess;@@ -3270,14 +3269,13 @@ int smb2_open(struct ksmbd_work *work)if (!rsp->hdr.Status) rsp->hdr.Status =STATUS_UNEXPECTED_IO_ERROR ; -if (!fp || !fp->filename) -kfree (name);if (fp)ksmbd_fd_put (work, fp);smb2_set_err_rsp (work);ksmbd_debug (SMB ,"Error response: %x\n" , rsp->hdr.Status); } +kfree (name);kfree (lc);return 0 ;@@ -3895,8 +3893,6 @@ int smb2_query_dir(struct ksmbd_work *work)ksmbd_debug (SMB ,"Search pattern is %s\n" , srch_ptr); } -ksmbd_debug (SMB ,"Directory name is %s\n" , dir_fp->filename); -if (srch_flag &SMB2_REOPEN || srch_flag &SMB2_RESTART_SCANS ) {ksmbd_debug (SMB ,"Restart directory scan\n" );generic_file_llseek (dir_fp->filp,0 ,SEEK_SET );@@ -4390,9 +4386,9 @@ static int get_file_all_info(struct ksmbd_work *work,return -EACCES ; } - filename =convert_to_nt_pathname (fp->filename); -if (!filename) -return -ENOMEM ; + filename =convert_to_nt_pathname (work->tcon->share_conf, &fp->filp->f_path); +if (IS_ERR (filename)) +return PTR_ERR (filename); inode =file_inode (fp->filp);generic_fillattr (file_mnt_user_ns (fp->filp), inode, &stat);@@ -5683,8 +5679,7 @@ static int set_file_allocation_info(struct ksmbd_work *work, size =i_size_read (inode); rc =ksmbd_vfs_truncate (work, fp, alloc_blks *512 );if (rc) { -pr_err ("truncate failed! filename : %s, err %d\n" , - fp->filename, rc); +pr_err ("truncate failed!, err %d\n" , rc);return rc; }if (size < alloc_blks *512 )@@ -5714,12 +5709,10 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp,* truncated range. */ if (inode->i_sb->s_magic !=MSDOS_SUPER_MAGIC ) { -ksmbd_debug (SMB ,"filename : %s truncated to newsize %lld\n" , - fp->filename, newsize); +ksmbd_debug (SMB ,"truncated to newsize %lld\n" , newsize); rc =ksmbd_vfs_truncate (work, fp, newsize);if (rc) { -ksmbd_debug (SMB ,"truncate failed! filename : %s err %d\n" , - fp->filename, rc); +ksmbd_debug (SMB ,"truncate failed!, err %d\n" , rc);if (rc != -EAGAIN ) rc = -EBADF ;return rc;fs/ksmbd/vfs.c +2
-4@@ -398,8 +398,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count, nbytes =kernel_read (filp, rbuf, count, pos);if (nbytes <0 ) { -pr_err ("smb read failed for (%s), err = %zd\n" , - fp->filename, nbytes); +pr_err ("smb read failed, err = %zd\n" , nbytes);return nbytes; }@@ -875,8 +874,7 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work, err =vfs_truncate (&filp->f_path, size);if (err) -pr_err ("truncate failed for filename : %s err %d\n" , - fp->filename, err); +pr_err ("truncate failed, err %d\n" , err);return err; }fs/ksmbd/vfs_cache.c +0
-1@@ -328,7 +328,6 @@ static void __ksmbd_close_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp)kfree (smb_lock); } -kfree (fp->filename);if (ksmbd_stream_fd (fp))kfree (fp->stream.name);kmem_cache_free (filp_cache, fp);fs/ksmbd/vfs_cache.h +0
-2@@ -62,7 +62,6 @@ struct ksmbd_inode {struct ksmbd_file {struct file *filp; -char *filename;u64 persistent_id;u64 volatile_id; --2.25.1
Signature · 2 lines
Thanks, Hyunchul
Namjae Jeon
maintainer2022-04-14 8:29 GMT+09:00, Hyunchul Lee <[email protected]>:
Quoted 27 lines
2022년 4월 13일 (수) 오전 7:57, Namjae Jeon <[email protected]>님이 작성:
Quoted 26 lines
If the filename is change by underlying rename the server,
fp->filenameand real filename can be different. This patch remove the uses offp->filenamein ksmbd and replace it withd_path().Signed-off-by Namjae Jeon <[email protected]>--- fs/ksmbd/misc.c | 40 +++++++++++++++++++++++++++++++--------- fs/ksmbd/misc.h | 3 ++- fs/ksmbd/oplock.c | 30 ------------------------------ fs/ksmbd/oplock.h | 2 -- fs/ksmbd/smb2pdu.c | 21 +++++++-------------- fs/ksmbd/vfs.c | 6 ++---- fs/ksmbd/vfs_cache.c | 1 - fs/ksmbd/vfs_cache.h | 1 - 8 files changed, 42 insertions(+), 62 deletions(-)fs/ksmbd/misc.c +0
-0@@ -158,19 +158,41 @@ int parse_stream_name(char *filename, char**stream_name, int *s_type) * Return : windows path string or error */
Quoted 8 lines
fs/ksmbd/misc.c int parse_stream_name(char *filename, char **stream_name, int *s_type) · line 165
Quoted 7 lines
fs/ksmbd/misc.c +4
-2-char *convert_to_nt_pathname (char *filename) +char *convert_to_nt_pathname (struct ksmbd_share_config *share, +struct path *path) { -char *ab_pathname; +char *pathname, *ab_pathname, *nt_pathname; +int share_path_len =strlen (share->path);
Hi Hyunchul,
Quoted 1 line
We can use
share->path_szinstead of calling strlen.
Okay.
Quoted 26 lines
Quoted 26 lines
fs/ksmbd/misc.c +17
-5-if (strlen (filename) ==0 ) - filename ="\\" ; + pathname =kmalloc (PATH_MAX ,GFP_KERNEL ); +if (!pathname) +return ERR_PTR (-EACCES ); - ab_pathname =kstrdup (filename,GFP_KERNEL ); -if (!ab_pathname) -return NULL ; + ab_pathname =d_path (path, pathname,PATH_MAX ); +if (IS_ERR (ab_pathname)) { + nt_pathname =ERR_PTR (-EACCES ); + goto free_pathname; + } + +if (strncmp (ab_pathname, share->path, share_path_len)) { + nt_pathname =ERR_PTR (-EACCES ); + goto free_pathname; + } + + nt_pathname =kzalloc (strlen (&ab_pathname[share_path_len]) +1 ,GFP_KERNEL ); +if (!nt_pathname) { + nt_pathname =ERR_PTR (-ENOMEM );
Quoted 8 lines
fs/ksmbd/misc.c int parse_stream_name(char *filename, char **stream_name, int *s_type) · line 188
Quoted 4 lines
fs/ksmbd/misc.c +4
-0+ goto free_pathname; + } +if (ab_pathname[share_path_len] =='\0' ) +strcpy (nt_pathname,"/" );If
ab_pathnameandshare->pathstore the same string literal, the size ofnt_pathnameis 1 byte. Could this strcpy make buffer overrun?
Will fix it.
Thanks:)
Quoted 222 lines
Quoted 214 lines
fs/ksmbd/misc.c +6
-2+strcat (nt_pathname, &ab_pathname[share_path_len]); + +ksmbd_conv_path_to_windows (nt_pathname); -ksmbd_conv_path_to_windows (ab_pathname); -return ab_pathname; +free_pathname: +kfree (pathname); +return nt_pathname; }int
get_nlink(struct kstat *st)fs/ksmbd/misc.h +2
-1@@ -14,7 +14,8 @@ struct ksmbd_file;int match_pattern (const char *str,size_t len,const char *pattern);int ksmbd_validate_filename (char *filename);int parse_stream_name (char *filename,char **stream_name,int *s_type); -char *convert_to_nt_pathname (char *filename); +char *convert_to_nt_pathname (struct ksmbd_share_config *share, +struct path *path);int get_nlink (struct kstat *st);void ksmbd_conv_path_to_unix (char *path);void ksmbd_strip_last_slash (char *path);fs/ksmbd/oplock.c +0
-30@@ -1694,33 +1694,3 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,read_unlock (&lease_list_lock);return ret_op; } - -int smb2_check_durable_oplock (struct ksmbd_file *fp, -struct lease_ctx_info *lctx,char *name) -{ -struct oplock_info *opinfo =opinfo_get (fp); -int ret =0 ; - -if (opinfo && opinfo->is_lease) { -if (!lctx) { -pr_err ("open does not include lease\n" ); - ret = -EBADF ; - goto out; - } -if (memcmp (opinfo->o_lease->lease_key, lctx->lease_key, -SMB2_LEASE_KEY_SIZE )) { -pr_err ("invalid lease key\n" ); - ret = -EBADF ; - goto out; - } -if (name &&strcmp (fp->filename, name)) { -pr_err ("invalid name reconnect %s\n" , name); - ret = -EINVAL ; - goto out; - } - } -out: -if (opinfo) -opinfo_put (opinfo); -return ret; -}fs/ksmbd/oplock.h +0
-2@@ -124,6 +124,4 @@ struct oplock_info *lookup_lease_in_table(structksmbd_conn *conn, int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,struct lease_ctx_info *lctx);void destroy_lease_table (struct ksmbd_conn *conn); -int smb2_check_durable_oplock (struct ksmbd_file *fp, -struct lease_ctx_info *lctx,char *name);#endif /* __KSMBD_OPLOCK_H */ fs/ksmbd/smb2pdu.c +1
-3@@ -2918,7 +2918,6 @@ int smb2_open(struct ksmbd_work *work) goto err_out; } - fp->filename = name; fp->cdoption = req->CreateDisposition; fp->daccess = daccess; fp->saccess = req->ShareAccess;@@ -3270,14 +3269,13 @@ int smb2_open(struct ksmbd_work *work)if (!rsp->hdr.Status) rsp->hdr.Status =STATUS_UNEXPECTED_IO_ERROR ; -if (!fp || !fp->filename) -kfree (name);if (fp)ksmbd_fd_put (work, fp);smb2_set_err_rsp (work);ksmbd_debug (SMB ,"Error response: %x\n" , rsp->hdr.Status); } +kfree (name);kfree (lc);return 0;fs/ksmbd/smb2pdu.c +3
-5@@ -3895,8 +3893,6 @@ int smb2_query_dir(struct ksmbd_work *work)ksmbd_debug (SMB ,"Search pattern is %s\n" , srch_ptr); } -ksmbd_debug (SMB ,"Directory name is %s\n" , dir_fp->filename); -if (srch_flag &SMB2_REOPEN || srch_flag &SMB2_RESTART_SCANS ) {ksmbd_debug (SMB ,"Restart directory scan\n" );generic_file_llseek (dir_fp->filp,0 ,SEEK_SET );@@ -4390,9 +4386,9 @@ static int get_file_all_info(struct ksmbd_work *work, return -EACCES ; } - filename =convert_to_nt_pathname (fp->filename); -if (!filename) -return -ENOMEM ; + filename =convert_to_nt_pathname (work->tcon->share_conf, &fp->filp->f_path); +if (IS_ERR (filename)) +return PTR_ERR (filename);inode = file_inode(fp->filp); generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat);fs/ksmbd/smb2pdu.c +1
-2@@ -5683,8 +5679,7 @@ static int set_file_allocation_info(structksmbd_work *work, size =i_size_read (inode); rc =ksmbd_vfs_truncate (work, fp, alloc_blks *512 );if (rc) { - pr_err("truncate failed! filename : %s, err %d\n", - fp->filename, rc); + pr_err("truncate failed!, err %d\n", rc);return rc;} if (size < alloc_blks * 512)fs/ksmbd/smb2pdu.c +2
-4@@ -5714,12 +5709,10 @@ static int set_end_of_file_info(struct ksmbd_work*work, struct ksmbd_file *fp, * truncated range. */ if (inode->i_sb->s_magic !=MSDOS_SUPER_MAGIC ) { - ksmbd_debug(SMB, "filename : %s truncated to newsize %lld\n", - fp->filename, newsize); + ksmbd_debug(SMB, "truncated to newsize %lld\n", newsize); rc =ksmbd_vfs_truncate (work, fp, newsize);if (rc) { - ksmbd_debug(SMB, "truncate failed! filename : %s err %d\n", - fp->filename, rc); + ksmbd_debug(SMB, "truncate failed!, err %d\n",rc); if (rc != -EAGAIN) rc = -EBADF; return rc;fs/ksmbd/vfs.c +2
-4@@ -398,8 +398,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count, nbytes =kernel_read (filp, rbuf, count, pos);if (nbytes <0 ) { -pr_err ("smb read failed for (%s), err = %zd\n" , - fp->filename, nbytes); +pr_err ("smb read failed, err = %zd\n" , nbytes);return nbytes; }@@ -875,8 +874,7 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work, err =vfs_truncate (&filp->f_path, size);if (err) -pr_err ("truncate failed for filename : %s err %d\n" , - fp->filename, err); +pr_err ("truncate failed, err %d\n" , err);return err; }fs/ksmbd/vfs_cache.c +0
-1@@ -328,7 +328,6 @@ static void __ksmbd_close_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp)kfree (smb_lock); } -kfree (fp->filename);if (ksmbd_stream_fd (fp))kfree (fp->stream.name);kmem_cache_free(filp_cache, fp);fs/ksmbd/vfs_cache.h +0
-2@@ -62,7 +62,6 @@ struct ksmbd_inode {struct ksmbd_file {struct file *filp; -char *filename;u64 persistent_id;u64 volatile_id; --Quoted 2 lines
2.25.1
--
Thanks,
Hyunchul