mirror of
https://github.com/torvalds/linux
synced 2024-10-08 04:12:40 +00:00
cifsd: check return value of ksmbd_vfs_getcasexattr() correctly
If ksmbd_vfs_getcasexattr() returns -ENOMEM, stream_buf is NULL, it will cause null-ptr-deref when using it to copy memory. So we need check the return value of ksmbd_vfs_getcasexattr() by comparing with 0. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
673b9ba7a1
commit
fd6de099d7
|
@ -274,7 +274,6 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
|
|||
{
|
||||
ssize_t v_len;
|
||||
char *stream_buf = NULL;
|
||||
int err;
|
||||
|
||||
ksmbd_debug(VFS, "read stream data pos : %llu, count : %zd\n",
|
||||
*pos, count);
|
||||
|
@ -283,11 +282,8 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
|
|||
fp->stream.name,
|
||||
fp->stream.size,
|
||||
&stream_buf);
|
||||
if (v_len == -ENOENT) {
|
||||
ksmbd_err("not found stream in xattr : %zd\n", v_len);
|
||||
err = -ENOENT;
|
||||
return err;
|
||||
}
|
||||
if ((int)v_len <= 0)
|
||||
return (int)v_len;
|
||||
|
||||
memcpy(buf, &stream_buf[*pos], count);
|
||||
kvfree(stream_buf);
|
||||
|
@ -415,9 +411,9 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
|
|||
fp->stream.name,
|
||||
fp->stream.size,
|
||||
&stream_buf);
|
||||
if (v_len == -ENOENT) {
|
||||
if ((int)v_len < 0) {
|
||||
ksmbd_err("not found stream in xattr : %zd\n", v_len);
|
||||
err = -ENOENT;
|
||||
err = (int)v_len;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue