Skip to contentSkip to conversation

sysfs/cpu: Make crash_hotplug attribute world-readable

PATCH In review Petr Tesarik 4 participants 8 messages Jul 11, 2024 – Jul 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysfs/cpu: Make crash_hotplug attribute world-readable

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Note that since commit 79365026f8694 ("crash: add a new kexec flag for hotplug support"), this maps to the same flag which is world-accessible through /sys/devices/system/memory/crash_hotplug.

---
 drivers/base/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +1 -1
index c61ecb0c2ae2..73d69791d0d3 100644
@@ -308,7 +308,7 @@ static ssize_t crash_hotplug_show(struct device *dev,
 {
 	return sysfs_emit(buf, "%d\n", crash_check_hotplug_support());
 }
-static DEVICE_ATTR_ADMIN_RO(crash_hotplug);
+static DEVICE_ATTR_RO(crash_hotplug);
 #endif
 
 static void cpu_device_release(struct device *dev)
Signature · 1 line
2.45.2
#1 lore raw

Forgot to Cc Sourabh Jain.

Quoted 28 lines · On Thu, 11 Jul 2024 12:34:09 +0200 Petr Tesarik <[email protected]> wrote:

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Note that since commit 79365026f8694 ("crash: add a new kexec flag for hotplug support"), this maps to the same flag which is world-accessible through /sys/devices/system/memory/crash_hotplug.

---
 drivers/base/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +1 -1
index c61ecb0c2ae2..73d69791d0d3 100644
@@ -308,7 +308,7 @@ static ssize_t crash_hotplug_show(struct device *dev,
 {
 	return sysfs_emit(buf, "%d\n", crash_check_hotplug_support());
 }
-static DEVICE_ATTR_ADMIN_RO(crash_hotplug);
+static DEVICE_ATTR_RO(crash_hotplug);
 #endif
 
 static void cpu_device_release(struct device *dev)
Acked-by on v1 1/1
#2 lore raw
In reply to Petr Tesarik
Quoted 20 lines · Petr Tesarik

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Note that since commit 79365026f8694 ("crash: add a new kexec flag for hotplug support"), this maps to the same flag which is world-accessible through /sys/devices/system/memory/crash_hotplug.

---
 drivers/base/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +0 -0
index c61ecb0c2ae2..73d69791d0d3 100644

drivers/base/cpu.c static ssize_t crash_hotplug_show(struct device *dev, · line 311

Quoted 5 lines
drivers/base/cpu.c +1 -1
@@ -308,7 +308,7 @@ static ssize_t crash_hotplug_show(struct device *dev,
 {
 	return sysfs_emit(buf, "%d\n", crash_check_hotplug_support());
 }
-static DEVICE_ATTR_ADMIN_RO(crash_hotplug);
+static DEVICE_ATTR_RO(crash_hotplug);

Agree. I guess this was copied from codes related to crash_notes/crash_notes_size. While crash_notes/crash_notes_size are in /sys/devices/system/cpu/cpuX/ which is next level.

Acked-by on v1 1/1
#3 lore raw
In reply to Petr Tesarik

Hello Petr,

Just want to mentioned few points about the commit message. No strong opinion on changing the commit message.

Quoted 5 lines · Petr Tesarik

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Now, it is not just elfcorehdr; there could be multiple kexec segments based on the architecture's needs. For example, on PowerPC, it is elfcorehdr and FDT.

Quoted 4 lines

Note that since commit 79365026f8694 ("crash: add a new kexec flag for hotplug support"), this maps to the same flag which is world-accessible through /sys/devices/system/memory/crash_hotplug.

The previous comment is more relevant for the kexec_load system call.

For the kexec_file_load system call, the kexec flag introduced in the commit message mentioned above is irrelevant. Building kernel with CONFIG_CRASH_HOTPLUG is enough.

Quoted 10 lines
---
  drivers/base/cpu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +0 -0
index c61ecb0c2ae2..73d69791d0d3 100644

drivers/base/cpu.c static ssize_t crash_hotplug_show(struct device *dev, · line 311

Quoted 5 lines
drivers/base/cpu.c +1 -1
@@ -308,7 +308,7 @@ static ssize_t crash_hotplug_show(struct device *dev,
  {
  	return sysfs_emit(buf, "%d\n", crash_check_hotplug_support());
  }
-static DEVICE_ATTR_ADMIN_RO(crash_hotplug);
+static DEVICE_ATTR_RO(crash_hotplug);

I agree, it doesn't have to be readable by admin only.

Thanks for the patch.
- Sourabh

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
Quoted 8 lines · On Fri, 12 Jul 2024 10:00:09 +0530 Sourabh Jain <[email protected]>…

Hello Petr,

Just want to mentioned few points about the commit message. No strong opinion on changing the commit message.

Quoted 2 lines · Petr Tesarik

From: Petr Tesarik <[email protected]>

Quoted 7 lines
Quoted 3 lines

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Now, it is not just elfcorehdr; there could be multiple kexec segments based on the architecture's needs.
For example, on PowerPC, it is elfcorehdr and FDT.

Right. I am even working with a PowerVM LPAR on an L922 system now. ;-)

OTOH I was just too lazy to invent my own description, so I took it from Documentation/ABI/testing/sysfs-devices-system-cpu. That one could be improved. And a couple of other places... Expect a patch.

Quoted 11 lines
Quoted 4 lines

Note that since commit 79365026f8694 ("crash: add a new kexec flag for hotplug support"), this maps to the same flag which is world-accessible through /sys/devices/system/memory/crash_hotplug.

The previous comment is more relevant for the kexec_load system call.

For the kexec_file_load system call, the kexec flag introduced in the commit message
mentioned above is irrelevant. Building kernel with CONFIG_CRASH_HOTPLUG is enough.

Yes, but then this sysfs attribute always reads "1".

Quoted 18 lines
Quoted 10 lines
---
  drivers/base/cpu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +0 -0
index c61ecb0c2ae2..73d69791d0d3 100644

drivers/base/cpu.c static ssize_t crash_hotplug_show(struct device · line 311

Quoted 5 lines
drivers/base/cpu.c +1 -1
@@ -308,7 +308,7 @@ static ssize_t crash_hotplug_show(struct device
 *dev, {
  	return sysfs_emit(buf, "%d\n",
 crash_check_hotplug_support()); }
-static DEVICE_ATTR_ADMIN_RO(crash_hotplug);
+static DEVICE_ATTR_RO(crash_hotplug);  

I agree, it doesn't have to be readable by admin only.

Quoted 1 line

Thank you!

Petr T

#5 lore raw

Hello Petr,

Quoted 14 lines · Petr Tesařík
Quoted 11 lines · On Fri, 12 Jul 2024 10:00:09 +0530 Sourabh Jain <[email protected]>…

Hello Petr,

Just want to mentioned few points about the commit message. No strong opinion on changing the commit message.

Quoted 5 lines · Petr Tesarik

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Quoted 8 lines
Quoted 3 lines

Now, it is not just elfcorehdr; there could be multiple kexec segments based on the architecture's needs.
For example, on PowerPC, it is elfcorehdr and FDT.

Right. I am even working with a PowerVM LPAR on an L922 system now. ;-)

OTOH I was just too lazy to invent my own description, so I took it from Documentation/ABI/testing/sysfs-devices-system-cpu. That one could be improved. And a couple of other places... Expect a patch.

Thanks for point it out, I will send a patch to fix the ABI document for crash_hotplug and other places in the kernel. Thanks, Sourabh Jain

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw
Quoted 20 lines · On Fri, 12 Jul 2024 12:01:29 +0530 Sourabh Jain <[email protected]>…

Hello Petr,

Quoted 17 lines · Petr Tesařík
Quoted 14 lines · On Fri, 12 Jul 2024 10:00:09 +0530 Sourabh Jain <[email protected]>…

Hello Petr,

Just want to mentioned few points about the commit message. No strong opinion on changing the commit message.

Quoted 5 lines · Petr Tesarik

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Now, it is not just elfcorehdr; there could be multiple kexec segments based on the architecture's needs.
For example, on PowerPC, it is elfcorehdr and FDT.

Quoted 7 lines
Quoted 5 lines

Right. I am even working with a PowerVM LPAR on an L922 system now. ;-)

OTOH I was just too lazy to invent my own description, so I took it from Documentation/ABI/testing/sysfs-devices-system-cpu. That one could be improved. And a couple of other places... Expect a patch.

Thanks for point it out, I will send a patch to fix the ABI document for crash_hotplug and other places in the kernel. Thanks,

Oh, I was planning to do that, but if you want to send a patch yourself, I won't duplicate efforts. There are other cleanups on my TODO list.

Petr T

#7 lore raw
Quoted 25 lines · Petr Tesarik
Quoted 22 lines · On Fri, 12 Jul 2024 12:01:29 +0530 Sourabh Jain <[email protected]>…

Hello Petr,

Quoted 19 lines · Petr Tesařík
Quoted 6 lines · On Fri, 12 Jul 2024 10:00:09 +0530 Sourabh Jain <[email protected]>…

Hello Petr,

Just want to mentioned few points about the commit message. No strong opinion on changing the commit message.

On 11/07/24 16:04, Petr Tesarik wrote:

Quoted 8 lines
Quoted 5 lines

From: Petr Tesarik <[email protected]>

There is no reason to restrict access to this attribute, as it merely reports whether crash elfcorehdr is automatically updated on CPU hot plug/unplug and/or online/offline events.

Now, it is not just elfcorehdr; there could be multiple kexec segments based on the architecture's needs.
For example, on PowerPC, it is elfcorehdr and FDT.

Right. I am even working with a PowerVM LPAR on an L922 system now. ;-)

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

OTOH I was just too lazy to invent my own description, so I took it from Documentation/ABI/testing/sysfs-devices-system-cpu. That one could be improved. And a couple of other places... Expect a patch.

Thanks for point it out, I will send a patch to fix the ABI document for crash_hotplug and other places in the kernel. Thanks,

Oh, I was planning to do that, but if you want to send a patch yourself, I won't duplicate efforts. There are other cleanups on my TODO list.

Yes, I will take care of this.

Thanks,
Sourabh Jain

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec