linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve French <smfrench@gmail.com>
To: Jeff Layton <jlayton@kernel.org>
Cc: Len Baker <len.baker@gmx.com>, Steve French <sfrench@samba.org>,
	Suresh Jayaraman <sjayaraman@suse.de>,
	CIFS <linux-cifs@vger.kernel.org>,
	samba-technical <samba-technical@lists.samba.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Kees Cook <keescook@chromium.org>,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] CIFS: Fix a potencially linear read overflow
Date: Fri, 20 Aug 2021 00:58:50 -0500	[thread overview]
Message-ID: <CAH2r5msKF-YZsmWEwqZZEn2ibooEOtFm7khvSnhD9uOidNycew@mail.gmail.com> (raw)
In-Reply-To: <2f3a644e279a8a0933343339fa0add8e76276bf8.camel@kernel.org>

Added RB and repushed to cifs-2.6.git for-next

On Wed, Aug 18, 2021 at 8:22 AM Jeff Layton <jlayton@kernel.org> wrote:
>
> On Tue, 2021-08-17 at 12:27 +0200, Len Baker wrote:
> > strlcpy() reads the entire source buffer first. This read may exceed the
> > destination size limit. This is both inefficient and can lead to linear
> > read overflows if a source string is not NUL-terminated.
> >
> > Also, the strnlen() call does not avoid the read overflow in the strlcpy
> > function when a not NUL-terminated string is passed.
> >
> > So, replace this block by a call to kstrndup() that avoids this type of
> > overflow and does the same.
> >
> > Fixes: 066ce6899484d ("cifs: rename cifs_strlcpy_to_host and make it use new functions")
> > Signed-off-by: Len Baker <len.baker@gmx.com>
> > ---
> >  fs/cifs/cifs_unicode.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
> > index 9bd03a231032..171ad8b42107 100644
> > --- a/fs/cifs/cifs_unicode.c
> > +++ b/fs/cifs/cifs_unicode.c
> > @@ -358,14 +358,9 @@ cifs_strndup_from_utf16(const char *src, const int maxlen,
> >               if (!dst)
> >                       return NULL;
> >               cifs_from_utf16(dst, (__le16 *) src, len, maxlen, codepage,
> > -                            NO_MAP_UNI_RSVD);
> > +                             NO_MAP_UNI_RSVD);
> >       } else {
> > -             len = strnlen(src, maxlen);
> > -             len++;
> > -             dst = kmalloc(len, GFP_KERNEL);
> > -             if (!dst)
> > -                     return NULL;
> > -             strlcpy(dst, src, len);
> > +             dst = kstrndup(src, maxlen, GFP_KERNEL);
> >       }
> >
> >       return dst;
> > --
> > 2.25.1
> >
>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
>


-- 
Thanks,

Steve

      reply	other threads:[~2021-08-20  5:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 10:27 Len Baker
2021-08-18  0:28 ` Paulo Alcantara
2021-08-18  2:46   ` Steve French
2021-08-18 13:21 ` Jeff Layton
2021-08-20  5:58   ` Steve French [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH2r5msKF-YZsmWEwqZZEn2ibooEOtFm7khvSnhD9uOidNycew@mail.gmail.com \
    --to=smfrench@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=keescook@chromium.org \
    --cc=len.baker@gmx.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=sjayaraman@suse.de \
    --subject='Re: [PATCH] CIFS: Fix a potencially linear read overflow' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).