linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
	Ran Menscher <ran.menscher@karambasecurity.com>
Subject: Re: [PATCH 2/2] Bluetooth: check the buffer size for some messages before parsing
Date: Fri, 18 Jan 2019 12:11:01 +0100	[thread overview]
Message-ID: <8D42DA95-47AB-47B0-B8A5-0F7FF8C786E4@holtmann.org> (raw)
In-Reply-To: <20190118102123.GB20179@kroah.com>

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?

I am pretty sure he meant that the remote attacker can control it from userspace. This is still a wire protocol and not some socket options.

>>> 
>>> Based on a patch from Ran Menscher.
>>> 
>>> Reported-by: Ran Menscher <ran.menscher@karambasecurity.com>
>>> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> ---
>>> 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…

I need to reproduce this and then I can tell you.

Regards

Marcel


  reply	other threads:[~2019-01-18 11:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10  6:28 [PATCH 1/2] Bluetooth: check message types in l2cap_get_conf_opt Greg Kroah-Hartman
2019-01-10  6:29 ` [PATCH 2/2] Bluetooth: check the buffer size for some messages before parsing Greg Kroah-Hartman
2019-01-10  6:30   ` Greg Kroah-Hartman
2019-01-18  9:37   ` Marcel Holtmann
2019-01-18 10:21     ` Greg Kroah-Hartman
2019-01-18 11:11       ` Marcel Holtmann [this message]
2019-01-18 12:44         ` Marcel Holtmann
2019-01-10 21:02 ` [PATCH 1/2] Bluetooth: check message types in l2cap_get_conf_opt Joe Perches
2019-01-11  5:32   ` Greg Kroah-Hartman
2019-01-18  9:35 ` Marcel Holtmann
2019-01-18 10:19   ` Greg Kroah-Hartman
2019-01-18 11:09     ` Marcel Holtmann
2019-01-18 12:08       ` Marcel Holtmann

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=8D42DA95-47AB-47B0-B8A5-0F7FF8C786E4@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ran.menscher@karambasecurity.com \
    --subject='Re: [PATCH 2/2] Bluetooth: check the buffer size for some messages before parsing' \
    /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
on how to clone and mirror all data and code used for this inbox