Skip to content

Commit e0f8e1a

Browse files
committed
Merge tag 'v6.15-rc8-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - Fix for rename regression due to the recent VFS lookup changes - Fix write failure - locking fix for oplock handling * tag 'v6.15-rc8-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: use list_first_entry_or_null for opinfo_get_list() ksmbd: fix rename failure ksmbd: fix stream write failure
2 parents 3d0ebc3 + 1037917 commit e0f8e1a

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

fs/smb/server/oplock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,9 @@ static struct oplock_info *opinfo_get_list(struct ksmbd_inode *ci)
146146
{
147147
struct oplock_info *opinfo;
148148

149-
if (list_empty(&ci->m_op_list))
150-
return NULL;
151-
152149
down_read(&ci->m_lock);
153-
opinfo = list_first_entry(&ci->m_op_list, struct oplock_info,
154-
op_entry);
150+
opinfo = list_first_entry_or_null(&ci->m_op_list, struct oplock_info,
151+
op_entry);
155152
if (opinfo) {
156153
if (opinfo->conn == NULL ||
157154
!atomic_inc_not_zero(&opinfo->refcount))

fs/smb/server/vfs.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,15 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
409409
ksmbd_debug(VFS, "write stream data pos : %llu, count : %zd\n",
410410
*pos, count);
411411

412+
if (*pos >= XATTR_SIZE_MAX) {
413+
pr_err("stream write position %lld is out of bounds\n", *pos);
414+
return -EINVAL;
415+
}
416+
412417
size = *pos + count;
413418
if (size > XATTR_SIZE_MAX) {
414419
size = XATTR_SIZE_MAX;
415-
count = (*pos + count) - XATTR_SIZE_MAX;
420+
count = XATTR_SIZE_MAX - *pos;
416421
}
417422

418423
v_len = ksmbd_vfs_getcasexattr(idmap,
@@ -426,13 +431,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
426431
goto out;
427432
}
428433

429-
if (v_len <= *pos) {
430-
pr_err("stream write position %lld is out of bounds (stream length: %zd)\n",
431-
*pos, v_len);
432-
err = -EINVAL;
433-
goto out;
434-
}
435-
436434
if (v_len < size) {
437435
wbuf = kvzalloc(size, KSMBD_DEFAULT_GFP);
438436
if (!wbuf) {
@@ -684,7 +682,7 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
684682
struct ksmbd_file *parent_fp;
685683
int new_type;
686684
int err, lookup_flags = LOOKUP_NO_SYMLINKS;
687-
int target_lookup_flags = LOOKUP_RENAME_TARGET;
685+
int target_lookup_flags = LOOKUP_RENAME_TARGET | LOOKUP_CREATE;
688686

689687
if (ksmbd_override_fsids(work))
690688
return -ENOMEM;

0 commit comments

Comments
 (0)