From: Hyunchul Lee hyc.lee@gmail.com
mainline inclusion from mainline-5.15-rc1 commit 21dd1fd6d718ac59841c3ee3d0b1d82508ef24dc category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I60T7G CVE: NA
Reference: https://git.kernel.org/torvalds/linux/c/21dd1fd6d718
-------------------------------
For code cleanup, handle error cases first in smb2_create_sd_buffers().
Reported-by: Dan Carpenter dan.carpenter@oracle.com Signed-off-by: Hyunchul Lee hyc.lee@gmail.com Signed-off-by: Namjae Jeon namjae.jeon@samsung.com Signed-off-by: Steve French stfrench@microsoft.com Signed-off-by: Jason Yan yanaijie@huawei.com Signed-off-by: Zhong Jinghua zhongjinghua@huawei.com --- fs/ksmbd/smb2pdu.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index f158b7e104da..b842768fc209 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -2309,25 +2309,23 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work, struct path *path) { struct create_context *context; - int rc = -ENOENT; + struct create_sd_buf_req *sd_buf;
if (!req->CreateContextsOffset) - return rc; + return -ENOENT;
/* Parse SD BUFFER create contexts */ context = smb2_find_context_vals(req, SMB2_CREATE_SD_BUFFER); - if (context && !IS_ERR(context)) { - struct create_sd_buf_req *sd_buf; - - ksmbd_debug(SMB, - "Set ACLs using SMB2_CREATE_SD_BUFFER context\n"); - sd_buf = (struct create_sd_buf_req *)context; - rc = set_info_sec(work->conn, work->tcon, - path, &sd_buf->ntsd, - le32_to_cpu(sd_buf->ccontext.DataLength), true); - } + if (!context) + return -ENOENT; + else if (IS_ERR(context)) + return PTR_ERR(context);
- return rc; + ksmbd_debug(SMB, + "Set ACLs using SMB2_CREATE_SD_BUFFER context\n"); + sd_buf = (struct create_sd_buf_req *)context; + return set_info_sec(work->conn, work->tcon, path, &sd_buf->ntsd, + le32_to_cpu(sd_buf->ccontext.DataLength), true); }
static void ksmbd_acls_fattr(struct smb_fattr *fattr, struct inode *inode)