lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANFS6bbZysgZ2Wv7_FqmeBC0e34h5uiBLFdeiDvOxHFd2XGTSg@mail.gmail.com>
Date:   Mon, 31 May 2021 14:38:42 +0900
From:   Hyunchul Lee <hyc.lee@...il.com>
To:     Yang Yingliang <yangyingliang@...wei.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        linux-cifsd-devel <linux-cifsd-devel@...ts.sourceforge.net>,
        linux-cifs <linux-cifs@...r.kernel.org>,
        Namjae Jeon <namjae.jeon@...sung.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steve French <sfrench@...ba.org>
Subject: Re: [PATCH -next v2] cifsd: check return value of ksmbd_vfs_getcasexattr()
 correctly

2021년 5월 31일 (월) 오후 12:01, Yang Yingliang <yangyingliang@...wei.com>님이 작성:
>
> 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.
>
> Fixes: f44158485826 ("cifsd: add file operations")
> Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
> ---
> v2:
>   Handle the case ksmbd_vfs_getcasexattr() returns 0.
> ---
>  fs/cifsd/vfs.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/cifsd/vfs.c b/fs/cifsd/vfs.c
> index 97d5584ec870..2a9cc0bc7726 100644
> --- a/fs/cifsd/vfs.c
> +++ b/fs/cifsd/vfs.c
> @@ -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,10 +282,9 @@ 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) {
> +       if ((int)v_len <= 0) {
>                 ksmbd_err("not found stream in xattr : %zd\n", v_len);
> -               err = -ENOENT;
> -               return err;
> +               return v_len == 0 ? -ENOENT : (int)v_len;

How about making ksmbd_vfs_getcasexattr return -ENONENT instead of
returning 0 to
remove duplicate error handling code?

Thanks,
Hyunchul

>         }
>
>         memcpy(buf, &stream_buf[*pos], count);
> @@ -415,9 +413,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 = v_len == 0 ? -ENOENT : (int)v_len;
>                 goto out;
>         }
>
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ