Skip to content

Commit 1b5487a

Browse files
author
Steve French
committed
smb3: fix setting SecurityFlags when encryption is required
Setting encryption as required in security flags was broken. For example (to require all mounts to be encrypted by setting): "echo 0x400c5 > /proc/fs/cifs/SecurityFlags" Would return "Invalid argument" and log "Unsupported security flags" This patch fixes that (e.g. allowing overriding the default for SecurityFlags 0x00c5, including 0x40000 to require seal, ie SMB3.1.1 encryption) so now that works and forces encryption on subsequent mounts. Acked-by: Bharath SM <bharathsm@microsoft.com> Cc: stable@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent de9c2c6 commit 1b5487a

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Documentation/admin-guide/cifs/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ SecurityFlags Flags which control security negotiation and
742742
may use NTLMSSP 0x00080
743743
must use NTLMSSP 0x80080
744744
seal (packet encryption) 0x00040
745-
must seal (not implemented yet) 0x40040
745+
must seal 0x40040
746746

747747
cifsFYI If set to non-zero value, additional debug information
748748
will be logged to the system error log. This field

fs/smb/client/cifs_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
10721072
static void
10731073
cifs_security_flags_handle_must_flags(unsigned int *flags)
10741074
{
1075-
unsigned int signflags = *flags & CIFSSEC_MUST_SIGN;
1075+
unsigned int signflags = *flags & (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_SEAL);
10761076

10771077
if ((*flags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
10781078
*flags = CIFSSEC_MUST_KRB5;

fs/smb/client/cifsglob.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ static inline bool is_replayable_error(int error)
18811881
#define CIFSSEC_MAY_SIGN 0x00001
18821882
#define CIFSSEC_MAY_NTLMV2 0x00004
18831883
#define CIFSSEC_MAY_KRB5 0x00008
1884-
#define CIFSSEC_MAY_SEAL 0x00040 /* not supported yet */
1884+
#define CIFSSEC_MAY_SEAL 0x00040
18851885
#define CIFSSEC_MAY_NTLMSSP 0x00080 /* raw ntlmssp with ntlmv2 */
18861886

18871887
#define CIFSSEC_MUST_SIGN 0x01001
@@ -1891,11 +1891,11 @@ require use of the stronger protocol */
18911891
#define CIFSSEC_MUST_NTLMV2 0x04004
18921892
#define CIFSSEC_MUST_KRB5 0x08008
18931893
#ifdef CONFIG_CIFS_UPCALL
1894-
#define CIFSSEC_MASK 0x8F08F /* flags supported if no weak allowed */
1894+
#define CIFSSEC_MASK 0xCF0CF /* flags supported if no weak allowed */
18951895
#else
1896-
#define CIFSSEC_MASK 0x87087 /* flags supported if no weak allowed */
1896+
#define CIFSSEC_MASK 0xC70C7 /* flags supported if no weak allowed */
18971897
#endif /* UPCALL */
1898-
#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */
1898+
#define CIFSSEC_MUST_SEAL 0x40040
18991899
#define CIFSSEC_MUST_NTLMSSP 0x80080 /* raw ntlmssp with ntlmv2 */
19001900

19011901
#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP | CIFSSEC_MAY_SEAL)

fs/smb/client/smb2pdu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ int smb3_encryption_required(const struct cifs_tcon *tcon)
8282
if (tcon->seal &&
8383
(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
8484
return 1;
85+
if (((global_secflags & CIFSSEC_MUST_SEAL) == CIFSSEC_MUST_SEAL) &&
86+
(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
87+
return 1;
8588
return 0;
8689
}
8790

0 commit comments

Comments
 (0)