mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
864fb5d371
[ 8743.393379] ======================================================
[ 8743.393385] WARNING: possible circular locking dependency detected
[ 8743.393391] 6.4.0-rc1+ #11 Tainted: G OE
[ 8743.393397] ------------------------------------------------------
[ 8743.393402] kworker/0:2/12921 is trying to acquire lock:
[ 8743.393408] ffff888127a14460 (sb_writers#8){.+.+}-{0:0}, at: ksmbd_vfs_setxattr+0x3d/0xd0 [ksmbd]
[ 8743.393510]
but task is already holding lock:
[ 8743.393515] ffff8880360d97f0 (&type->i_mutex_dir_key#6/1){+.+.}-{3:3}, at: ksmbd_vfs_kern_path_locked+0x181/0x670 [ksmbd]
[ 8743.393618]
which lock already depends on the new lock.
[ 8743.393623]
the existing dependency chain (in reverse order) is:
[ 8743.393628]
-> #1 (&type->i_mutex_dir_key#6/1){+.+.}-{3:3}:
[ 8743.393648] down_write_nested+0x9a/0x1b0
[ 8743.393660] filename_create+0x128/0x270
[ 8743.393670] do_mkdirat+0xab/0x1f0
[ 8743.393680] __x64_sys_mkdir+0x47/0x60
[ 8743.393690] do_syscall_64+0x5d/0x90
[ 8743.393701] entry_SYSCALL_64_after_hwframe+0x72/0xdc
[ 8743.393711]
-> #0 (sb_writers#8){.+.+}-{0:0}:
[ 8743.393728] __lock_acquire+0x2201/0x3b80
[ 8743.393737] lock_acquire+0x18f/0x440
[ 8743.393746] mnt_want_write+0x5f/0x240
[ 8743.393755] ksmbd_vfs_setxattr+0x3d/0xd0 [ksmbd]
[ 8743.393839] ksmbd_vfs_set_dos_attrib_xattr+0xcc/0x110 [ksmbd]
[ 8743.393924] compat_ksmbd_vfs_set_dos_attrib_xattr+0x39/0x50 [ksmbd]
[ 8743.394010] smb2_open+0x3432/0x3cc0 [ksmbd]
[ 8743.394099] handle_ksmbd_work+0x2c9/0x7b0 [ksmbd]
[ 8743.394187] process_one_work+0x65a/0xb30
[ 8743.394198] worker_thread+0x2cf/0x700
[ 8743.394209] kthread+0x1ad/0x1f0
[ 8743.394218] ret_from_fork+0x29/0x50
This patch add mnt_want_write() above parent inode lock and remove
nested mnt_want_write calls in smb2_open().
Fixes: 40b268d384
("ksmbd: add mnt_want_write to ksmbd vfs functions")
Cc: stable@vger.kernel.org
Reported-by: Marios Makassikis <mmakassikis@freebox.fr>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
168 lines
5.8 KiB
C
168 lines
5.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2016 Namjae Jeon <linkinjeon@kernel.org>
|
|
* Copyright (C) 2018 Samsung Electronics Co., Ltd.
|
|
*/
|
|
|
|
#ifndef __KSMBD_VFS_H__
|
|
#define __KSMBD_VFS_H__
|
|
|
|
#include <linux/file.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/namei.h>
|
|
#include <uapi/linux/xattr.h>
|
|
#include <linux/posix_acl.h>
|
|
#include <linux/unicode.h>
|
|
|
|
#include "smbacl.h"
|
|
#include "xattr.h"
|
|
|
|
/*
|
|
* Enumeration for stream type.
|
|
*/
|
|
enum {
|
|
DATA_STREAM = 1, /* type $DATA */
|
|
DIR_STREAM /* type $INDEX_ALLOCATION */
|
|
};
|
|
|
|
/* CreateOptions */
|
|
#define CREATE_TREE_CONNECTION cpu_to_le32(0x00000080)
|
|
#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
|
|
|
|
#define CREATE_OPTION_READONLY 0x10000000
|
|
/* system. NB not sent over wire */
|
|
#define CREATE_OPTION_SPECIAL 0x20000000
|
|
|
|
struct ksmbd_work;
|
|
struct ksmbd_file;
|
|
struct ksmbd_conn;
|
|
|
|
struct ksmbd_dir_info {
|
|
const char *name;
|
|
char *wptr;
|
|
char *rptr;
|
|
int name_len;
|
|
int out_buf_len;
|
|
int num_entry;
|
|
int data_count;
|
|
int last_entry_offset;
|
|
bool hide_dot_file;
|
|
int flags;
|
|
int last_entry_off_align;
|
|
};
|
|
|
|
struct ksmbd_readdir_data {
|
|
struct dir_context ctx;
|
|
union {
|
|
void *private;
|
|
char *dirent;
|
|
};
|
|
|
|
unsigned int used;
|
|
unsigned int dirent_count;
|
|
unsigned int file_attr;
|
|
struct unicode_map *um;
|
|
};
|
|
|
|
/* ksmbd kstat wrapper to get valid create time when reading dir entry */
|
|
struct ksmbd_kstat {
|
|
struct kstat *kstat;
|
|
unsigned long long create_time;
|
|
__le32 file_attributes;
|
|
};
|
|
|
|
int ksmbd_vfs_lock_parent(struct dentry *parent, struct dentry *child);
|
|
void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
|
|
struct dentry *dentry, __le32 *daccess);
|
|
int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode);
|
|
int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode);
|
|
int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
|
|
loff_t *pos, char *rbuf);
|
|
int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,
|
|
char *buf, size_t count, loff_t *pos, bool sync,
|
|
ssize_t *written);
|
|
int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id);
|
|
int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path);
|
|
int ksmbd_vfs_link(struct ksmbd_work *work,
|
|
const char *oldname, const char *newname);
|
|
int ksmbd_vfs_getattr(const struct path *path, struct kstat *stat);
|
|
int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
|
|
char *newname, int flags);
|
|
int ksmbd_vfs_truncate(struct ksmbd_work *work,
|
|
struct ksmbd_file *fp, loff_t size);
|
|
struct srv_copychunk;
|
|
int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
|
|
struct ksmbd_file *src_fp,
|
|
struct ksmbd_file *dst_fp,
|
|
struct srv_copychunk *chunks,
|
|
unsigned int chunk_count,
|
|
unsigned int *chunk_count_written,
|
|
unsigned int *chunk_size_written,
|
|
loff_t *total_size_written);
|
|
ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
|
|
ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
|
|
struct dentry *dentry,
|
|
char *xattr_name,
|
|
char **xattr_buf);
|
|
ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
|
|
struct dentry *dentry, char *attr_name,
|
|
int attr_name_len);
|
|
int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
|
|
const struct path *path, const char *attr_name,
|
|
void *attr_value, size_t attr_size, int flags,
|
|
bool get_write);
|
|
int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
|
|
size_t *xattr_stream_name_size, int s_type);
|
|
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
|
|
const struct path *path, char *attr_name);
|
|
int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
|
|
unsigned int flags, struct path *parent_path,
|
|
struct path *path, bool caseless);
|
|
void ksmbd_vfs_kern_path_unlock(struct path *parent_path, struct path *path);
|
|
struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
|
|
const char *name,
|
|
unsigned int flags,
|
|
struct path *path);
|
|
int ksmbd_vfs_empty_dir(struct ksmbd_file *fp);
|
|
void ksmbd_vfs_set_fadvise(struct file *filp, __le32 option);
|
|
int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,
|
|
loff_t off, loff_t len);
|
|
struct file_allocated_range_buffer;
|
|
int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
|
|
struct file_allocated_range_buffer *ranges,
|
|
unsigned int in_count, unsigned int *out_count);
|
|
int ksmbd_vfs_unlink(struct file *filp);
|
|
void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
|
|
int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
|
|
struct mnt_idmap *idmap,
|
|
struct dentry *dentry,
|
|
struct ksmbd_kstat *ksmbd_kstat);
|
|
void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
|
|
int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout);
|
|
void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
|
|
int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
|
|
const struct path *path);
|
|
int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path);
|
|
int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
|
|
struct mnt_idmap *idmap,
|
|
const struct path *path,
|
|
struct smb_ntsd *pntsd, int len,
|
|
bool get_write);
|
|
int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
|
|
struct mnt_idmap *idmap,
|
|
struct dentry *dentry,
|
|
struct smb_ntsd **pntsd);
|
|
int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
|
|
const struct path *path,
|
|
struct xattr_dos_attrib *da,
|
|
bool get_write);
|
|
int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
|
|
struct dentry *dentry,
|
|
struct xattr_dos_attrib *da);
|
|
int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
|
|
struct path *path);
|
|
int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
|
|
struct path *path,
|
|
struct inode *parent_inode);
|
|
#endif /* __KSMBD_VFS_H__ */
|