From: tip-bot for Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
akpm@linux-foundation.org, a.p.zijlstra@chello.nl,
tglx@linutronix.de, fengguang.wu@intel.com
Subject: [tip:sched/numa] mm/mpol: Fix potential buffer overflow in mpol_parse_str()
Date: Fri, 5 Oct 2012 06:06:34 -0700 [thread overview]
Message-ID: <tip-i0egmq9r7tzocxo5pmc8jbfi@git.kernel.org> (raw)
Commit-ID: b9fb9910378947a2b7d58ca75d805b907929e001
Gitweb: http://git.kernel.org/tip/b9fb9910378947a2b7d58ca75d805b907929e001
Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Mon, 1 Oct 2012 15:12:16 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 5 Oct 2012 14:00:30 +0200
mm/mpol: Fix potential buffer overflow in mpol_parse_str()
Wu reported an Smatch error:
+ mm/mempolicy.c:2426 mpol_parse_str() error: buffer overflow 'policy_modes' 5 <= 5
Fix it by growing the array to the right size, but avoid it being a
valid string for mpol_parse_str() because its not an effective policy.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/n/tip-i0egmq9r7tzocxo5pmc8jbfi@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
mm/mempolicy.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 7b4ff19..e59756a 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2514,7 +2514,8 @@ static const char * const policy_modes[] =
[MPOL_PREFERRED] = "prefer",
[MPOL_BIND] = "bind",
[MPOL_INTERLEAVE] = "interleave",
- [MPOL_LOCAL] = "local"
+ [MPOL_LOCAL] = "local",
+ [MPOL_NOOP] = "noop", /* should not actually be used */
};
@@ -2565,7 +2566,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
break;
}
}
- if (mode >= MPOL_MAX)
+ if (mode >= MPOL_MAX || mode == MPOL_NOOP)
goto out;
switch (mode) {
reply other threads:[~2012-10-05 13:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=tip-i0egmq9r7tzocxo5pmc8jbfi@git.kernel.org \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome