diff mbox series

[2/3] ksmbd: set only file permisson to mode for posix extension

Message ID 20220920132045.5055-2-linkinjeon@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/3] ksmbd: change security id to the one samba used for posix extension | expand

Commit Message

Namjae Jeon Sept. 20, 2022, 1:20 p.m. UTC
Set only file permisson to mode for posix extension like samba.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ksmbd/oplock.c  | 2 +-
 fs/ksmbd/smb2pdu.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Tom Talpey Sept. 20, 2022, 9 p.m. UTC | #1
On 9/20/2022 9:20 AM, Namjae Jeon wrote:
> Set only file permisson to mode for posix extension like samba.

Suggest rewording this for clarity:

  "Set file permission mode to match Samba server posix extension behavior".

Acked-by: Tom Talpey <tom@talpey.com>

> 
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> ---
>   fs/ksmbd/oplock.c  | 2 +-
>   fs/ksmbd/smb2pdu.c | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ksmbd/oplock.c b/fs/ksmbd/oplock.c
> index c26f02086783..9bfd1ef6debd 100644
> --- a/fs/ksmbd/oplock.c
> +++ b/fs/ksmbd/oplock.c
> @@ -1640,7 +1640,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
>   
>   	buf->nlink = cpu_to_le32(inode->i_nlink);
>   	buf->reparse_tag = cpu_to_le32(fp->volatile_id);
> -	buf->mode = cpu_to_le32(inode->i_mode);
> +	buf->mode = cpu_to_le32(inode->i_mode & 0777);
>   	id_to_sid(from_kuid_munged(&init_user_ns, vfsuid_into_kuid(vfsuid)),
>   		  SIDOWNER, (struct smb_sid *)&buf->SidBuffer[0]);
>   	id_to_sid(from_kgid_munged(&init_user_ns, vfsgid_into_kgid(vfsgid)),
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index bc6c7ce17ea8..5c797cc09494 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -3565,7 +3565,7 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
>   		posix_info->AllocationSize = cpu_to_le64(ksmbd_kstat->kstat->blocks << 9);
>   		posix_info->DeviceId = cpu_to_le32(ksmbd_kstat->kstat->rdev);
>   		posix_info->HardLinks = cpu_to_le32(ksmbd_kstat->kstat->nlink);
> -		posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode);
> +		posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode & 0777);
>   		posix_info->Inode = cpu_to_le64(ksmbd_kstat->kstat->ino);
>   		posix_info->DosAttributes =
>   			S_ISDIR(ksmbd_kstat->kstat->mode) ?
> @@ -4732,7 +4732,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
>   	file_info->EndOfFile = cpu_to_le64(inode->i_size);
>   	file_info->AllocationSize = cpu_to_le64(inode->i_blocks << 9);
>   	file_info->HardLinks = cpu_to_le32(inode->i_nlink);
> -	file_info->Mode = cpu_to_le32(inode->i_mode);
> +	file_info->Mode = cpu_to_le32(inode->i_mode & 0777);
>   	file_info->DeviceId = cpu_to_le32(inode->i_rdev);
>   	rsp->OutputBufferLength =
>   		cpu_to_le32(sizeof(struct smb311_posix_qinfo));
diff mbox series

Patch

diff --git a/fs/ksmbd/oplock.c b/fs/ksmbd/oplock.c
index c26f02086783..9bfd1ef6debd 100644
--- a/fs/ksmbd/oplock.c
+++ b/fs/ksmbd/oplock.c
@@ -1640,7 +1640,7 @@  void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
 
 	buf->nlink = cpu_to_le32(inode->i_nlink);
 	buf->reparse_tag = cpu_to_le32(fp->volatile_id);
-	buf->mode = cpu_to_le32(inode->i_mode);
+	buf->mode = cpu_to_le32(inode->i_mode & 0777);
 	id_to_sid(from_kuid_munged(&init_user_ns, vfsuid_into_kuid(vfsuid)),
 		  SIDOWNER, (struct smb_sid *)&buf->SidBuffer[0]);
 	id_to_sid(from_kgid_munged(&init_user_ns, vfsgid_into_kgid(vfsgid)),
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index bc6c7ce17ea8..5c797cc09494 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -3565,7 +3565,7 @@  static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
 		posix_info->AllocationSize = cpu_to_le64(ksmbd_kstat->kstat->blocks << 9);
 		posix_info->DeviceId = cpu_to_le32(ksmbd_kstat->kstat->rdev);
 		posix_info->HardLinks = cpu_to_le32(ksmbd_kstat->kstat->nlink);
-		posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode);
+		posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode & 0777);
 		posix_info->Inode = cpu_to_le64(ksmbd_kstat->kstat->ino);
 		posix_info->DosAttributes =
 			S_ISDIR(ksmbd_kstat->kstat->mode) ?
@@ -4732,7 +4732,7 @@  static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
 	file_info->EndOfFile = cpu_to_le64(inode->i_size);
 	file_info->AllocationSize = cpu_to_le64(inode->i_blocks << 9);
 	file_info->HardLinks = cpu_to_le32(inode->i_nlink);
-	file_info->Mode = cpu_to_le32(inode->i_mode);
+	file_info->Mode = cpu_to_le32(inode->i_mode & 0777);
 	file_info->DeviceId = cpu_to_le32(inode->i_rdev);
 	rsp->OutputBufferLength =
 		cpu_to_le32(sizeof(struct smb311_posix_qinfo));