All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: Johan Hovold <johan@kernel.org>,
	Marcel Holtmann <marcel@holtmann.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Frederic Danis <frederic.danis@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 4.4 49/56] Bluetooth: hci_bcm: add missing tty-device sanity check
Date: Wed, 24 May 2017 12:19:13 +0200	[thread overview]
Message-ID: <20170524101913.GH3657@localhost> (raw)
In-Reply-To: <1495589815.2083.7.camel@codethink.co.uk>

On Wed, May 24, 2017 at 02:36:55AM +0100, Ben Hutchings wrote:
> On Thu, 2017-05-18 at 12:49 +0200, Greg Kroah-Hartman wrote:
> > 4.4-stable review patch.  If anyone has any objections, please let me know.
> > 
> > ------------------
> > 
> > From: Johan Hovold <johan@kernel.org>
> > 
> > commit 95065a61e9bf25fb85295127fba893200c2bbbd8 upstream.
> > 
> > Make sure to check the tty-device pointer before looking up the sibling
> > platform device to avoid dereferencing a NULL-pointer when the tty is
> > one end of a Unix98 pty.
> > 
> > Fixes: 0395ffc1ee05 ("Bluetooth: hci_bcm: Add PM for BCM devices")
> > Cc: Frederic Danis <frederic.danis@linux.intel.com>
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > ---
> >  drivers/bluetooth/hci_bcm.c |    5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > --- a/drivers/bluetooth/hci_bcm.c
> > +++ b/drivers/bluetooth/hci_bcm.c
> > @@ -287,6 +287,9 @@ static int bcm_open(struct hci_uart *hu)
> >  
> >  	hu->priv = bcm;
> >  
> > +	if (!hu->tty->dev)
> > +		goto out;
> > +
> >  	mutex_lock(&bcm_device_lock);
> >  	list_for_each(p, &bcm_device_list) {
> >  		struct bcm_device *dev = list_entry(p, struct bcm_device, list);
> > @@ -307,7 +310,7 @@ static int bcm_open(struct hci_uart *hu)
> >  	}
> >  
> >  	mutex_unlock(&bcm_device_lock);
> > -
> > +out:
> >  	return 0;
> >  }
> 
> I'm a bit sceptical that this is fixing a real bug, 

Please take a look at bcm_open() where the tty device is being
dereferenced whenever there is bcm platform device registered:

	list_for_each(p, &bcm_device_list) {
		struct bcm_device *dev = list_entry(p, struct bcm_device, list);
		
		...

		if (hu->tty->dev->parent == dev->pdev->dev.parent) {


This can be used by an unprivileged user to trigger a NULL-dereference:

	Unable to handle kernel NULL pointer dereference at virtual address 00000000
	...
	[<bf0d5d74>] (bcm_open [hci_uart]) from [<bf0d1284>] (hci_uart_tty_ioctl+0x1b0/0x3c8 [hci_uart])
	[<bf0d1284>] (hci_uart_tty_ioctl [hci_uart]) from [<c0465bcc>] (tty_ioctl+0x5bc/0xbc8)
	[<c0465bcc>] (tty_ioctl) from [<c0258ad4>] (do_vfs_ioctl+0xac/0x9e8)
	[<c0258ad4>] (do_vfs_ioctl) from [<c0259454>] (SyS_ioctl+0x44/0x6c)
	[<c0259454>] (SyS_ioctl) from [<c01092e0>] (ret_fast_syscall+0x0/0x1c)

> but if it is -
> surely bcm_open() should fail if the tty device is not the right type?
> bcm_setup() would certainly fail after this.

The driver is written to be able to handle a non-existing platform
device (e.g. see use of bcm_device_exists() in the commit introducing
this issue), although since commit 6cc4396c8829 ("Bluetooth: hci_bcm:
Add wake-up capability") setup would indeed fail in this case (well at
least when firmware *is* available...).

Perhaps that is a separate issue that should be fixed (by failing early
in open as you suggest or by again allowing the driver to work without a
platform device), but I believe this patch is correct nonetheless. And
it does specifically fix the local DoS-attack.

Thanks,
Johan

  reply	other threads:[~2017-05-24 10:19 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 10:48 [PATCH 4.4 00/56] 4.4.69-stable review Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 01/56] xen: adjust early dom0 p2m handling to xen hypervisor behavior Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 02/56] target: Fix compare_and_write_callback handling for non GOOD status Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 03/56] target/fileio: Fix zero-length READ and WRITE handling Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 04/56] target: Convert ACL change queue_depth se_session reference usage Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 05/56] iscsi-target: Set session_fall_back_to_erl0 when forcing reinstatement Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 06/56] usb: host: xhci: print correct command ring address Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 07/56] USB: serial: ftdi_sio: add device ID for Microsemi/Arrow SF2PLUS Dev Kit Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 08/56] USB: Proper handling of Race Condition when two USB class drivers try to call init_usb_class simultaneously Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 09/56] staging: vt6656: use off stack for in buffer USB transfers Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 10/56] staging: vt6656: use off stack for out " Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 11/56] staging: gdm724x: gdm_mux: fix use-after-free on module unload Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 12/56] staging: comedi: jr3_pci: fix possible null pointer dereference Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 13/56] staging: comedi: jr3_pci: cope with jiffies wraparound Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 14/56] usb: misc: add missing continue in switch Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 15/56] usb: Make sure usb/phy/of gets built-in Greg Kroah-Hartman
2017-05-18 10:48   ` Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 16/56] usb: hub: Fix error loop seen after hub communication errors Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 17/56] usb: hub: Do not attempt to autosuspend disconnected devices Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 18/56] usb: misc: legousbtower: Fix buffers on stack Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 19/56] x86/boot: Fix BSS corruption/overwrite bug in early x86 kernel startup Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 20/56] selftests/x86/ldt_gdt_32: Work around a glibc sigaction() bug Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 21/56] x86, pmem: Fix cache flushing for iovec write < 8 bytes Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 22/56] um: Fix PTRACE_POKEUSER on x86_64 Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 24/56] KVM: arm/arm64: fix races in kvm_psci_vcpu_on Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 25/56] block: fix blk_integrity_register to use templates interval_exp if not 0 Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 26/56] crypto: algif_aead - Require setkey before accept(2) Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 27/56] dm era: save spacemap metadata root after the pre-commit Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 28/56] vfio/type1: Remove locked page accounting workqueue Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 29/56] IB/core: Fix sysfs registration error flow Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 30/56] IB/IPoIB: ibX: failed to create mcg debug file Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 31/56] IB/mlx4: Fix ib device initialization error flow Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 32/56] IB/mlx4: Reduce SRIOV multicast cleanup warning message to debug level Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 33/56] ext4: evict inline data when writing to memory map Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 34/56] fs/xattr.c: zero out memory copied to userspace in getxattr Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 35/56] ceph: fix memory leak in __ceph_setxattr() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 36/56] fs/block_dev: always invalidate cleancache in invalidate_bdev() Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 37/56] Set unicode flag on cifs echo request to avoid Mac error Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 38/56] SMB3: Work around mount failure when using SMB3 dialect to Macs Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 40/56] cifs: fix CIFS_IOC_GET_MNT_INFO oops Greg Kroah-Hartman
2017-05-18 10:48 ` [PATCH 4.4 42/56] padata: free correct variable Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 43/56] arm64: KVM: Fix decoding of Rt/Rt2 when trapping AArch32 CP accesses Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 44/56] serial: samsung: Use right device for DMA-mapping calls Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 45/56] serial: omap: fix runtime-pm handling on unbind Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 46/56] serial: omap: suspend device on probe errors Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 47/56] tty: pty: Fix ldisc flush after userspace become aware of the data already Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 48/56] Bluetooth: Fix user channel for 32bit userspace on 64bit kernel Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 49/56] Bluetooth: hci_bcm: add missing tty-device sanity check Greg Kroah-Hartman
2017-05-24  1:36   ` Ben Hutchings
2017-05-24 10:19     ` Johan Hovold [this message]
2017-05-18 10:49 ` [PATCH 4.4 50/56] Bluetooth: hci_intel: " Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 51/56] mac80211: pass RX aggregation window size to driver Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 52/56] mac80211: pass block ack session timeout to " Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 53/56] mac80211: RX BA support for sta max_rx_aggregation_subframes Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 54/56] wlcore: Pass win_size taken from ieee80211_sta to FW Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 55/56] wlcore: Add RX_BA_WIN_SIZE_CHANGE_EVENT event Greg Kroah-Hartman
2017-05-18 10:49 ` [PATCH 4.4 56/56] ipmi: Fix kernel panic at ipmi_ssif_thread() Greg Kroah-Hartman
2017-05-18 17:33 ` [PATCH 4.4 00/56] 4.4.69-stable review Shuah Khan
2017-05-19  1:10 ` Guenter Roeck

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=20170524101913.GH3657@localhost \
    --to=johan@kernel.org \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=frederic.danis@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.