From: Jeremy Allison <jra@samba.org>
To: Steve French <smfrench@gmail.com>
Cc: Christoph Probst <kernel@probst.it>,
Steve French <sfrench@samba.org>,
CIFS <linux-cifs@vger.kernel.org>,
samba-technical <samba-technical@lists.samba.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cifs: fix strcat buffer overflow in smb21_set_oplock_level()
Date: Mon, 6 May 2019 09:56:58 -0700 [thread overview]
Message-ID: <20190506165658.GA168433@jra4> (raw)
In-Reply-To: <CAH2r5mtdpOvcE25P2UuNFpOwsNyFiBWRQELQFui+FJGVOOBV8w@mail.gmail.com>
On Mon, May 06, 2019 at 11:53:44AM -0500, Steve French via samba-technical wrote:
> I think strcpy is clearer - but I don't think it can overflow since if
> R, W or W were written to "message" then cinode->oplock would be
> non-zero so we would never strcap "None"
Ahem. In Samba we have :
lib/util/safe_string.h:#define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
Maybe you should do likewise :-).
> On Mon, May 6, 2019 at 10:26 AM Christoph Probst <kernel@probst.it> wrote:
> >
> > Change strcat to strcpy in the "None" case as it is never valid to append
> > "None" to any other message. It may also overflow char message[5], in a
> > race condition on cinode if cinode->oplock is unset by another thread
> > after "RHW" or "RH" had been written to message.
> >
> > Signed-off-by: Christoph Probst <kernel@probst.it>
> > ---
> > fs/cifs/smb2ops.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> > index c36ff0d..5fd5567 100644
> > --- a/fs/cifs/smb2ops.c
> > +++ b/fs/cifs/smb2ops.c
> > @@ -2936,7 +2936,7 @@ smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
> > strcat(message, "W");
> > }
> > if (!cinode->oplock)
> > - strcat(message, "None");
> > + strcpy(message, "None");
> > cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
> > &cinode->vfs_inode);
> > }
> > --
> > 2.1.4
> >
>
>
> --
> Thanks,
>
> Steve
>
next prev parent reply other threads:[~2019-05-06 16:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-06 15:16 [PATCH] cifs: fix strcat buffer overflow in smb21_set_oplock_level() Christoph Probst
2019-05-06 16:53 ` Steve French
2019-05-06 16:56 ` Jeremy Allison [this message]
2019-05-06 17:02 ` Steve French
2019-05-06 19:03 ` Pavel Shilovsky
2019-05-06 21:18 ` Steve French
2019-05-07 6:10 ` Christoph Probst
2019-05-07 11:02 ` David Laight
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=20190506165658.GA168433@jra4 \
--to=jra@samba.org \
--cc=kernel@probst.it \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=smfrench@gmail.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox