linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] DAMON dbgfs_mk_context() error handling
@ 2022-08-12 18:01 Pulavarty, Badari
  2022-08-14 16:32 ` SeongJae Park
  0 siblings, 1 reply; 7+ messages in thread
From: Pulavarty, Badari @ 2022-08-12 18:01 UTC (permalink / raw)
  To: damon; +Cc: linux-mm

damon dbgfs_mk_context() does not handle error from debugfs_create_dir() correctly.

For example, if one tries to create a context with existing name, debugfs_create_dir() fails
with -EEXIST, but dbgfs_mk_context() assumes the call is successful and adds another entry - which
will cause failures when try to enable the monitor.

Test case:

echo "off" >  /sys/kernel/debug/damon/monitor_on
echo "abc" > /sys/kernel/debug/damon/mk_context
echo "abc" > /sys/kernel/debug/damon/mk_context
echo <pid> > /sys/kernel/debug/damon/target_ids
echo "on" > /sys/kernel/debug/damon/monitor_on  <<< fails to enable monitor

Signed-off-by: Badari Pulavarty badari.pulavarty@intel.com
---
--- orig/mm/damon/dbgfs.c       2022-08-05 13:35:54.416831666 -0400
+++ new/mm/damon/dbgfs.c        2022-08-05 13:44:25.121849930 -0400
@@ -721,6 +721,9 @@ static int dbgfs_mk_context(char *name)
                return -ENOENT;

        new_dir = debugfs_create_dir(name, root);
+       if (IS_ERR(new_dir)) {
+               return PTR_ERR(new_dir);
+       }
        dbgfs_dirs[dbgfs_nr_ctxs] = new_dir;

        new_ctx = dbgfs_new_ctx();


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH] DAMON dbgfs_mk_context() error handling
@ 2022-08-12 17:57 Pulavarty, Badari
  0 siblings, 0 replies; 7+ messages in thread
From: Pulavarty, Badari @ 2022-08-12 17:57 UTC (permalink / raw)
  To: damon; +Cc: linux-mm

[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]

damon dbgfs_mk_context() does not handle error from debugfs_create_dir() correctly.

For example, if one tries to create a context with existing name, debugfs_create_dir() fails
with -EEXIST, but dbgfs_mk_context() assumes the call is successful and adds another entry - which
will cause failures when try to enable the monitor.

Test case:

echo "off" >  /sys/kernel/debug/damon/monitor_on
echo "abc" > /sys/kernel/debug/damon/mk_context
echo "abc" > /sys/kernel/debug/damon/mk_context
echo <pid> > /sys/kernel/debug/damon/target_ids
echo "on" > /sys/kernel/debug/damon/monitor_on  <<< fails to enable monitor


Signed-off-by: Badari Pulavarty badari.pulavarty@intel.com<mailto:badari.pulavarty@intel.com>
---
--- orig/mm/damon/dbgfs.c       2022-08-05 13:35:54.416831666 -0400
+++ new/mm/damon/dbgfs.c        2022-08-05 13:44:25.121849930 -0400
@@ -721,6 +721,9 @@ static int dbgfs_mk_context(char *name)
                return -ENOENT;

        new_dir = debugfs_create_dir(name, root);
+       if (IS_ERR(new_dir)) {
+               return PTR_ERR(new_dir);
+       }
        dbgfs_dirs[dbgfs_nr_ctxs] = new_dir;

        new_ctx = dbgfs_new_ctx();

[-- Attachment #2: Type: text/html, Size: 4245 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-16  0:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 18:01 [PATCH] DAMON dbgfs_mk_context() error handling Pulavarty, Badari
2022-08-14 16:32 ` SeongJae Park
2022-08-15 21:51   ` Pulavarty, Badari
2022-08-15 23:42     ` SeongJae Park
2022-08-15 23:54       ` Pulavarty, Badari
2022-08-16  0:12       ` SeongJae Park
  -- strict thread matches above, loose matches on Subject: below --
2022-08-12 17:57 Pulavarty, Badari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox