Re: [PATCH 2/2] Bluetooth: check the buffer size for some messages before parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 18, 2019 at 10:37:25AM +0100, Marcel Holtmann wrote:
> Hi Greg,
> 
> > The L2CAP_CONF_EFS and L2CAP_CONF_RFC messages can be sent from
> > userspace so their structure sizes need to be checked before parsing
> > them.
> 
> this message is confusing me. How can these be send from userspace?

So claimed the original reporter.  You have the information in your
inbox, is it incorrect?

> > 
> > Based on a patch from Ran Menscher.
> > 
> > Reported-by: Ran Menscher <ran.menscher@xxxxxxxxxxxxxxxxxxx>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > ---
> > net/bluetooth/l2cap_core.c | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index 93daf94565cf..55e48e6efc2b 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -3361,7 +3361,8 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t data
> > 			break;
> > 
> > 		case L2CAP_CONF_RFC:
> > -			if (olen == sizeof(rfc))
> > +			if ((olen == sizeof(rfc)) &&
> > +			    (endptr - ptr >= L2CAP_CONF_OPT_SIZE + sizeof(rfc)))
> > 				memcpy(&rfc, (void *) val, olen);
> 
> We don’t do ((x == y) && (..)) actually. Using (x == y && ..) is plenty.

Ick, ok, whatever, you all trust that your brains can remember C
priority levels, me, I trust ()...

I can fix this up to remove the extra (), but I would like _SOMEONE_ to
at least validate that this resolves the reported issues...

thanks,

greg k-h



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux