From: SeongJae Park <sj@kernel.org>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
SeongJae Park <sj@kernel.org>
Subject: [PATCH for-mm] mm/damon/sysfs: Fix out-of-bound array access for wmark_metric_strs[]
Date: Tue, 1 Mar 2022 18:56:19 +0000 [thread overview]
Message-ID: <20220301185619.2904-1-sj@kernel.org> (raw)
Commit 7a8630be880e ("mm/damon/sysfs: support DAMOS watermarks") on -mm
tree which introduced by a patch[1] titled
mm-damon-sysfs-support-damos-watermarks.patch allows out-of-bound access
to damon_sysfs_wmark_metric_strs[] array due to wrong bound check. This
commit fixes the wrong bound check. The issue has found by Coverity
report for linux-next.
[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-damon-sysfs-support-damos-watermarks.patch
Addresses-Coverity: ("Out-of-bounds read")
Fixes: 7a8630be880e ("mm/damon/sysfs: support DAMOS watermarks")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 32a9d21c0db5..fda2506c676f 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -266,7 +266,7 @@ static ssize_t metric_store(struct kobject *kobj, struct kobj_attribute *attr,
struct damon_sysfs_watermarks, kobj);
enum damos_wmark_metric metric;
- for (metric = 0; metric <= NR_DAMOS_WMARK_METRICS; metric++) {
+ for (metric = 0; metric < NR_DAMOS_WMARK_METRICS; metric++) {
if (sysfs_streq(buf, damon_sysfs_wmark_metric_strs[metric])) {
watermarks->metric = metric;
return count;
--
2.17.1
reply other threads:[~2022-03-01 18:56 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=20220301185619.2904-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.