Skip to content

Conversation

@socram8888
Copy link

According to the official Microsoft MS-SMB2 document section 3.3.5.4, this
flag should be used only for 3.0 and 3.0.2 dialects. Setting it for 3.1.1 is
a violation of the specification.

This caused Windows 10 to detect a mistake in the protocol, and disable
encryption despite being enabled in the settings.

@hclee
Copy link
Member

hclee commented Dec 15, 2021

Could you send this patch to [email protected]?
And the prefix, "ksmbd: " has to be added to the commit title.

conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING;

if (conn->cipher_type)
conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the root cause of your encryption problem?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, Looks great!

smb2pdu.c Outdated
* SMB 3.1.1 uses the cipher_type field.
*/
encrequested = conn->cipher_type ||
(conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to use encrequested variable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created the variable to make clearer the conditions on which the encryption applied, since there were already a sizeable amount of operands in the if statement.

Mixing complex and, ors and bit-twiddling in the same if would be a big no for me since it requires thinking about C's operand priorities, but if you'd prefer I can change it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the logic into a function, which makes it IMHO clearer and reduces duplicate code.

I'll send it now to the LKML for further review.

According to the official Microsoft MS-SMB2 document section 3.3.5.4, this
flag should be used only for 3.0 and 3.0.2 dialects. Setting it for 3.1.1 is
a violation of the specification.
*
* Return: true if should be encrypted, else false
*/
static bool should_encrypt(struct ksmbd_conn *conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this naming sense. how about smb3_encryption_negotiated()

@socram8888
Copy link
Author

I've just sent the patch to the LKML, so I am gonna close this PR :)

@socram8888 socram8888 closed this Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants