Merge tag 'ksmbd-for-7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/smb

Pull smb server updates from Namjae Jeon:

 - Validate EA-name NUL termination to prevent out-of-bounds reads in
   debug logging. Return STATUS_EA_LIST_INCONSISTENT for malformed EA
   names in CREATE and SET_INFO requests.

 - Grant the owner's implicit READ_CONTROL and WRITE_DAC rights when no
   ACE names it, including MAXIMUM_ALLOWED handling, while respecting
   applicable OWNER RIGHTS ACEs.

 - Check group membership before granting permissions from a POSIX ACL
   group entry, preventing unintended access when a caller's UID matches
   the group's numeric GID.

 - Avoid reading past the DACL when logging an access denial by printing
   the requested and allowed access masks instead.

 - Handle unauthenticated sessions in procfs reporting without
   dereferencing a NULL session->user.

 - Fix credential cleanup on attribute lookup failures during durable
   handle reconnect or request replay, preventing subsequent requests
   from running with another user's credentials.

 - Fix read-only share handling for named stream creation, including
   AFP_AfpInfo synthesis on Time Machine shares.

 - Validate DELETE access for FILE_DELETE_ON_CLOSE opens, including
   MAXIMUM_ALLOWED handling, to prevent unauthorized deletion or
   delete-pending states.

* tag 'ksmbd-for-7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/smb:
  ksmbd: require NUL-terminated EA names
  ksmbd: let the owner read and change the DACL when no ACE names it
  ksmbd: grant a POSIX ACL group entry only to the group's members
  ksmbd: do not read past the DACL in the access denied debug message
  ksmbd: fix NULL pointer dereference in session_user_name() and session_account_type()
  ksmbd: revert fsids on durable reconnect and replay failure
  ksmbd: enforce the read-only share flag when creating a stream
  ksmbd: require DELETE access for delete-on-close opens
This commit is contained in:
Linus Torvalds
2026-11-07 13:44:05 -08:00
3 changed files with 71 additions and 10 deletions
+4
View File
@@ -85,6 +85,8 @@ static const char *session_state_string(struct ksmbd_session *session)
static const char *session_user_name(struct ksmbd_session *session)
{
if (!session->user)
return "(Unauthenticated)";
if (user_guest(session->user))
return "(Guest)";
else if (ksmbd_anonymous_user(session->user))
@@ -94,6 +96,8 @@ static const char *session_user_name(struct ksmbd_session *session)
static const char *session_account_type(struct ksmbd_session *session)
{
if (!session->user)
return "unauthenticated";
if (user_guest(session->user))
return "guest";
if (ksmbd_anonymous_user(session->user))
+31 -3
View File
@@ -3454,6 +3454,11 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
if (!eabuf->EaNameLength)
goto next;
if (eabuf->name[eabuf->EaNameLength]) {
rc = -EBADMSG;
break;
}
ksmbd_debug(SMB,
"name : <%s>, name_len : %u, value_len : %u, next : %u\n",
eabuf->name, eabuf->EaNameLength,
@@ -3566,7 +3571,8 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
if (fp->cdoption == FILE_OPEN_LE) {
if (!strcmp(stream_name, "AFP_AfpInfo") &&
test_share_config_flag(fp->tcon->share_conf,
KSMBD_SHARE_FLAG_TIME_MACHINE)) {
KSMBD_SHARE_FLAG_TIME_MACHINE) &&
test_tree_conn_flag(fp->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE)) {
/*
* Synthesize an empty AFP_AfpInfo xattr on first access.
* type=0/creator=0 tells macOS to use the file extension
@@ -3593,6 +3599,9 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
return -EBADF;
}
if (!test_tree_conn_flag(fp->tcon, KSMBD_TREE_CONN_FLAG_WRITABLE))
return -EACCES;
rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);
if (rc < 0)
pr_err("Failed to store XATTR stream name :%d\n", rc);
@@ -4526,7 +4535,7 @@ int smb2_open(struct ksmbd_work *work)
file_info = FILE_OPENED;
rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);
if (rc)
goto err_out2;
goto err_out1;
goto reconnected_fp;
}
@@ -4556,7 +4565,7 @@ int smb2_open(struct ksmbd_work *work)
rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);
if (rc)
goto err_out2;
goto err_out1;
goto reconnected_fp;
}
@@ -4606,6 +4615,14 @@ int smb2_open(struct ksmbd_work *work)
goto err_out2;
}
}
/* MS-FSA 2.1.5.1: delete-on-close requires DELETE access */
if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE &&
!(smb_map_generic_desired_access(req->DesiredAccess) &
FILE_DELETE_LE)) {
rc = -EINVAL;
goto err_out2;
}
}
if (le32_to_cpu(req->CreateDisposition) >
@@ -4875,6 +4892,13 @@ resolve_path:
maximal_access = daccess;
}
/* MAXIMUM_ALLOWED may not have granted the requested DELETE */
if (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE &&
!(daccess & FILE_DELETE_LE)) {
rc = -EACCES;
goto err_out;
}
open_flags = smb2_create_open_flags(file_present, daccess,
req->CreateDisposition,
&may_flags,
@@ -5606,6 +5630,8 @@ err_out2:
if (rc) {
if (rc == -EINVAL)
rsp->hdr.Status = STATUS_INVALID_PARAMETER;
else if (rc == -EBADMSG)
rsp->hdr.Status = STATUS_EA_LIST_INCONSISTENT;
else if (rc == -EOPNOTSUPP)
rsp->hdr.Status = STATUS_NOT_SUPPORTED;
else if ((rc == -EACCES || rc == -ESTALE || rc == -EXDEV) &&
@@ -9304,6 +9330,8 @@ err_out:
}
else if (rc == -EINVAL)
rsp->hdr.Status = STATUS_INVALID_PARAMETER;
else if (rc == -EBADMSG)
rsp->hdr.Status = STATUS_EA_LIST_INCONSISTENT;
else if (rc == -EMSGSIZE)
rsp->hdr.Status = STATUS_INFO_LENGTH_MISMATCH;
else if (rc == -ENOSPC || rc == -EFBIG)
+36 -7
View File
@@ -1477,6 +1477,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
int i, found = 0;
unsigned int access_bits = 0, denied = 0;
struct smb_ace *others_ace = NULL;
bool or_ace = false;
struct posix_acl_entry *pa_entry;
unsigned int sid_type = SIDOWNER;
unsigned short ace_size;
@@ -1509,6 +1510,8 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
is_owner = uid == from_kuid(&init_user_ns, vfsuid_into_kuid(vfsuid));
if (!pdacl->num_aces) {
unsigned int allowed = 0;
/*
* An empty (present, zero-ACE) DACL grants no access to
* anyone except the object owner's implicit READ_CONTROL
@@ -1517,9 +1520,14 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
* not let trailing bytes after a zero-ACE DACL become an
* implicit grant.
*/
if (!is_owner ||
(*pdaccess & ~(FILE_READ_CONTROL_LE | FILE_WRITE_DAC_LE)))
if (is_owner)
allowed = READ_CONTROL | WRITE_DAC;
if (*pdaccess & FILE_MAXIMAL_ACCESS_LE)
requested |= allowed;
if (!allowed || requested & ~allowed)
rc = -EACCES;
else
*pdaccess = cpu_to_le32(requested);
goto err_out;
}
@@ -1604,6 +1612,9 @@ next_ace:
found = 1;
break;
}
if (!compare_sids(&sid_owner_rights, &ace->sid) &&
!(ace->flags & INHERIT_ONLY_ACE))
or_ace = true;
if (!compare_sids(&sid_everyone, &ace->sid) ||
!compare_sids(&sid_authusers, &ace->sid))
others_ace = ace;
@@ -1625,7 +1636,10 @@ next_ace:
else
continue;
if (id == uid) {
/* A group entry grants only to the group's members */
if (id == uid &&
(pa_entry->e_tag == ACL_USER ||
in_group_p(make_kgid(&init_user_ns, id)))) {
mode_to_access_flags(pa_entry->e_perm,
0777,
&access_bits);
@@ -1645,8 +1659,23 @@ next_ace:
if (others_ace) {
ace = others_ace;
} else {
ksmbd_debug(SMB, "Can't find corresponding sid\n");
rc = -EACCES;
unsigned int allowed = 0;
/*
* No ACE names the owner, who may still read and
* change the DACL unless OWNER RIGHTS applies
* (MS-DTYP 2.5.3.2).
*/
if (is_owner && !or_ace)
allowed = READ_CONTROL | WRITE_DAC;
if (*pdaccess & FILE_MAXIMAL_ACCESS_LE)
requested |= allowed;
if (!allowed || requested & ~allowed) {
ksmbd_debug(SMB, "Can't find corresponding sid\n");
rc = -EACCES;
goto err_out;
}
*pdaccess = cpu_to_le32(requested);
goto err_out;
}
}
@@ -1672,8 +1701,8 @@ check_access_bits:
}
if (granted & ~access_bits) {
ksmbd_debug(SMB, "Access denied with winACL, granted : %x, access_req : %x\n",
granted, le32_to_cpu(ace->access_req));
ksmbd_debug(SMB, "Access denied with winACL, requested : %x, allowed : %x\n",
granted, access_bits);
rc = -EACCES;
goto err_out;
}