mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Jiri Kosina <jkosina@suse.cz>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 11/56] HID: logitech: perform bounds checking on device_id early enough
Date: Wed,  3 Sep 2014 11:26:30 +0200	[thread overview]
Message-ID: <2ae8a66674a4cd7f2cfee757ee29cb63dce755fe.1409735865.git.jslaby@suse.cz> (raw)
In-Reply-To: <b4839e6cd4a236a81725e422b2e05c26fe36048a.1409735865.git.jslaby@suse.cz>
In-Reply-To: <cover.1409735865.git.jslaby@suse.cz>

From: Jiri Kosina <jkosina@suse.cz>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit ad3e14d7c5268c2e24477c6ef54bbdf88add5d36 upstream.

device_index is a char type and the size of paired_dj_deivces is 7
elements, therefore proper bounds checking has to be applied to
device_index before it is used.

We are currently performing the bounds checking in
logi_dj_recv_add_djhid_device(), which is too late, as malicious device
could send REPORT_TYPE_NOTIF_DEVICE_UNPAIRED early enough and trigger the
problem in one of the report forwarding functions called from
logi_dj_raw_event().

Fix this by performing the check at the earliest possible ocasion in
logi_dj_raw_event().

Reported-by: Ben Hawkes <hawkes@google.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/hid/hid-logitech-dj.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 834cda2c25c7..9bf4c218cac8 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -237,13 +237,6 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
 		return;
 	}
 
-	if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
-	    (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
-		dev_err(&djrcv_hdev->dev, "%s: invalid device index:%d\n",
-			__func__, dj_report->device_index);
-		return;
-	}
-
 	if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {
 		/* The device is already known. No need to reallocate it. */
 		dbg_hid("%s: device is already known\n", __func__);
@@ -721,6 +714,12 @@ static int logi_dj_raw_event(struct hid_device *hdev,
 	 * device (via hid_input_report() ) and return 1 so hid-core does not do
 	 * anything else with it.
 	 */
+	if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
+	    (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
+		dev_err(&hdev->dev, "%s: invalid device index:%d\n",
+				__func__, dj_report->device_index);
+		return false;
+	}
 
 	spin_lock_irqsave(&djrcv_dev->lock, flags);
 	if (dj_report->report_id == REPORT_ID_DJ_SHORT) {
-- 
2.1.0


  parent reply	other threads:[~2014-09-03  9:57 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03  9:26 [PATCH 3.12 00/56] 3.12.28-stable review Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 01/56] bcache: Minor journal fix Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 02/56] usb: musb: cppi41: fire hrtimer according to programmed channel length Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 03/56] USB: serial: cp210x: Removing unncessary `usb_reset_device` on startup Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 04/56] USB: add reset resume quirk for usb3503 Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 05/56] usb-core bInterval quirk Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 06/56] USB: core: hcd-pci: free IRQ before disabling PCI device when shutting down Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 07/56] HID: add quirk for 0x04d9:0xa096 device Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 08/56] PM / hibernate: avoid unsafe pages in e820 reserved regions Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 09/56] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 10/56] PCI: Add pci_upstream_bridge() Jiri Slaby
2014-09-03  9:26 ` Jiri Slaby [this message]
2014-09-03  9:26 ` [PATCH 3.12 12/56] HID: fix a couple of off-by-ones Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 13/56] isofs: Fix unbounded recursion when processing relocated directories Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 14/56] USB: OHCI: fix bugs in debug routines Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 15/56] USB: OHCI: don't lose track of EDs when a controller dies Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 16/56] USB: devio: fix issue with log flooding Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 17/56] USB: serial: ftdi_sio: Annotate the current Xsens PID assignments Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 18/56] USB: serial: ftdi_sio: Add support for new Xsens devices Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 19/56] USB: ehci-pci: USB host controller support for Intel Quark X1000 Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 20/56] USB: Fix persist resume of some SS USB devices Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 21/56] ALSA: hda - fix an external mic jack problem on a HP machine Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 22/56] ALSA: virtuoso: add Xonar Essence STX II support Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 23/56] ALSA: hda/ca0132 - Don't try loading firmware at resume when already failed Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 24/56] ALSA: usb-audio: fix BOSS ME-25 MIDI regression Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 25/56] ALSA: hda - restore the gpio led after resume Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 26/56] ALSA: hda/realtek - Avoid setting wrong COEF on ALC269 & co Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 27/56] mei: start disconnect request timer consistently Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 28/56] ARM: OMAP3: Fix choice of omap3_restore_es function in OMAP34XX rev3.1.2 case Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 29/56] drm: omapdrm: fix compiler errors Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 30/56] hwmon: (sis5595) Prevent overflow problem when writing large limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 31/56] hwmon: (amc6821) Fix possible race condition bug Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 32/56] hwmon: (lm78) Fix overflow problems seen when writing large temperature limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 33/56] hwmon: (gpio-fan) Prevent overflow problem when writing large limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 34/56] hwmon: (ads1015) Fix off-by-one for valid channel index checking Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 35/56] hwmon: (lm85) Fix various errors on attribute writes Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 36/56] hwmon: (ads1015) Fix out-of-bounds array access Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 37/56] hwmon: (dme1737) Prevent overflow problem when writing large limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 38/56] tpm: Add missing tpm_do_selftest to ST33 I2C driver Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 39/56] drivers/i2c/busses: use correct type for dma_map/unmap Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 40/56] ext4: fix ext4_discard_allocated_blocks() if we can't allocate the pa struct Jiri Slaby
2014-09-15  2:46   ` Ben Hutchings
2014-09-15  7:40     ` Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 41/56] serial: core: Preserve termios c_cflag for console resume Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 42/56] crypto: ux500 - make interrupt mode plausible Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 43/56] debugfs: Fix corrupted loop in debugfs_remove_recursive Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 44/56] KVM: x86: Inter-privilege level ret emulation is not implemeneted Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 45/56] KVM: x86: always exit on EOIs for interrupts listed in the IOAPIC redir table Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 46/56] Revert "KVM: x86: Increase the number of fixed MTRR regs to 10" Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 47/56] kvm: iommu: fix the third parameter of kvm_iommu_put_pages (CVE-2014-3601) Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 48/56] drm/radeon: add new KV pci id Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 49/56] drm/radeon: add new bonaire pci ids Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 50/56] drm/radeon: add additional SI " Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 51/56] PCI: Configure ASPM when enabling device Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 52/56] x86: don't exclude low BIOS area when allocating address space for non-PCI cards Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 53/56] x86_64/vsyscall: Fix warn_bad_vsyscall log output Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 54/56] x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 55/56] x86/xen: resume timer irqs early Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 56/56] hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl Jiri Slaby
2014-09-03 13:26 ` [PATCH 3.12 00/56] 3.12.28-stable review Guenter Roeck
2014-09-03 19:32   ` Jiri Slaby
2014-09-03 19:55     ` Guenter Roeck
2014-09-03 21:08     ` Guenter Roeck
2014-09-05  7:28       ` Jiri Slaby
2014-09-04 13:33 ` Shuah Khan

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=2ae8a66674a4cd7f2cfee757ee29cb63dce755fe.1409735865.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®