Re: [PATCH 4.4 13/74] cifs: fix out-of-bounds access in lease parsing

From: Ben Hutchings
Date: Wed Mar 09 2016 - 11:17:29 EST


On Tue, 2016-03-08 at 22:23 -0600, Steve French wrote:
> On Tue, Mar 8, 2016 at 9:47 PM, Ben Hutchings <ben@xxxxxxxxxxxxxxx> wrote:
> >
> > On Mon, 2016-03-07 at 16:02 -0800, Greg Kroah-Hartman wrote:
> > >
> > > 4.4-stable review patch.ÂÂIf anyone has any objections, please let me know.
> > >
> > > ------------------
> > >
> > > From: Justin Maggard <jmaggard10@xxxxxxxxx>
> > >
> > > commit deb7deff2f00bdbbcb3d560dad2a89ef37df837d upstream.
> > >
> > > When opening a file, SMB2_open() attempts to parse the lease state from the
> > > SMB2 CREATE Response.ÂÂHowever, the parsing code was not careful to ensure
> > > that the create contexts are not empty or invalid, which can lead to out-
> > > of-bounds memory access.ÂÂThis can be seen easily by trying
> > > to read a file from a OSX 10.11 SMB3 server.ÂÂHere is sample crash output:
[...]
> > > --- a/fs/cifs/smb2pdu.c
> > > +++ b/fs/cifs/smb2pdu.c
> > > @@ -1109,21 +1109,25 @@ parse_lease_state(struct TCP_Server_Info
> > > Â{
> > > ÂÂÂÂÂÂchar *data_offset;
> > > ÂÂÂÂÂÂstruct create_context *cc;
> > > -ÂÂÂÂÂunsigned int next = 0;
> > > +ÂÂÂÂÂunsigned int next;
> > > +ÂÂÂÂÂunsigned int remaining;
> > > ÂÂÂÂÂÂchar *name;
> > >
> > > ÂÂÂÂÂÂdata_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset);
> > > +ÂÂÂÂÂremaining = le32_to_cpu(rsp->CreateContextsLength);
> > What if remaining is > the response length?
> Do you want to do the followon patch to check for that, or do you want me
> to write up a small patch for that?
[...]

I'm not likely to find time to dig into cifs, so please do work on the
complete fix.

Ben.

--
Ben Hutchings
When in doubt, use brute force. - Ken Thompson

Attachment: signature.asc
Description: This is a digitally signed message part