All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ksmbd: fix SMB 3.11 posix extension mount failure
@ 2022-01-22  1:47 Namjae Jeon
  2022-01-22  5:00 ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2022-01-22  1:47 UTC (permalink / raw)
  To: linux-cifs; +Cc: Namjae Jeon, stable, Steve French

cifs client set 4 to DataLength of create_posix context, which mean
Mode variable of create_posix context is only available. So buffer
validation of ksmbd should check only the size of Mode except for
the size of Reserved variable.

Fixes: 8f77150c15f8 ("ksmbd: add buffer validation for SMB2_CREATE_CONTEXT")
Cc: stable@vger.kernel.org # v5.15+
Reported-by: Steve French <smfrench@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ksmbd/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index 1866c81c5c99..3926ca18dca4 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -2688,7 +2688,7 @@ int smb2_open(struct ksmbd_work *work)
 					(struct create_posix *)context;
 				if (le16_to_cpu(context->DataOffset) +
 				    le32_to_cpu(context->DataLength) <
-				    sizeof(struct create_posix)) {
+				    sizeof(struct create_posix) - 4) {
 					rc = -EINVAL;
 					goto err_out1;
 				}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ksmbd: fix SMB 3.11 posix extension mount failure
  2022-01-22  1:47 [PATCH] ksmbd: fix SMB 3.11 posix extension mount failure Namjae Jeon
@ 2022-01-22  5:00 ` Steve French
  2022-01-23  0:53   ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2022-01-22  5:00 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: CIFS, Stable

Looks good.  I tested it and it works.

With this I can see some additional things work e.g. "stat /mnt/file"
shows the correct mode bits, but the owner and group are reported as
the default (0) instead of the actual uid/gid

On Fri, Jan 21, 2022 at 7:47 PM Namjae Jeon <linkinjeon@kernel.org> wrote:
>
> cifs client set 4 to DataLength of create_posix context, which mean
> Mode variable of create_posix context is only available. So buffer
> validation of ksmbd should check only the size of Mode except for
> the size of Reserved variable.
>
> Fixes: 8f77150c15f8 ("ksmbd: add buffer validation for SMB2_CREATE_CONTEXT")
> Cc: stable@vger.kernel.org # v5.15+
> Reported-by: Steve French <smfrench@gmail.com>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> ---
>  fs/ksmbd/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index 1866c81c5c99..3926ca18dca4 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -2688,7 +2688,7 @@ int smb2_open(struct ksmbd_work *work)
>                                         (struct create_posix *)context;
>                                 if (le16_to_cpu(context->DataOffset) +
>                                     le32_to_cpu(context->DataLength) <
> -                                   sizeof(struct create_posix)) {
> +                                   sizeof(struct create_posix) - 4) {
>                                         rc = -EINVAL;
>                                         goto err_out1;
>                                 }
> --
> 2.25.1
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ksmbd: fix SMB 3.11 posix extension mount failure
  2022-01-22  5:00 ` Steve French
@ 2022-01-23  0:53   ` Namjae Jeon
  0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2022-01-23  0:53 UTC (permalink / raw)
  To: Steve French; +Cc: CIFS, Stable

2022-01-22 14:00 GMT+09:00, Steve French <smfrench@gmail.com>:
> Looks good.  I tested it and it works.
>
> With this I can see some additional things work e.g. "stat /mnt/file"
> shows the correct mode bits, but the owner and group are reported as
> the default (0) instead of the actual uid/gid
As we discussed on chat, we need to implement code to handle Sids[] in
smb311_posix_qinfo on both ksmbd and cifs.

fattr->cf_uid = cifs_sb->ctx->linux_uid; /* TODO: map uid and gid from SID */
fattr->cf_gid = cifs_sb->ctx->linux_gid;

cifs client doesn't handle Sids[] from server. Instead, cifs client
seems to use uid/gid from mount option. So the uid/gid will appear as
0. And I will also change ksmbd to set uid/gid to Sid in
smb311_posix_qinfo.

Thanks!
>
> On Fri, Jan 21, 2022 at 7:47 PM Namjae Jeon <linkinjeon@kernel.org> wrote:
>>
>> cifs client set 4 to DataLength of create_posix context, which mean
>> Mode variable of create_posix context is only available. So buffer
>> validation of ksmbd should check only the size of Mode except for
>> the size of Reserved variable.
>>
>> Fixes: 8f77150c15f8 ("ksmbd: add buffer validation for
>> SMB2_CREATE_CONTEXT")
>> Cc: stable@vger.kernel.org # v5.15+
>> Reported-by: Steve French <smfrench@gmail.com>
>> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
>> ---
>>  fs/ksmbd/smb2pdu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
>> index 1866c81c5c99..3926ca18dca4 100644
>> --- a/fs/ksmbd/smb2pdu.c
>> +++ b/fs/ksmbd/smb2pdu.c
>> @@ -2688,7 +2688,7 @@ int smb2_open(struct ksmbd_work *work)
>>                                         (struct create_posix *)context;
>>                                 if (le16_to_cpu(context->DataOffset) +
>>                                     le32_to_cpu(context->DataLength) <
>> -                                   sizeof(struct create_posix)) {
>> +                                   sizeof(struct create_posix) - 4) {
>>                                         rc = -EINVAL;
>>                                         goto err_out1;
>>                                 }
>> --
>> 2.25.1
>>
>
>
> --
> Thanks,
>
> Steve
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-23  0:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22  1:47 [PATCH] ksmbd: fix SMB 3.11 posix extension mount failure Namjae Jeon
2022-01-22  5:00 ` Steve French
2022-01-23  0:53   ` Namjae Jeon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.