cifs: nosharesock should not share socket with future sessions
authorShyam Prasad N <sprasad@microsoft.com>
Sat, 6 Nov 2021 11:31:53 +0000 (11:31 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:04:55 +0000 (09:04 +0100)
[ Upstream commit c9f1c19cf7c50949885fa5afdb2cb242d61a7fac ]

Today, when a new mount is done with nosharesock, we ensure
that we don't select an existing matching session. However,
we don't mark the connection as nosharesock, which means that
those could be shared with future sessions.

Fixed it with this commit. Also printing this info in DebugData.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/cifs_debug.c
fs/cifs/cifsglob.h
fs/cifs/connect.c

index de2c12bcfa4bc62b715065a7a5d4bd9a397f9bb1..905a901f7f80b9af3b68dcbedb00afc07066ba01 100644 (file)
@@ -358,6 +358,8 @@ skip_rdma:
                        seq_printf(m, " signed");
                if (server->posix_ext_supported)
                        seq_printf(m, " posix");
+               if (server->nosharesock)
+                       seq_printf(m, " nosharesock");
 
                if (server->rdma)
                        seq_printf(m, "\nRDMA ");
index dea4c929d3f46e592fb19917817c2915f8efbdbd..3e5b8e177cfa78737303e8db35525a78e17b25cb 100644 (file)
@@ -592,6 +592,7 @@ struct TCP_Server_Info {
        struct list_head pending_mid_q;
        bool noblocksnd;                /* use blocking sendmsg */
        bool noautotune;                /* do not autotune send buf sizes */
+       bool nosharesock;
        bool tcp_nodelay;
        unsigned int credits;  /* send no more requests at once */
        unsigned int max_credits; /* can override large 32000 default at mnt */
index e757ee52cc7777e60568c113938184085eb53a81..d26703a05c6b44bdfee72b854b8f09f8b1626c8d 100644 (file)
@@ -1217,7 +1217,13 @@ static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context *
 {
        struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr;
 
-       if (ctx->nosharesock)
+       if (ctx->nosharesock) {
+               server->nosharesock = true;
+               return 0;
+       }
+
+       /* this server does not share socket */
+       if (server->nosharesock)
                return 0;
 
        /* If multidialect negotiation see if existing sessions match one */