mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	John Hughes <john@calva.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [107/127] x25: Patch to fix bug 15678 - x25 accesses fields beyond end of packet.
Date: Tue, 07 Dec 2010 16:44:53 -0800	[thread overview]
Message-ID: <20101208004435.019108606@clark.site> (raw)
In-Reply-To: <20101208004456.GA23578@kroah.com>

2.6.32-stable review patch.  If anyone has any objections, please let us know.

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

From: John Hughes <john@calva.com>

commit f5eb917b861828da18dc28854308068c66d1449a upstream.

Here is a patch to stop X.25 examining fields beyond the end of the packet.

For example, when a simple CALL ACCEPTED was received:

	10 10 0f

x25_parse_facilities was attempting to decode the FACILITIES field, but this
packet contains no facilities field.

Signed-off-by: John Hughes <john@calva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 include/net/x25.h        |    4 ++++
 net/x25/af_x25.c         |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 net/x25/x25_facilities.c |   12 +++++++++++-
 net/x25/x25_in.c         |   15 +++++++++++----
 4 files changed, 72 insertions(+), 6 deletions(-)

--- a/include/net/x25.h
+++ b/include/net/x25.h
@@ -182,6 +182,10 @@ extern int  sysctl_x25_clear_request_tim
 extern int  sysctl_x25_ack_holdback_timeout;
 extern int  sysctl_x25_forward;
 
+extern int x25_parse_address_block(struct sk_buff *skb,
+		struct x25_address *called_addr,
+		struct x25_address *calling_addr);
+
 extern int  x25_addr_ntoa(unsigned char *, struct x25_address *,
 			  struct x25_address *);
 extern int  x25_addr_aton(unsigned char *, struct x25_address *,
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -81,6 +81,41 @@ struct compat_x25_subscrip_struct {
 };
 #endif
 
+
+int x25_parse_address_block(struct sk_buff *skb,
+		struct x25_address *called_addr,
+		struct x25_address *calling_addr)
+{
+	unsigned char len;
+	int needed;
+	int rc;
+
+	if (skb->len < 1) {
+		/* packet has no address block */
+		rc = 0;
+		goto empty;
+	}
+
+	len = *skb->data;
+	needed = 1 + (len >> 4) + (len & 0x0f);
+
+	if (skb->len < needed) {
+		/* packet is too short to hold the addresses it claims
+		   to hold */
+		rc = -1;
+		goto empty;
+	}
+
+	return x25_addr_ntoa(skb->data, called_addr, calling_addr);
+
+empty:
+	*called_addr->x25_addr = 0;
+	*calling_addr->x25_addr = 0;
+
+	return rc;
+}
+
+
 int x25_addr_ntoa(unsigned char *p, struct x25_address *called_addr,
 		  struct x25_address *calling_addr)
 {
@@ -871,16 +906,26 @@ int x25_rx_call_request(struct sk_buff *
 	/*
 	 *	Extract the X.25 addresses and convert them to ASCII strings,
 	 *	and remove them.
+	 *
+	 *	Address block is mandatory in call request packets
 	 */
-	addr_len = x25_addr_ntoa(skb->data, &source_addr, &dest_addr);
+	addr_len = x25_parse_address_block(skb, &source_addr, &dest_addr);
+	if (addr_len <= 0)
+		goto out_clear_request;
 	skb_pull(skb, addr_len);
 
 	/*
 	 *	Get the length of the facilities, skip past them for the moment
 	 *	get the call user data because this is needed to determine
 	 *	the correct listener
+	 *
+	 *	Facilities length is mandatory in call request packets
 	 */
+	if (skb->len < 1)
+		goto out_clear_request;
 	len = skb->data[0] + 1;
+	if (skb->len < len)
+		goto out_clear_request;
 	skb_pull(skb,len);
 
 	/*
--- a/net/x25/x25_facilities.c
+++ b/net/x25/x25_facilities.c
@@ -35,7 +35,7 @@ int x25_parse_facilities(struct sk_buff
 		struct x25_dte_facilities *dte_facs, unsigned long *vc_fac_mask)
 {
 	unsigned char *p = skb->data;
-	unsigned int len = *p++;
+	unsigned int len;
 
 	*vc_fac_mask = 0;
 
@@ -50,6 +50,14 @@ int x25_parse_facilities(struct sk_buff
 	memset(dte_facs->called_ae, '\0', sizeof(dte_facs->called_ae));
 	memset(dte_facs->calling_ae, '\0', sizeof(dte_facs->calling_ae));
 
+	if (skb->len < 1)
+		return 0;
+
+	len = *p++;
+
+	if (len >= skb->len)
+		return -1;
+
 	while (len > 0) {
 		switch (*p & X25_FAC_CLASS_MASK) {
 		case X25_FAC_CLASS_A:
@@ -247,6 +255,8 @@ int x25_negotiate_facilities(struct sk_b
 	memcpy(new, ours, sizeof(*new));
 
 	len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask);
+	if (len < 0)
+		return len;
 
 	/*
 	 *	They want reverse charging, we won't accept it.
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -89,6 +89,7 @@ static int x25_queue_rx_frame(struct soc
 static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametype)
 {
 	struct x25_address source_addr, dest_addr;
+	int len;
 
 	switch (frametype) {
 		case X25_CALL_ACCEPTED: {
@@ -106,11 +107,17 @@ static int x25_state1_machine(struct soc
 			 *	Parse the data in the frame.
 			 */
 			skb_pull(skb, X25_STD_MIN_LEN);
-			skb_pull(skb, x25_addr_ntoa(skb->data, &source_addr, &dest_addr));
-			skb_pull(skb,
-				 x25_parse_facilities(skb, &x25->facilities,
+
+			len = x25_parse_address_block(skb, &source_addr,
+						&dest_addr);
+			if (len > 0)
+				skb_pull(skb, len);
+
+			len = x25_parse_facilities(skb, &x25->facilities,
 						&x25->dte_facilities,
-						&x25->vc_facil_mask));
+						&x25->vc_facil_mask);
+			if (len > 0)
+				skb_pull(skb, len);
 			/*
 			 *	Copy any Call User Data.
 			 */



  parent reply	other threads:[~2010-12-08  0:52 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08  0:44 [000/127] 2.6.32.27-stable review Greg KH
2010-12-08  0:43 ` [001/127] block: Ensure physical block size is unsigned int Greg KH
2010-12-08  0:43 ` [002/127] block: limit vec count in bio_kmalloc() and bio_alloc_map_data() Greg KH
2010-12-08  0:43 ` [003/127] block: take care not to overflow when calculating total iov length Greg KH
2010-12-08  0:43 ` [004/127] block: check for proper length of iov entries in blk_rq_map_user_iov() Greg KH
2010-12-08  0:43 ` [005/127] jme: Fix PHY power-off error Greg KH
2010-12-08  0:43 ` [006/127] irda: Fix parameter extraction stack overflow Greg KH
2010-12-08  0:43 ` [007/127] irda: Fix heap memory corruption in iriap.c Greg KH
2010-12-08  0:43 ` [008/127] i2c-pca-platform: Change device name of request_irq Greg KH
2010-12-08  0:43 ` [009/127] microblaze: Fix build with make 3.82 Greg KH
2010-12-08  0:43 ` [010/127] net: clear heap allocation for ETHTOOL_GRXCLSRLALL Greg KH
2010-12-08  0:43 ` [011/127] Staging: asus_oled: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:43 ` [012/127] Staging: asus_oled: fix up my fixup for " Greg KH
2010-12-08  0:43 ` [013/127] Staging: line6: fix up " Greg KH
2010-12-08  0:43 ` [014/127] hpet: fix unwanted interrupt due to stale irq status bit Greg KH
2010-12-08  0:43 ` [015/127] hpet: unmap unused I/O space Greg KH
2010-12-08  0:43 ` [016/127] olpc_battery: Fix endian neutral breakage for s16 values Greg KH
2010-12-08  0:43 ` [017/127] percpu: fix list_head init bug in __percpu_counter_init() Greg KH
2010-12-08  0:43 ` [018/127] um: remove PAGE_SIZE alignment in linker script causing kernel segfault Greg KH
2010-12-08  0:43 ` [019/127] um: fix global timer issue when using CONFIG_NO_HZ Greg KH
2010-12-08  0:43 ` [020/127] numa: fix slab_node(MPOL_BIND) Greg KH
2010-12-08  0:43 ` [021/127] hwmon: (lm85) Fix ADT7468 frequency table Greg KH
2010-12-08  0:43 ` [022/127] mm: fix return value of scan_lru_pages in memory unplug Greg KH
2010-12-08  0:43 ` [023/127] mm: fix is_mem_section_removable() page_order BUG_ON check Greg KH
2010-12-08  0:43 ` [024/127] ahci,ata_generic: let ata_generic handle new MBP w/ MCP89 Greg KH
2010-12-08  0:43 ` [025/127] ata_generic: implement ATA_GEN_* flags and force enable DMA on MBP 7,1 Greg KH
2010-12-08  0:43 ` [026/127] ssb: b43-pci-bridge: Add new vendor for BCM4318 Greg KH
2010-12-08  0:43 ` [027/127] sgi-xpc: XPC fails to discover partitions with all nasids above 128 Greg KH
2010-12-08  0:43 ` [028/127] xen: ensure that all event channels start off bound to VCPU 0 Greg KH
2010-12-08  0:43 ` [029/127] xen: dont bother to stop other cpus on shutdown/reboot Greg KH
2010-12-08  0:43 ` [030/127] ipc: initialize structure memory to zero for compat functions Greg KH
2010-12-08  0:43 ` [031/127] ipc: shm: fix information leak to userland Greg KH
2010-12-08  0:43 ` [032/127] sys_semctl: fix kernel stack leakage Greg KH
2010-12-08  0:43 ` [033/127] net: NETIF_F_HW_CSUM does not imply FCoE CRC offload Greg KH
2010-12-08  0:43 ` [034/127] drivers/char/vt_ioctl.c: fix VT_OPENQRY error value Greg KH
2010-12-08  0:43 ` [035/127] viafb: use proper register for colour when doing fill ops Greg KH
2010-12-08  0:43 ` [036/127] eCryptfs: Clear LOOKUP_OPEN flag when creating lower file Greg KH
2010-12-08  0:43 ` [037/127] md/raid1: really fix recovery looping when single good device fails Greg KH
2010-12-08  0:43 ` [038/127] md: fix return value of rdev_size_change() Greg KH
2010-12-08  0:43 ` [039/127] x86: AMD Northbridge: Verify NBs node is online Greg KH
2010-12-08  0:43 ` [040/127] tty: prevent DOS in the flush_to_ldisc Greg KH
2010-12-08  0:43 ` [041/127] TTY: restore tty_ldisc_wait_idle Greg KH
2010-12-08  0:43 ` [042/127] tty_ldisc: Fix BUG() on hangup Greg KH
2010-12-08  0:43 ` [043/127] TTY: ldisc, fix open flag handling Greg KH
2010-12-08  6:24   ` Jiri Slaby
2010-12-08 15:02     ` Greg KH
2010-12-08 15:09       ` Jiri Slaby
2010-12-08 15:50         ` Greg KH
2010-12-08  0:43 ` [044/127] KVM: VMX: fix vmx null pointer dereference on debug register access Greg KH
2010-12-08  0:43 ` [045/127] KVM: x86: fix information leak to userland Greg KH
2010-12-08  0:43 ` [046/127] KVM: VMX: Fix host userspace gsbase corruption Greg KH
2010-12-08  2:12   ` [Stable-review] " Ben Hutchings
2010-12-08  3:58     ` Greg KH
2010-12-08  0:43 ` [047/127] firewire: cdev: fix information leak Greg KH
2010-12-08  0:43 ` [048/127] firewire: core: fix an " Greg KH
2010-12-08  0:43 ` [049/127] firewire: ohci: fix buffer overflow in AR split packet handling Greg KH
2010-12-08  0:43 ` [050/127] firewire: ohci: fix race " Greg KH
2010-12-08  0:43 ` [051/127] ALSA: ac97: Apply quirk for Dell Latitude D610 binding Master and Headphone controls Greg KH
2010-12-08  0:43 ` [052/127] ALSA: HDA: Add an extra DAC for Realtek ALC887-VD Greg KH
2010-12-08  0:43 ` [053/127] ALSA: hda: Use "alienware" model quirk for another SSID Greg KH
2010-12-08  0:44 ` [054/127] netfilter: nf_conntrack: allow nf_ct_alloc_hashtable() to get highmem pages Greg KH
2010-12-08  0:44 ` [055/127] latencytop: fix per task accumulator Greg KH
2010-12-08  0:44 ` [056/127] mm/vfs: revalidate page->mapping in do_generic_file_read() Greg KH
2010-12-08  0:44 ` [057/127] bio: take care not overflow page count when mapping/copying user data Greg KH
2010-12-08  0:44 ` [058/127] drm/ttm: Clear the ghost cpu_writers flag on ttm_buffer_object_transfer Greg KH
2010-12-08  0:44 ` [059/127] libata-scsi passthru: fix bug which truncated LBA48 return values Greg KH
2010-12-08  0:44 ` [060/127] libata: fix NULL sdev dereference race in atapi_qc_complete() Greg KH
2010-12-08  0:44 ` [061/127] PCI: fix size checks for mmap() on /proc/bus/pci files Greg KH
2010-12-08  0:44 ` [062/127] PCI: fix offset check for sysfs mmapped files Greg KH
2010-12-08  0:44 ` [063/127] efifb: check that the base address is plausible on pci systems Greg KH
2010-12-08  0:44 ` [064/127] USB: gadget: AT91: fix typo in atmel_usba_udc driver Greg KH
2010-12-08  0:44 ` [065/127] USB: ftdi_sio: add device IDs for Milkymist One JTAG/serial Greg KH
2010-12-08  0:44 ` [066/127] USB: option: fix when the driver is loaded incorrectly for some Huawei devices Greg KH
2010-12-08  0:44 ` [067/127] usb: misc: sisusbvga: fix information leak to userland Greg KH
2010-12-08  0:44 ` [068/127] usb: misc: iowarrior: " Greg KH
2010-12-08  0:44 ` [069/127] usb: core: " Greg KH
2010-12-08  0:44 ` [070/127] USB: EHCI: fix obscure race in ehci_endpoint_disable Greg KH
2010-12-08  0:44 ` [071/127] USB: storage: sierra_ms: fix sysfs file attribute Greg KH
2010-12-08  0:44 ` [072/127] USB: atm: ueagle-atm: fix up some permissions on the sysfs files Greg KH
2010-12-08  0:44 ` [073/127] USB: misc: cypress_cy7c63: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [074/127] USB: misc: usbled: " Greg KH
2010-12-08  0:44 ` [075/127] USB: ftdi_sio: revert "USB: ftdi_sio: fix DTR/RTS line modes" Greg KH
2010-12-08  0:44 ` [076/127] USB: misc: trancevibrator: fix up a sysfs attribute permission Greg KH
2010-12-08  0:44 ` [077/127] USB: misc: usbsevseg: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [078/127] USB: ftdi_sio: Add ID for RT Systems USB-29B radio cable Greg KH
2010-12-08  0:44 ` [079/127] USB: serial: ftdi_sio: Vardaan USB RS422/485 converter PID added Greg KH
2010-12-08  0:44 ` [080/127] acpi-cpufreq: fix a memleak when unloading driver Greg KH
2010-12-08  0:44 ` [081/127] ACPI: EC: add Vista incompatibility DMI entry for Toshiba Satellite L355 Greg KH
2010-12-08  0:44 ` [082/127] fuse: fix attributes after open(O_TRUNC) Greg KH
2010-12-08  0:44 ` [083/127] do_exit(): make sure that we run with get_fs() == USER_DS Greg KH
2010-12-08  0:44 ` [084/127] uml: disable winch irq before freeing handler data Greg KH
2010-12-08  0:44 ` [085/127] backlight: grab ops_lock before testing bd->ops Greg KH
2010-12-08  0:44 ` [086/127] nommu: yield CPU while disposing VM Greg KH
2010-12-08  0:44 ` [087/127] DECnet: dont leak uninitialized stack byte Greg KH
2010-12-08  0:44 ` [088/127] perf_events: Fix perf_counter_mmap() hook in mprotect() Greg KH
2010-12-08  0:44 ` [089/127] ARM: 6489/1: thumb2: fix incorrect optimisation in usracc Greg KH
2010-12-08  0:44 ` [090/127] ARM: 6482/2: Fix find_next_zero_bit and related assembly Greg KH
2010-12-08  0:44 ` [091/127] Staging: frontier: fix up some sysfs attribute permissions Greg KH
2010-12-08  0:44 ` [092/127] staging: rtl8187se: Change panic to warn when RF switch turned off Greg KH
2010-12-08  0:44 ` [093/127] net sched: fix kernel leak in act_police Greg KH
2010-12-08  0:44 ` [094/127] HID: hidraw, fix a NULL pointer dereference in hidraw_ioctl Greg KH
2010-12-08  0:44 ` [095/127] HID: hidraw, fix a NULL pointer dereference in hidraw_write Greg KH
2010-12-08  0:44 ` [096/127] gianfar: Fix crashes on RX path (Was Re: [Bugme-new] [Bug 19692] New: linux-2.6.36-rc5 crash with gianfar ethernet at full line rate traffic) Greg KH
2010-12-08  0:44 ` [097/127] Limit sysctl_tcp_mem and sysctl_udp_mem initializers to prevent integer overflows Greg KH
2010-12-08  0:44 ` [098/127] sparc64: Fix race in signal instruction flushing Greg KH
2010-12-08  0:44 ` [099/127] sparc: Dont mask signal when we cant setup signal frame Greg KH
2010-12-08  0:44 ` [100/127] sparc: Prevent no-handler signal syscall restart recursion Greg KH
2010-12-08  0:44 ` [101/127] x86, UV: Delete unneeded boot messages Greg KH
2010-12-08  0:44 ` [102/127] x86, UV: Fix initialization of max_pnode Greg KH
2010-12-08  0:44 ` [103/127] drivers/video/efifb.c: support framebuffer for NVIDIA 9400M in MacBook Pro 5,1 Greg KH
2010-12-08  0:44 ` [104/127] efifb: support the EFI framebuffer on more Apple hardware Greg KH
2010-12-08  0:44 ` [105/127] V4L/DVB (13154): uvcvideo: Handle garbage at the end of streaming interface descriptors Greg KH
2010-12-08  0:44 ` [106/127] Input: i8042 - add Sony VAIO VPCZ122GX to nomux list Greg KH
2010-12-08  0:44 ` Greg KH [this message]
2010-12-08  0:44 ` [108/127] memory corruption in X.25 facilities parsing Greg KH
2010-12-08  0:44 ` [109/127] can-bcm: fix minor heap overflow Greg KH
2010-12-08  0:44 ` [110/127] V4L/DVB: ivtvfb: prevent reading uninitialized stack memory Greg KH
2010-12-08  0:44 ` [111/127] x25: Prevent crashing when parsing bad X.25 facilities Greg KH
2010-12-08  0:44 ` [112/127] crypto: padlock - Fix AES-CBC handling on odd-block-sized input Greg KH
2010-12-08  0:44 ` [113/127] x86-32: Separate 1:1 pagetables from swapper_pg_dir Greg KH
2010-12-08  0:45 ` [114/127] x86, mm: Fix CONFIG_VMSPLIT_1G and 2G_OPT trampoline Greg KH
2010-12-08  0:45 ` [115/127] x86-32: Fix dummy trampoline-related inline stubs Greg KH
2010-12-08  0:45 ` [116/127] econet: disallow NULL remote addr for sendmsg(), fixes CVE-2010-3849 Greg KH
2010-12-08  0:45 ` [117/127] econet: fix CVE-2010-3850 Greg KH
2010-12-08  0:45 ` [118/127] rds: Integer overflow in RDS cmsg handling Greg KH
2010-12-08  0:45 ` [119/127] net: Truncate recvfrom and sendto length to INT_MAX Greg KH
2010-12-08  0:45 ` [120/127] net: Limit socket I/O iovec total " Greg KH
2010-12-08  0:45 ` [121/127] [S390] nmi: fix clock comparator revalidation Greg KH
2010-12-08  8:04   ` Heiko Carstens
2010-12-08 17:13     ` Greg KH
2010-12-09  6:23       ` Heiko Carstens
2010-12-08 23:10     ` Greg KH
2010-12-08  0:45 ` [122/127] act_nat: use stack variable Greg KH
2010-12-08  0:45 ` [123/127] net sched: fix some kernel memory leaks Greg KH
2010-12-08  0:45 ` [124/127] UV - XPC: pass nasid instead of nid to gru_create_message_queue Greg KH
2010-12-08  0:45 ` [125/127] x86: uv: XPC receive message reuse triggers invalid BUG_ON() Greg KH
2010-12-08  0:45 ` [126/127] X86: uv: xpc_make_first_contact hang due to not accepting ACTIVE state Greg KH
2010-12-08  0:45 ` [127/127] x86: uv: xpc NULL deref when mesq becomes empty Greg KH

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=20101208004435.019108606@clark.site \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=john@calva.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.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®