Skip to contentSkip to conversation

dlmfs: add a newline when printing 'capabilities' by sysfs

PATCH In review Xiongfeng Wang 2 participants 2 messages Jul 20, 2020 – Jul 21, 2020 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dlmfs: add a newline when printing 'capabilities' by sysfs

When I cat module parameter 'capabilities' by sysfs, it displays as follows. It's better to add a newline for easy reading.

root@syzkaller:~# cat /sys/module/ocfs2_dlmfs/parameters/capabilities
bast stackglueroot@syzkaller:~#
---
 fs/ocfs2/dlmfs/dlmfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/ocfs2/dlmfs/dlmfs.c +6 -1
index ea868c6f9800..1f9c864ec09b 100644
@@ -82,8 +82,13 @@ static int param_set_dlmfs_capabilities(const char *val,
 static int param_get_dlmfs_capabilities(char *buffer,
 					const struct kernel_param *kp)
 {
-	return strlcpy(buffer, DLMFS_CAPABILITIES,
+	int cnt;
+
+	cnt = strlcpy(buffer, DLMFS_CAPABILITIES,
 		       strlen(DLMFS_CAPABILITIES) + 1);
+	cnt += sprintf(buffer + cnt, "\n");
+
+	return cnt;
 }
 module_param_call(capabilities, param_set_dlmfs_capabilities,
 		  param_get_dlmfs_capabilities, NULL, 0444);
Signature · 1 line
2.20.1
#1 lore raw

Hi?

I am afraid that doing so might introduce a compatible risk into exited systems which reply ocfs2/dlmfs.

We can't guarantee that no system management tools is using the information reported from this file.

Basically, ocfs2-tools works of top of it. But after a quick glance at the source, I didn't see side effect if this path applied. Better you can do some test if this patch breaks ocfs2-tools.

Still my suggestion is that we don't try to touch this file as what I explained above.

Thanks,
Changwei

Quoted 31 lines · Xiongfeng Wang

When I cat module parameter 'capabilities' by sysfs, it displays as follows. It's better to add a newline for easy reading.

root at syzkaller:~# cat /sys/module/ocfs2_dlmfs/parameters/capabilities bast stackglueroot at syzkaller:~#

---
  fs/ocfs2/dlmfs/dlmfs.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
fs/ocfs2/dlmfs/dlmfs.c +6 -1
index ea868c6f9800..1f9c864ec09b 100644
@@ -82,8 +82,13 @@ static int param_set_dlmfs_capabilities(const char *val,
  static int param_get_dlmfs_capabilities(char *buffer,
  					const struct kernel_param *kp)
  {
-	return strlcpy(buffer, DLMFS_CAPABILITIES,
+	int cnt;
+
+	cnt = strlcpy(buffer, DLMFS_CAPABILITIES,
  		       strlen(DLMFS_CAPABILITIES) + 1);
+	cnt += sprintf(buffer + cnt, "\n");
+
+	return cnt;
  }
  module_param_call(capabilities, param_set_dlmfs_capabilities,
  		  param_get_dlmfs_capabilities, NULL, 0444);