stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Andy Lutomirski <luto@amacapital.net>,
	Eric Paris <eparis@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3.15 03/12] auditsc: audit_krule mask accesses need bounds checking
Date: Thu, 12 Jun 2014 16:21:05 -0700	[thread overview]
Message-ID: <20140612232045.042866426@linuxfoundation.org> (raw)
In-Reply-To: <20140612232044.886466924@linuxfoundation.org>

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

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

From: Andy Lutomirski <luto@amacapital.net>

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/auditsc.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -728,6 +728,22 @@ static enum audit_state audit_filter_tas
 	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
@@ -745,11 +761,8 @@ static enum audit_state audit_filter_sys
 
 	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();
@@ -769,20 +782,16 @@ static enum audit_state audit_filter_sys
 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;



  parent reply	other threads:[~2014-06-12 23:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12 23:21 [PATCH 3.15 00/12] 3.15.1-stable review Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 01/12] fs,userns: Change inode_capable to capable_wrt_inode_uidgid Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 02/12] lock_parent: dont step on stale ->d_parent of all-but-freed one Greg Kroah-Hartman
2014-06-12 23:21 ` Greg Kroah-Hartman [this message]
2014-06-12 23:21 ` [PATCH 3.15 04/12] PCI/MSI: Fix memory leak in free_msi_irqs() Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 05/12] mei: me: fix hw ready reset flow Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 06/12] mei: me: drop harmful wait optimization Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 07/12] mei: me: read H_CSR after asserting reset Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 08/12] [media] rtl28xxu: add 1b80:d395 Peak DVB-T USB Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 09/12] [media] rtl28xxu: add [1b80:d39d] Sveon STV20 Greg Kroah-Hartman
2014-06-12 23:21 ` [PATCH 3.15 10/12] [media] rtl28xxu: add [1b80:d3af] Sveon STV27 Greg Kroah-Hartman
2014-06-13 15:16 ` [PATCH 3.15 00/12] 3.15.1-stable review Guenter Roeck
2014-06-13 16:07   ` Greg Kroah-Hartman
2014-06-13 16:18     ` Guenter Roeck
2014-06-14 10:31   ` Satoru Takeuchi
2014-06-14 14:41     ` Greg Kroah-Hartman

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=20140612232045.042866426@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --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).