From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: kernel-janitors@vger.kernel.org
Subject: Re: [tip:sched/numa 20/35] mm/mempolicy.c:2426 mpol_parse_str() error: buffer overflow 'policy_modes
Date: Mon, 01 Oct 2012 13:22:25 +0000 [thread overview]
Message-ID: <1349097745.7780.13.camel@twins> (raw)
On Fri, 2012-09-28 at 19:14 +0800, Fengguang Wu wrote:
> + mm/mempolicy.c:2426 mpol_parse_str() error: buffer overflow 'policy_modes' 5 <= 5
---
Subject: mm, mpol: Fix buffer overflow in mpol_parse_str()
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Mon Oct 01 15:12:16 CEST 2012
Wu reported a 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>
---
mm/mempolicy.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- 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 mem
break;
}
}
- if (mode >= MPOL_MAX)
+ if (mode >= MPOL_MAX || mode = MPOL_NOOP)
goto out;
switch (mode) {
reply other threads:[~2012-10-01 13:22 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=1349097745.7780.13.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=kernel-janitors@vger.kernel.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