lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue,  1 Mar 2022 18:56:19 +0000
From:   SeongJae Park <sj@...nel.org>
To:     akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        SeongJae Park <sj@...nel.org>
Subject: [PATCH for-mm] mm/damon/sysfs: Fix out-of-bound array access for wmark_metric_strs[]

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@...nel.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ