Skip to content

Commit f65289a

Browse files
committed
Merge tag 'v6.13-rc1-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - Three fixes for potential out of bound accesses in read and write paths (e.g. when alternate data streams enabled) - GCC 15 build fix * tag 'v6.13-rc1-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: align aux_payload_buf to avoid OOB reads in cryptographic operations ksmbd: fix Out-of-Bounds Write in ksmbd_vfs_stream_write ksmbd: fix Out-of-Bounds Read in ksmbd_vfs_stream_read smb: server: Fix building with GCC 15
2 parents 896d894 + 06a0254 commit f65289a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6663,6 +6663,10 @@ int smb2_read(struct ksmbd_work *work)
66636663
}
66646664

66656665
offset = le64_to_cpu(req->Offset);
6666+
if (offset < 0) {
6667+
err = -EINVAL;
6668+
goto out;
6669+
}
66666670
length = le32_to_cpu(req->Length);
66676671
mincount = le32_to_cpu(req->MinimumCount);
66686672

@@ -6676,7 +6680,7 @@ int smb2_read(struct ksmbd_work *work)
66766680
ksmbd_debug(SMB, "filename %pD, offset %lld, len %zu\n",
66776681
fp->filp, offset, length);
66786682

6679-
aux_payload_buf = kvzalloc(length, KSMBD_DEFAULT_GFP);
6683+
aux_payload_buf = kvzalloc(ALIGN(length, 8), KSMBD_DEFAULT_GFP);
66806684
if (!aux_payload_buf) {
66816685
err = -ENOMEM;
66826686
goto out;
@@ -6878,6 +6882,8 @@ int smb2_write(struct ksmbd_work *work)
68786882
}
68796883

68806884
offset = le64_to_cpu(req->Offset);
6885+
if (offset < 0)
6886+
return -EINVAL;
68816887
length = le32_to_cpu(req->Length);
68826888

68836889
if (req->Channel == SMB2_CHANNEL_RDMA_V1 ||

fs/smb/server/smb_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "mgmt/share_config.h"
1919

2020
/*for shortname implementation */
21-
static const char basechars[43] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
22-
#define MANGLE_BASE (sizeof(basechars) / sizeof(char) - 1)
21+
static const char *basechars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
22+
#define MANGLE_BASE (strlen(basechars) - 1)
2323
#define MAGIC_CHAR '~'
2424
#define PERIOD '.'
2525
#define mangle(V) ((char)(basechars[(V) % MANGLE_BASE]))

0 commit comments

Comments
 (0)