Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1648686

[PATCH 4.4 077/103] [media] cx231xx-audio: fix NULL-deref at probe

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 077/103] [media] cx231xx-audio: fix NULL-deref at probe
Date 2017-05-23 23:10 +0200
Message-ID <tKpe2-rD-33@gated-at.bofh.it> (permalink)
References <tKoKZ-8pv-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

------------------

From: Johan Hovold <johan@kernel.org>

commit 65f921647f4c89a2068478c89691f39b309b58f7 upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory beyond the endpoint array should a
malicious device lack the expected endpoints.

Fixes: e0d3bafd0258 ("V4L/DVB (10954): Add cx231xx USB driver")

Cc: Sri Deevi <Srinivasa.Deevi@conexant.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/media/usb/cx231xx/cx231xx-audio.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -698,6 +698,11 @@ static int cx231xx_audio_init(struct cx2
 					    hs_config_info[0].interface_info.
 					    audio_index + 1];
 
+	if (uif->altsetting[0].desc.bNumEndpoints < isoc_pipe + 1) {
+		err = -ENODEV;
+		goto err_free_card;
+	}
+
 	adev->end_point_addr =
 	    uif->altsetting[0].endpoint[isoc_pipe].desc.
 			bEndpointAddress;
@@ -713,8 +718,14 @@ static int cx231xx_audio_init(struct cx2
 	}
 
 	for (i = 0; i < adev->num_alt; i++) {
-		u16 tmp =
-		    le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
+		u16 tmp;
+
+		if (uif->altsetting[i].desc.bNumEndpoints < isoc_pipe + 1) {
+			err = -ENODEV;
+			goto err_free_pkt_size;
+		}
+
+		tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.
 				wMaxPacketSize);
 		adev->alt_max_pkt_size[i] =
 		    (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
@@ -725,6 +736,8 @@ static int cx231xx_audio_init(struct cx2
 
 	return 0;
 
+err_free_pkt_size:
+	kfree(adev->alt_max_pkt_size);
 err_free_card:
 	snd_card_free(card);
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 099/103] PCI: Fix pci_mmap_fits() for HAVE_PCI_RESOURCE_TO_USER platforms Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 098/103] tracing/kprobes: Enforce kprobes teardown after testing Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 097/103] osf_wait4(): fix infoleak Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 095/103] uwb: fix device quirk on big-endian hosts Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 012/103] dm bufio: avoid a possible ABBA deadlock Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 037/103] proc: Fix unbalanced hard link numbers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 029/103] drm/amdgpu: Avoid overflows/divide-by-zero in latency_watermark calculations. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 034/103] drm/nouveau/tmr: avoid processing completed alarms when adding a new one Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 030/103] drm/amdgpu: Make display watermark calculations more accurate Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 078/103] [media] cx231xx-cards: fix NULL-deref at probe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 014/103] dm cache metadata: fail operations if fail_io mode has been established Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:00 +0200
  [PATCH 4.4 077/103] [media] cx231xx-audio: fix NULL-deref at probe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:10 +0200
  [PATCH 4.4 080/103] powerpc/pseries: Fix of_node_put() underflow during DLPAR remove Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:10 +0200
  [PATCH 4.4 073/103] [media] dib0700: fix NULL-deref at probe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:20 +0200
  [PATCH 4.4 082/103] ARM: dts: at91: sama5d3_xplained: fix ADC vref Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:20 +0200
  [PATCH 4.4 081/103] powerpc/64e: Fix hang when debugging programs with relocated kernel Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:20 +0200
  [PATCH 4.4 079/103] powerpc/book3s/mce: Move add_taint() later in virtual mode Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:20 +0200
  [PATCH 4.4 102/103] nfsd: encoders mustnt use unitialized values in error cases Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:30 +0200
  [PATCH 4.4 103/103] drivers: char: mem: Check for address space wraparound with mmap() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:30 +0200
  [PATCH 4.4 101/103] drm/edid: Add 10 bpc quirk for LGD 764 panel in HP zBook 17 G2 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-23 23:30 +0200
  Re: [PATCH 4.4 000/103] 4.4.70-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-24 06:10 +0200
    Re: [PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-24 09:00 +0200
      Re: [PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-24 09:00 +0200
  Re: [PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-24 09:10 +0200
    Re: [PATCH 4.4 000/103] 4.4.70-stable review Thomas Voegtle <tv@lio96.de> - 2017-05-24 11:40 +0200
      Re: [PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-24 13:40 +0200
        Re: [PATCH 4.4 000/103] 4.4.70-stable review Thomas Voegtle <tv@lio96.de> - 2017-05-24 14:10 +0200
          Re: [PATCH 4.4 000/103] 4.4.70-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-24 15:00 +0200
    Re: [PATCH 4.4 000/103] 4.4.70-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-24 14:50 +0200
      Re: [PATCH 4.4 000/103] 4.4.70-stable review Mark Brown <broonie@kernel.org> - 2017-05-24 15:10 +0200
        Re: [PATCH 4.4 000/103] 4.4.70-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-24 15:20 +0200
          Re: [PATCH 4.4 000/103] 4.4.70-stable review Mark Brown <broonie@kernel.org> - 2017-05-24 17:10 +0200
        Re: [PATCH 4.4 000/103] 4.4.70-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-24 15:40 +0200
  Re: [PATCH 4.4 000/103] 4.4.70-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-24 22:30 +0200

csiph-web