Skip to contentSkip to conversation

Revert "zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()"

PATCH Superseded Greg Kroah-Hartman 4 participants 8 messages Jun 17, 2020 – Jun 23, 2020

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

PATCH 1/1 Revert "zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()"

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can write to this file.

[fixed formatting and made static - gregkh]

Cc stable <[email protected]>
Fixes f40609d1591f ("zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()")
---
 drivers/block/zram/zram_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +2 -1
index 6e2ad90b17a3..270dd810be54 100644
@@ -2021,7 +2021,8 @@ static ssize_t hot_add_show(struct class *class,
 		return ret;
 	return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
 }
-static CLASS_ATTR_RO(hot_add);
+static struct class_attribute class_attr_hot_add =
+	__ATTR(hot_add, 0400, hot_add_show, NULL);
 
 static ssize_t hot_remove_store(struct class *class,
 			struct class_attribute *attr,
Signature · 1 line
2.27.0
#1 lore raw
Quoted 4 lines · Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can write to this file.

Minor confusion on my side:
Did you mean "read from" instead of "write to"? I.e. only owner may read but not group nor others. Whereas using CLASS_ATTR_RO would resolve into 0444.

Quoted 27 lines

[fixed formatting and made static - gregkh]

Cc stable <[email protected]>
Fixes f40609d1591f ("zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()")
---
  drivers/block/zram/zram_drv.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +2 -1
index 6e2ad90b17a3..270dd810be54 100644
@@ -2021,7 +2021,8 @@ static ssize_t hot_add_show(struct class *class,
  		return ret;
  	return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  }
-static CLASS_ATTR_RO(hot_add);
+static struct class_attribute class_attr_hot_add =
+	__ATTR(hot_add, 0400, hot_add_show, NULL);
 
  static ssize_t hot_remove_store(struct class *class,
  			struct class_attribute *attr,
Signature · 11 lines
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z Development

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#2 lore raw
Quoted 10 lines · Steffen Maier
Quoted 4 lines · Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can write to this file.

Minor confusion on my side:
Did you mean "read from" instead of "write to"? I.e. only owner may read but not group nor others. Whereas using CLASS_ATTR_RO would resolve into 0444.

Sorry, you are correct, I'll fix the changelog text and send this out again.

It's a "fun" file, reading from it causes something to happen, not the normal way things work :(

greg k-h

#3 lore raw

PATCH v2 1/1 Revert "zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()"

In reply to Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can read from this file.

[fixed formatting, added changelog, and made attribute static - gregkh]

Cc stable <[email protected]>
Fixes f40609d1591f ("zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()")

---
v2: fix read/write confusion in the changelog, thanks to Steffen for the
review.
was more specific as to the changes I made to the original patch.

 drivers/block/zram/zram_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +2 -1
index 6e2ad90b17a3..270dd810be54 100644
@@ -2021,7 +2021,8 @@ static ssize_t hot_add_show(struct class *class,
 		return ret;
 	return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
 }
-static CLASS_ATTR_RO(hot_add);
+static struct class_attribute class_attr_hot_add =
+	__ATTR(hot_add, 0400, hot_add_show, NULL);
 
 static ssize_t hot_remove_store(struct class *class,
 			struct class_attribute *attr,
Signature · 1 line
2.27.0
Reviewed-by on v2 1/1
#4 lore raw
Quoted 5 lines · Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can read from this file.

Quoted 7 lines

[fixed formatting, added changelog, and made attribute static - gregkh]

Cc stable <[email protected]>
Fixes f40609d1591f ("zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()")
Quoted 23 lines

---
v2: fix read/write confusion in the changelog, thanks to Steffen for the
review.
was more specific as to the changes I made to the original patch.

  drivers/block/zram/zram_drv.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +2 -1
index 6e2ad90b17a3..270dd810be54 100644
@@ -2021,7 +2021,8 @@ static ssize_t hot_add_show(struct class *class,
  		return ret;
  	return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
  }
-static CLASS_ATTR_RO(hot_add);
+static struct class_attribute class_attr_hot_add =
+	__ATTR(hot_add, 0400, hot_add_show, NULL);
 
  static ssize_t hot_remove_store(struct class *class,
  			struct class_attribute *attr,
Signature · 11 lines
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z Development

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
maintainer Acked-by on v2 1/1
#5 lore raw
In reply to Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can read from this file.

Quoted 7 lines

[fixed formatting, added changelog, and made attribute static - gregkh]

Cc stable <[email protected]>
Fixes f40609d1591f ("zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()")
#6 lore raw
In reply to Greg Kroah-Hartman

Hi Greg,

Quoted 4 lines · Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can write to this file.

                         ^^^^^^^^

s/write to/read from/

As Wade reported, it's sufficient to read from it to create a zram entry.

Regards,
Willy

#7 lore raw
Quoted 11 lines · Willy Tarreau

Hi Greg,

Quoted 4 lines · Greg Kroah-Hartman

From: Wade Mealing <[email protected]>

Turns out that the permissions for 0400 really are what we want here, otherwise any user can write to this file.

                         ^^^^^^^^

s/write to/read from/

As Wade reported, it's sufficient to read from it to create a zram entry.

Bah I just saw your v2 now, sorry for the noise.

Willy