stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Vlad Halilov <vlad.halilov@gmail.com>,
	Paul Moore <pmoore@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [13/88] netlabel: improve domain mapping validation
Date: Tue, 13 Aug 2013 11:57:07 -0400	[thread overview]
Message-ID: <20130813155825.705956535@goodmis.org> (raw)
In-Reply-To: 20130813155654.069291373@goodmis.org

[-- Attachment #1: 0013-netlabel-improve-domain-mapping-validation.patch --]
[-- Type: text/plain, Size: 3540 bytes --]

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

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

From: Paul Moore <pmoore@redhat.com>

[ Upstream commit 6b21e1b77d1a3d58ebfd513264c885695e8a0ba5 ]

The net/netlabel/netlabel_domainhash.c:netlbl_domhsh_add() function
does not properly validate new domain hash entries resulting in
potential problems when an administrator attempts to add an invalid
entry.  One such problem, as reported by Vlad Halilov, is a kernel
BUG (found in netlabel_domainhash.c:netlbl_domhsh_audit_add()) when
adding an IPv6 outbound mapping with a CIPSO configuration.

This patch corrects this problem by adding the necessary validation
code to netlbl_domhsh_add() via the newly created
netlbl_domhsh_validate() function.

Ideally this patch should also be pushed to the currently active
-stable trees.

Reported-by: Vlad Halilov <vlad.halilov@gmail.com>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 net/netlabel/netlabel_domainhash.c |   69 ++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index d8d4243..6bb1d42 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -245,6 +245,71 @@ static void netlbl_domhsh_audit_add(struct netlbl_dom_map *entry,
 	}
 }
 
+/**
+ * netlbl_domhsh_validate - Validate a new domain mapping entry
+ * @entry: the entry to validate
+ *
+ * This function validates the new domain mapping entry to ensure that it is
+ * a valid entry.  Returns zero on success, negative values on failure.
+ *
+ */
+static int netlbl_domhsh_validate(const struct netlbl_dom_map *entry)
+{
+	struct netlbl_af4list *iter4;
+	struct netlbl_domaddr4_map *map4;
+#if IS_ENABLED(CONFIG_IPV6)
+	struct netlbl_af6list *iter6;
+	struct netlbl_domaddr6_map *map6;
+#endif /* IPv6 */
+
+	if (entry == NULL)
+		return -EINVAL;
+
+	switch (entry->type) {
+	case NETLBL_NLTYPE_UNLABELED:
+		if (entry->type_def.cipsov4 != NULL ||
+		    entry->type_def.addrsel != NULL)
+			return -EINVAL;
+		break;
+	case NETLBL_NLTYPE_CIPSOV4:
+		if (entry->type_def.cipsov4 == NULL)
+			return -EINVAL;
+		break;
+	case NETLBL_NLTYPE_ADDRSELECT:
+		netlbl_af4list_foreach(iter4, &entry->type_def.addrsel->list4) {
+			map4 = netlbl_domhsh_addr4_entry(iter4);
+			switch (map4->type) {
+			case NETLBL_NLTYPE_UNLABELED:
+				if (map4->type_def.cipsov4 != NULL)
+					return -EINVAL;
+				break;
+			case NETLBL_NLTYPE_CIPSOV4:
+				if (map4->type_def.cipsov4 == NULL)
+					return -EINVAL;
+				break;
+			default:
+				return -EINVAL;
+			}
+		}
+#if IS_ENABLED(CONFIG_IPV6)
+		netlbl_af6list_foreach(iter6, &entry->type_def.addrsel->list6) {
+			map6 = netlbl_domhsh_addr6_entry(iter6);
+			switch (map6->type) {
+			case NETLBL_NLTYPE_UNLABELED:
+				break;
+			default:
+				return -EINVAL;
+			}
+		}
+#endif /* IPv6 */
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * Domain Hash Table Functions
  */
@@ -311,6 +376,10 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
 	struct netlbl_af6list *tmp6;
 #endif /* IPv6 */
 
+	ret_val = netlbl_domhsh_validate(entry);
+	if (ret_val != 0)
+		return ret_val;
+
 	/* XXX - we can remove this RCU read lock as the spinlock protects the
 	 *       entire function, but before we do we need to fixup the
 	 *       netlbl_af[4,6]list RCU functions to do "the right thing" with
-- 
1.7.10.4



  parent reply	other threads:[~2013-08-13 15:57 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-13 15:56 [00/88] 3.6.11.7-rc1-stable review Steven Rostedt
2013-08-13 15:56 ` [01/88] ALSA: usb-audio: Fix invalid volume resolution for Logitech HD Webcam c310 Steven Rostedt
2013-08-13 15:56 ` [02/88] ALSA: usb-audio: work around Android accessory firmware bug Steven Rostedt
2013-08-13 15:56 ` [03/88] clk: remove notifier from list before freeing it Steven Rostedt
2013-08-13 15:56 ` [04/88] tilepro: work around module link error with gcc 4.7 Steven Rostedt
2013-08-13 15:56 ` [05/88] carl9170: fix frame drop and WARN due to minstrel_ht change Steven Rostedt
2013-08-13 17:15   ` Luis Henriques
2013-08-13 20:00     ` Steven Rostedt
2013-08-13 15:57 ` [06/88] KVM: x86: remove vcpus CPL check in host-invoked XCR set Steven Rostedt
2013-08-13 15:57 ` [07/88] drm/radeon: prevent crash in the ring space allocation Steven Rostedt
2013-08-13 15:57 ` [08/88] drm/radeon: update lockup tracking when scheduling in empty ring Steven Rostedt
2013-08-13 15:57 ` [09/88] x86: fix build error and kconfig for ia32_emulation and binfmt Steven Rostedt
2013-08-13 15:57 ` [10/88] tcp: fix tcp_md5_hash_skb_data() Steven Rostedt
2013-08-13 15:57 ` [11/88] gianfar: add missing iounmap() on error in gianfar_ptp_probe() Steven Rostedt
2013-08-13 15:57 ` [12/88] ipv6: fix possible crashes in ip6_cork_release() Steven Rostedt
2013-08-13 15:57 ` Steven Rostedt [this message]
2013-08-13 15:57 ` [14/88] 8139cp: reset BQL when ring tx ring cleared Steven Rostedt
2013-08-13 15:57 ` [15/88] tcp: bug fix in proportional rate reduction Steven Rostedt
2013-08-13 15:57 ` [16/88] tcp: xps: fix reordering issues Steven Rostedt
2013-08-13 15:57 ` [17/88] ip_tunnel: fix kernel panic with icmp_dest_unreach Steven Rostedt
2013-08-13 15:57 ` [18/88] net: phy: fix a bug when verify the EEE support Steven Rostedt
2013-08-13 15:57 ` [19/88] ipv4: fix redirect handling for TCP packets Steven Rostedt
2013-08-13 15:57 ` [20/88] net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg Steven Rostedt
2013-08-13 15:57 ` [21/88] net: Unbreak compat_sys_{send,recv}msg Steven Rostedt
2013-08-13 15:57 ` [22/88] net/core/sock.c: add missing VSOCK string in af_family_*_key_strings Steven Rostedt
2013-08-13 15:57 ` [23/88] net: force a reload of first item in hlist_nulls_for_each_entry_rcu Steven Rostedt
2013-08-13 15:57 ` [24/88] ipv6: assign rt6_info to inet6_ifaddr in init_loopback Steven Rostedt
2013-08-13 15:57 ` [25/88] net: sctp: fix NULL pointer dereference in socket destruction Steven Rostedt
2013-08-13 15:57 ` [26/88] team: check return value of team_get_port_by_index_rcu() for NULL Steven Rostedt
2013-08-13 15:57 ` [27/88] team: move add to port list before port enablement Steven Rostedt
2013-08-13 15:57 ` [28/88] packet: packet_getname_spkt: make sure string is always 0-terminated Steven Rostedt
2013-08-13 15:57 ` [29/88] l2tp: Fix PPP header erasure and memory leak Steven Rostedt
2013-08-13 15:57 ` [30/88] l2tp: Fix sendmsg() return value Steven Rostedt
2013-08-13 15:57 ` [31/88] sctp: fully initialize sctp_outq in sctp_outq_init Steven Rostedt
2013-08-13 15:57 ` [32/88] net: sh_eth: fix incorrect RX length error if R8A7740 Steven Rostedt
2013-08-13 15:57 ` [33/88] Input: cyttsp - fix memcpy size param Steven Rostedt
2013-08-13 15:57 ` [34/88] USB: serial: ti_usb_3410_5052: new device id for Abbot strip port cable Steven Rostedt
2013-08-13 15:57 ` [35/88] tcm_qla2xxx: Fix residual for underrun commands that fail Steven Rostedt
2013-08-13 15:57 ` [36/88] target/iscsi: dont corrupt bh_count in iscsit_stop_time2retain_timer() Steven Rostedt
2013-08-13 15:57 ` [37/88] perf: Fix perf mmap bugs Steven Rostedt
2013-08-13 15:57 ` [38/88] perf: Fix mmap() accounting hole Steven Rostedt
2013-08-13 15:57 ` [39/88] ARM: 7755/1: handle user space mapped pages in flush_kernel_dcache_page Steven Rostedt
2013-08-13 15:57 ` [40/88] ARM: 7772/1: Fix missing flush_kernel_dcache_page() for noMMU Steven Rostedt
2013-08-13 15:57 ` [41/88] Bluetooth: Fix crash in l2cap_build_cmd() with small MTU Steven Rostedt
2013-08-13 15:57 ` [42/88] hw_breakpoint: Use cpu_possible_mask in {reserve,release}_bp_slot() Steven Rostedt
2013-08-13 15:57 ` [43/88] ath9k_htc: Handle IDLE state transition properly Steven Rostedt
2013-08-13 15:57 ` [44/88] iwlwifi: dvm: fix chain noise calibration Steven Rostedt
2013-08-13 15:57 ` [45/88] dlci: acquire rtnl_lock before calling __dev_get_by_name() Steven Rostedt
2013-08-13 15:57 ` [46/88] dlci: validate the net device in dlci_del() Steven Rostedt
2013-08-13 15:57 ` [47/88] iommu/vt-d: add quirk for broken interrupt remapping on 55XX chipsets Steven Rostedt
2013-08-13 15:57 ` [48/88] perf: Disable monitoring on setuid processes for regular users Steven Rostedt
2013-08-13 15:57 ` [49/88] crypto: algboss - Hold ref count on larval Steven Rostedt
2013-08-13 15:57 ` [50/88] UBIFS: prepare to fix a horrid bug Steven Rostedt
2013-08-13 15:57 ` [51/88] UBIFS: " Steven Rostedt
2013-08-13 15:57 ` [52/88] libata-acpi: add back ACPI based hotplug functionality Steven Rostedt
2013-08-13 15:57 ` [53/88] libceph: Fix NULL pointer dereference in auth client code Steven Rostedt
2013-08-13 15:57 ` [54/88] drivers/cdrom/cdrom.c: use kzalloc() for failing hardware Steven Rostedt
2013-08-13 15:57 ` [55/88] charger-manager: Ensure event is not used as format string Steven Rostedt
2013-08-13 15:57 ` [56/88] hpfs: better test for errors Steven Rostedt
2013-08-13 15:57 ` [57/88] block: do not pass disk names as format strings Steven Rostedt
2013-08-13 15:57 ` [58/88] crypto: sanitize argument for format string Steven Rostedt
2013-08-13 15:57 ` [59/88] MAINTAINERS: add stable_kernel_rules.txt to stable maintainer information Steven Rostedt
2013-08-13 15:57 ` [60/88] futex: Take hugepages into account when generating futex_key Steven Rostedt
2013-08-13 15:57 ` [61/88] nfsd4: fix decoding of compounds across page boundaries Steven Rostedt
2013-08-13 15:57 ` [62/88] sd: Fix parsing of temporary cache mode prefix Steven Rostedt
2013-08-13 15:57 ` [63/88] use sensible file nlink values if unprovided Steven Rostedt
2013-08-13 15:57 ` [64/88] rtlwifi: rtl8192cu: Fix duplicate if test Steven Rostedt
2013-08-13 15:57 ` [65/88] jbd2: move superblock checksum calculation to jbd2_write_superblock() Steven Rostedt
2013-08-13 15:58 ` [66/88] jbd2: fix theoretical race in jbd2__journal_restart Steven Rostedt
2013-08-13 15:58 ` [67/88] ext3,ext4: dont mess with dir_file->f_pos in htree_dirblock_to_tree() Steven Rostedt
2013-08-13 15:58 ` [68/88] usb: gadget: f_mass_storage: add missing memory barrier for thread_wakeup_needed Steven Rostedt
2013-08-13 15:58 ` [69/88] xhci: check for failed dma pool allocation Steven Rostedt
2013-08-13 15:58 ` [70/88] usb: host: xhci-plat: release mem region while removing module Steven Rostedt
2013-08-13 15:58 ` [71/88] drivers: hv: switch to use mb() instead of smp_mb() Steven Rostedt
2013-08-13 15:58 ` [72/88] pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status Steven Rostedt
2013-08-13 15:58 ` [73/88] cgroup: fix umount vs cgroup_event_remove() race Steven Rostedt
2013-08-13 15:58 ` [74/88] xen/time: remove blocked time accounting from xen "clockchip" Steven Rostedt
2013-08-13 15:58 ` [75/88] genirq: Fix can_request_irq() for IRQs without an action Steven Rostedt
2013-08-13 15:58 ` [76/88] drivers/rtc/rtc-rv3029c2.c: fix disabling AIE irq Steven Rostedt
2013-08-13 15:58 ` [77/88] ACPICA: Do not use extended sleep registers unless HW-reduced bit is set Steven Rostedt
2013-08-13 15:58 ` [78/88] ocfs2: xattr: fix inlined xattr reflink Steven Rostedt
2013-08-13 15:58 ` [79/88] nbd: correct disconnect behavior Steven Rostedt
2013-08-13 15:58 ` [80/88] PCI: Fix refcount issue in pci_create_root_bus() error recovery path Steven Rostedt
2013-08-13 15:58 ` [81/88] ahci: remove pmp link online check in FBS EH Steven Rostedt
2013-08-13 15:58 ` [82/88] timer: Fix jiffies wrap behavior of round_jiffies_common() Steven Rostedt
2013-08-13 15:58 ` [83/88] ext4: fix data offset overflow in ext4_xattr_fiemap() on 32-bit archs Steven Rostedt
2013-08-13 15:58 ` [84/88] ext4: fix overflow when counting used blocks on 32-bit architectures Steven Rostedt
2013-08-13 15:58 ` [85/88] ext4: dont allow ext4_free_blocks() to fail due to ENOMEM Steven Rostedt
2013-08-13 15:58 ` [86/88] drivers/dma/pl330.c: fix locking in pl330_free_chan_resources() Steven Rostedt
2013-08-13 15:58 ` [87/88] mm/memory-hotplug: fix lowmem count overflow when offline pages Steven Rostedt
2013-08-13 15:58 ` [88/88] Handle big endianness in NTLM (ntlmv2) authentication Steven Rostedt
2013-08-13 16:25 ` [00/88] 3.6.11.7-rc1-stable review Steven Rostedt

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=20130813155825.705956535@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmoore@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=vlad.halilov@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).