Skip to content

Commit 1a2ab0f

Browse files
committed
Merge tag 'v7.1-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - Fix two null pointer dereferences and a memory leak * tag 'v7.1-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: fix null pointer dereference in compare_guid_key() ksmbd: fix null pointer dereference in proc_show_files() ksmbd: fix SID memory leak in set_posix_acl_entries_dacl() on overflow
2 parents 0c0b282 + 4b83cbc commit 1a2ab0f

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

fs/smb/server/oplock.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,12 @@ static inline int compare_guid_key(struct oplock_info *opinfo,
481481
const char *guid1, const char *key1)
482482
{
483483
const char *guid2, *key2;
484+
struct ksmbd_conn *conn;
484485

485-
guid2 = opinfo->conn->ClientGUID;
486+
conn = READ_ONCE(opinfo->conn);
487+
if (!conn)
488+
return 0;
489+
guid2 = conn->ClientGUID;
486490
key2 = opinfo->o_lease->lease_key;
487491
if (!memcmp(guid1, guid2, SMB2_CLIENT_GUID_SIZE) &&
488492
!memcmp(key1, key2, SMB2_LEASE_KEY_SIZE))

fs/smb/server/smbacl.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,10 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
643643
ntace = (struct smb_ace *)((char *)pndace + *size);
644644
ace_sz = fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, flags,
645645
pace->e_perm, 0777);
646-
if (check_add_overflow(*size, ace_sz, size))
646+
if (check_add_overflow(*size, ace_sz, size)) {
647+
kfree(sid);
647648
break;
649+
}
648650
(*num_aces)++;
649651
if (pace->e_tag == ACL_USER)
650652
ntace->access_req |=
@@ -655,8 +657,10 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
655657
ntace = (struct smb_ace *)((char *)pndace + *size);
656658
ace_sz = fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED,
657659
0x03, pace->e_perm, 0777);
658-
if (check_add_overflow(*size, ace_sz, size))
660+
if (check_add_overflow(*size, ace_sz, size)) {
661+
kfree(sid);
659662
break;
663+
}
660664
(*num_aces)++;
661665
if (pace->e_tag == ACL_USER)
662666
ntace->access_req |=
@@ -698,8 +702,10 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
698702
ntace = (struct smb_ace *)((char *)pndace + *size);
699703
ace_sz = fill_ace_for_sid(ntace, sid, ACCESS_ALLOWED, 0x0b,
700704
pace->e_perm, 0777);
701-
if (check_add_overflow(*size, ace_sz, size))
705+
if (check_add_overflow(*size, ace_sz, size)) {
706+
kfree(sid);
702707
break;
708+
}
703709
(*num_aces)++;
704710
if (pace->e_tag == ACL_USER)
705711
ntace->access_req |=

fs/smb/server/vfs_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int proc_show_files(struct seq_file *m, void *v)
8181
read_lock(&global_ft.lock);
8282
idr_for_each_entry(global_ft.idr, fp, id) {
8383
seq_printf(m, "%#-10x %#-10llx %#-10llx %#-10x",
84-
fp->tcon->id,
84+
fp->tcon ? fp->tcon->id : 0,
8585
fp->persistent_id,
8686
fp->volatile_id,
8787
atomic_read(&fp->refcount));

0 commit comments

Comments
 (0)