Skip to content

Commit 4963d74

Browse files
atheiksmfrench
authored andcommitted
ksmbd: request update to stale share config
ksmbd_share_config_get() retrieves the cached share config as long as there is at least one connection to the share. This is an issue when the user space utilities are used to update share configs. In that case there is a need to inform ksmbd that it should not use the cached share config for a new connection to the share. With these changes the tree connection flag KSMBD_TREE_CONN_FLAG_UPDATE indicates this. When this flag is set, ksmbd removes the share config from the shares hash table meaning that ksmbd_share_config_get() ends up requesting a share config from user space. Signed-off-by: Atte Heikkilä <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent fe54833 commit 4963d74

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

fs/ksmbd/ksmbd_netlink.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ enum KSMBD_TREE_CONN_STATUS {
349349
#define KSMBD_SHARE_FLAG_STREAMS BIT(11)
350350
#define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS BIT(12)
351351
#define KSMBD_SHARE_FLAG_ACL_XATTR BIT(13)
352+
#define KSMBD_SHARE_FLAG_UPDATE BIT(14)
352353

353354
/*
354355
* Tree connect request flags.
@@ -364,6 +365,7 @@ enum KSMBD_TREE_CONN_STATUS {
364365
#define KSMBD_TREE_CONN_FLAG_READ_ONLY BIT(1)
365366
#define KSMBD_TREE_CONN_FLAG_WRITABLE BIT(2)
366367
#define KSMBD_TREE_CONN_FLAG_ADMIN_ACCOUNT BIT(3)
368+
#define KSMBD_TREE_CONN_FLAG_UPDATE BIT(4)
367369

368370
/*
369371
* RPC over IPC.

fs/ksmbd/mgmt/share_config.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ static void kill_share(struct ksmbd_share_config *share)
5151
kfree(share);
5252
}
5353

54-
void __ksmbd_share_config_put(struct ksmbd_share_config *share)
54+
void ksmbd_share_config_del(struct ksmbd_share_config *share)
5555
{
5656
down_write(&shares_table_lock);
5757
hash_del(&share->hlist);
5858
up_write(&shares_table_lock);
59+
}
5960

61+
void __ksmbd_share_config_put(struct ksmbd_share_config *share)
62+
{
63+
ksmbd_share_config_del(share);
6064
kill_share(share);
6165
}
6266

fs/ksmbd/mgmt/share_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static inline int test_share_config_flag(struct ksmbd_share_config *share,
6464
return share->flags & flag;
6565
}
6666

67+
void ksmbd_share_config_del(struct ksmbd_share_config *share);
6768
void __ksmbd_share_config_put(struct ksmbd_share_config *share);
6869

6970
static inline void ksmbd_share_config_put(struct ksmbd_share_config *share)

fs/ksmbd/mgmt/tree_connect.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ ksmbd_tree_conn_connect(struct ksmbd_conn *conn, struct ksmbd_session *sess,
5757
goto out_error;
5858

5959
tree_conn->flags = resp->connection_flags;
60+
if (test_tree_conn_flag(tree_conn, KSMBD_TREE_CONN_FLAG_UPDATE)) {
61+
struct ksmbd_share_config *new_sc;
62+
63+
ksmbd_share_config_del(sc);
64+
new_sc = ksmbd_share_config_get(share_name);
65+
if (!new_sc) {
66+
pr_err("Failed to update stale share config\n");
67+
status.ret = -ESTALE;
68+
goto out_error;
69+
}
70+
ksmbd_share_config_put(sc);
71+
sc = new_sc;
72+
}
73+
6074
tree_conn->user = sess->user;
6175
tree_conn->share_conf = sc;
6276
status.tree_conn = tree_conn;

fs/ksmbd/smb2pdu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ int smb2_tree_connect(struct ksmbd_work *work)
19441944
rsp->hdr.Status = STATUS_SUCCESS;
19451945
rc = 0;
19461946
break;
1947+
case -ESTALE:
19471948
case -ENOENT:
19481949
case KSMBD_TREE_CONN_STATUS_NO_SHARE:
19491950
rsp->hdr.Status = STATUS_BAD_NETWORK_NAME;

0 commit comments

Comments
 (0)