linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Andy Lutomirski <luto@amacapital.net>,
	Eric Paris <eparis@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 066/111] auditsc: audit_krule mask accesses need bounds checking
Date: Mon, 23 Jun 2014 10:31:41 +0200	[thread overview]
Message-ID: <6004b0e5ac2e8e9e1bb0f012dc9242e03cca95df.1403512281.git.jslaby@suse.cz> (raw)
In-Reply-To: <55d5f044a1fc96a74e4470e318c0a24f27a9ab7e.1403512280.git.jslaby@suse.cz>
In-Reply-To: <cover.1403512280.git.jslaby@suse.cz>

From: Andy Lutomirski <luto@amacapital.net>

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

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

commit a3c54931199565930d6d84f4c3456f6440aefd41 upstream.

Fixes an easy DoS and possible information disclosure.

This does nothing about the broken state of x32 auditing.

eparis: If the admin has enabled auditd and has specifically loaded
audit rules.  This bug has been around since before git.  Wow...

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 kernel/auditsc.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 3b79a47ddb13..979c00bf24aa 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -733,6 +733,22 @@ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key)
 	return AUDIT_BUILD_CONTEXT;
 }
 
+static int audit_in_mask(const struct audit_krule *rule, unsigned long val)
+{
+	int word, bit;
+
+	if (val > 0xffffffff)
+		return false;
+
+	word = AUDIT_WORD(val);
+	if (word >= AUDIT_BITMASK_SIZE)
+		return false;
+
+	bit = AUDIT_BIT(val);
+
+	return rule->mask[word] & bit;
+}
+
 /* At syscall entry and exit time, this filter is called if the
  * audit_state is not low enough that auditing cannot take place, but is
  * also not high enough that we already know we have to write an audit
@@ -750,11 +766,8 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
 
 	rcu_read_lock();
 	if (!list_empty(list)) {
-		int word = AUDIT_WORD(ctx->major);
-		int bit  = AUDIT_BIT(ctx->major);
-
 		list_for_each_entry_rcu(e, list, list) {
-			if ((e->rule.mask[word] & bit) == bit &&
+			if (audit_in_mask(&e->rule, ctx->major) &&
 			    audit_filter_rules(tsk, &e->rule, ctx, NULL,
 					       &state, false)) {
 				rcu_read_unlock();
@@ -774,20 +787,16 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
 static int audit_filter_inode_name(struct task_struct *tsk,
 				   struct audit_names *n,
 				   struct audit_context *ctx) {
-	int word, bit;
 	int h = audit_hash_ino((u32)n->ino);
 	struct list_head *list = &audit_inode_hash[h];
 	struct audit_entry *e;
 	enum audit_state state;
 
-	word = AUDIT_WORD(ctx->major);
-	bit  = AUDIT_BIT(ctx->major);
-
 	if (list_empty(list))
 		return 0;
 
 	list_for_each_entry_rcu(e, list, list) {
-		if ((e->rule.mask[word] & bit) == bit &&
+		if (audit_in_mask(&e->rule, ctx->major) &&
 		    audit_filter_rules(tsk, &e->rule, ctx, n, &state, false)) {
 			ctx->current_state = state;
 			return 1;
-- 
2.0.0


  parent reply	other threads:[~2014-06-23  9:01 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  8:32 [PATCH 3.12 000/111] 3.12.23-stable review Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 001/111] ath9k: Fix sequence number assignment for non-data frames Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 002/111] rtlwifi: rtl8192se: Fix regression due to commit 1bf4bbb Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 003/111] xhci: extend quirk for Renesas cards Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 004/111] drm/i915: restrict vt-d stolen memory workaround to pre-gen8 Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 005/111] floppy: do not corrupt bio.bi_flags when reading block 0 Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 006/111] xhci: Switch only Intel Lynx Point-LP ports to EHCI on shutdown Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 007/111] MIPS: asm: thread_info: Add _TIF_SECCOMP flag Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 008/111] btrfs: fix defrag 32-bit integer overflow Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 009/111] target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 010/111] mm: compaction: reset cached scanner pfn's before reading them Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 011/111] mm: compaction: detect when scanners meet in isolate_freepages Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 012/111] mm/compaction: make isolate_freepages start at pageblock boundary Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 013/111] ARM: perf: hook up perf_sample_event_took around pmu irq handling Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 014/111] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap() Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 015/111] sched: Use CPUPRI_NR_PRIORITIES instead of MAX_RT_PRIO in cpupri check Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 016/111] sched: Sanitize irq accounting madness Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 017/111] perf: Prevent false warning in perf_swevent_add Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 018/111] perf: Limit perf_event_attr::sample_period to 63 bits Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 019/111] perf: Fix race in removing an event Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 020/111] mm/memory-failure.c: fix memory leak by race between poison and unpoison Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 021/111] Documentation: fix DOCBOOKS=... building Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 022/111] hwmon: (ntc_thermistor) Fix dependencies Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 023/111] hwmon: (ntc_thermistor) Fix OF device ID mapping Jiri Slaby
2014-06-23  8:30 ` [PATCH 3.12 024/111] drm/gf119-/disp: fix nasty bug which can clobber SOR0's clock setup Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 025/111] drm/radeon: also try GART for CPU accessed buffers Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 026/111] drm/radeon: handle non-VGA class pci devices with ATRM Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 027/111] SCSI: scsi_transport_sas: move bsg destructor into sas_rphy_remove Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 028/111] ARM: imx: fix error handling in ipu device registration Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 029/111] ARM: omap5: hwmod_data: Correct IDLEMODE for McPDM Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 030/111] ARM: OMAP3: clock: Back-propagate rate change from cam_mclk to dpll4_m5 on all OMAP3 platforms Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 031/111] ARM: 8051/1: put_user: fix possible data corruption in put_user Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 032/111] ARM: 8064/1: fix v7-M signal return Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 033/111] cpufreq: remove race while accessing cur_policy Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 034/111] dm cache: always split discards on cache block boundaries Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 035/111] sched: Fix hotplug vs. set_cpus_allowed_ptr() Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 036/111] drm/radeon: avoid crash if VM command submission isn't available Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 037/111] drm/i915: Only copy back the modified fields to userspace from execbuffer Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 038/111] libata: Blacklist queued trim for Crucial M500 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 039/111] md: always set MD_RECOVERY_INTR when aborting a reshape or other "resync" Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 040/111] md: always set MD_RECOVERY_INTR when interrupting a reshape thread Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 041/111] xhci: delete endpoints from bandwidth list before freeing whole device Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 042/111] Staging: speakup: Move pasting into a work item Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 043/111] staging: comedi: ni_daq_700: add mux settling delay Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 044/111] Staging: speakup: Update __speakup_paste_selection() tty (ab)usage to match vt Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 045/111] ALSA: hda/analog - Fix silent output on ASUS A8JN Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 046/111] ALSA: hda/realtek - Correction of fixup codes for PB V7900 laptop Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 047/111] ALSA: hda/realtek - Fix COEF widget NID for ALC260 replacer fixup Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 048/111] USB: ftdi_sio: add NovaTech OrionLXm product ID Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 049/111] usb: cdc-wdm: export cdc-wdm uapi header Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 050/111] USB: cdc-wdm: properly include types.h Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 051/111] USB: serial: option: add support for Novatel E371 PCIe card Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 052/111] USB: io_ti: fix firmware download on big-endian machines (part 2) Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 053/111] usb: pci-quirks: Prevent Sony VAIO t-series from switching usb ports Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 054/111] USB: Avoid runtime suspend loops for HCDs that can't handle suspend/resume Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 055/111] percpu-refcount: fix usage of this_cpu_ops Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 056/111] mm: rmap: fix use-after-free in __put_anon_vma Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 057/111] iser-target: Add missing target_put_sess_cmd for ImmedateData failure Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 058/111] target: Fix alua_access_state attribute OOPs for un-configured devices Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 059/111] gpio: mcp23s08: Bug fix of SPI device tree registration Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 060/111] [media] rtl28xxu: add 15f4:0131 Astrometa DVB-T2 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 061/111] [media] Add USB IDs for Winfast DTV Dongle Mini-D Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 062/111] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 063/111] Target/iscsi,iser: Avoid accepting transport connections during stop stage Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 064/111] iser-target: Fix multi network portal shutdown regression Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 065/111] target: Allow READ_CAPACITY opcode in ALUA Standby access state Jiri Slaby
2014-06-23  8:31 ` Jiri Slaby [this message]
2014-06-23  8:31 ` [PATCH 3.12 067/111] mei: me: drop harmful wait optimization Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 068/111] rtl28xxu: add ID [0ccd:00b4] TerraTec NOXON DAB Stick (rev 3) Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 069/111] rtl28xxu: add USB ID for Genius TVGo DVB-T03 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 070/111] rtl28xxu: add chipset version comments into device list Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 071/111] rtl28xxu: add 1b80:d395 Peak DVB-T USB Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 072/111] rtl28xxu: add [1b80:d39d] Sveon STV20 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 073/111] rtl28xxu: add [1b80:d3af] Sveon STV27 Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 074/111] ahci: Add Device ID for HighPoint RocketRaid 642L Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 075/111] ahci: add PCI ID for Marvell 88SE91A0 SATA Controller Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 076/111] drm/i915: Allow user modes to exceed DVI 165MHz limit Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 077/111] ima: audit log files opened with O_DIRECT flag Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 078/111] skbuff: skb_segment: s/frag/nskb_frag/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 079/111] skbuff: skb_segment: s/skb_frag/frag/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 080/111] skbuff: skb_segment: s/skb/head_skb/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 081/111] skbuff: skb_segment: s/fskb/list_skb/ Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 082/111] skbuff: skb_segment: orphan frags before copying Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 083/111] rtc: rtc-at91rm9200: fix infinite wait for ACKUPD irq Jiri Slaby
2014-06-23  8:31 ` [PATCH 3.12 084/111] iscsi-target: Reject mutual authentication with reflected CHAP_C Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 085/111] ima: introduce ima_kernel_read() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 086/111] evm: prohibit userspace writing 'security.evm' HMAC value Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 087/111] netlink: Rename netlink_capable netlink_allowed Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 088/111] net: Move the permission check in sock_diag_put_filterinfo to packet_diag_dump Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 089/111] net: Add variants of capable for use on on sockets Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 090/111] net: Add variants of capable for use on netlink messages Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 091/111] net: Use netlink_ns_capable to verify the permisions of " Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 092/111] netlink: Only check file credentials for implicit destinations Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 093/111] qlcnic: info leak in qlcnic_dcb_peer_app_info() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 094/111] netlink: rate-limit leftover bytes warning and print process name Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 095/111] bridge: Prevent insertion of FDB entry with disallowed vlan Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 096/111] net: tunnels - enable module autoloading Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 097/111] net: fix inet_getid() and ipv6_select_ident() bugs Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 098/111] team: fix mtu setting Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 099/111] tcp: fix cwnd undo on DSACK in F-RTO Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 100/111] sh_eth: use RNC mode for packet reception Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 101/111] sh_eth: fix SH7619/771x support Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 102/111] net: filter: fix typo in sparc BPF JIT Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 103/111] net: filter: fix sparc32 typo Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 104/111] net: qmi_wwan: add Olivetti Olicard modems Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 105/111] net: force a list_del() in unregister_netdevice_many() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 106/111] ipip, sit: fix ipv4_{update_pmtu,redirect} calls Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 107/111] ipv4: fix a race in ip4_datagram_release_cb() Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 108/111] sctp: Fix sk_ack_backlog wrap-around problem Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 109/111] rtnetlink: fix userspace API breakage for iproute2 < v3.9.0 Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 110/111] vxlan: use dev->needed_headroom instead of dev->hard_header_len Jiri Slaby
2014-06-23  8:32 ` [PATCH 3.12 111/111] ARM: at91: fix at91_sysirq_mask_rtc for sam9x5 SoCs Jiri Slaby
2014-06-23 14:55 ` [PATCH 3.12 000/111] 3.12.23-stable review Guenter Roeck
2014-06-25 13:29   ` Jiri Slaby
2014-06-23 16:45 ` Shuah Khan
2014-06-23 22:13 ` Satoru Takeuchi

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=6004b0e5ac2e8e9e1bb0f012dc9242e03cca95df.1403512281.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).