diff options
author | Paulo Alcantara <pc@manguebit.com> | 2023-04-26 19:43:53 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2023-05-04 07:29:39 +0300 |
commit | 3dc9c433c9dde15477d02b609ccb4328e2adb6dc (patch) | |
tree | d097b78d406ba5b6324c3e732ce8aebfc6aa4440 /fs/cifs/dfs.h | |
parent | ee20d7c6100752eaf2409d783f4f1449c29ea33d (diff) | |
download | linux-3dc9c433c9dde15477d02b609ccb4328e2adb6dc.tar.xz |
cifs: protect access of TCP_Server_Info::{origin,leaf}_fullpath
Protect access of TCP_Server_Info::{origin,leaf}_fullpath when
matching DFS connections, and get rid of
TCP_Server_Info::current_fullpath while we're at it.
Cc: stable@vger.kernel.org # v6.2+
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/dfs.h')
-rw-r--r-- | fs/cifs/dfs.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/cifs/dfs.h b/fs/cifs/dfs.h index 0b8cbf721fff..1c90df5ecfbd 100644 --- a/fs/cifs/dfs.h +++ b/fs/cifs/dfs.h @@ -43,8 +43,12 @@ static inline char *dfs_get_automount_devname(struct dentry *dentry, void *page) size_t len; char *s; - if (unlikely(!server->origin_fullpath)) + spin_lock(&server->srv_lock); + if (unlikely(!server->origin_fullpath)) { + spin_unlock(&server->srv_lock); return ERR_PTR(-EREMOTE); + } + spin_unlock(&server->srv_lock); s = dentry_path_raw(dentry, page, PATH_MAX); if (IS_ERR(s)) @@ -53,13 +57,18 @@ static inline char *dfs_get_automount_devname(struct dentry *dentry, void *page) if (!s[1]) s++; + spin_lock(&server->srv_lock); len = strlen(server->origin_fullpath); - if (s < (char *)page + len) + if (s < (char *)page + len) { + spin_unlock(&server->srv_lock); return ERR_PTR(-ENAMETOOLONG); + } s -= len; memcpy(s, server->origin_fullpath, len); + spin_unlock(&server->srv_lock); convert_delimiter(s, '/'); + return s; } |