Skip to contentSkip to conversation

block: grant IOPRIO_CLASS_RT to CAP_SYS_NICE

PATCH In review Khazhismel Kumykov 4 participants 5 messages Aug 24, 2020 – Sep 1, 2020

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

PATCH v2 1/1 block: grant IOPRIO_CLASS_RT to CAP_SYS_NICE

CAP_SYS_ADMIN is too broad, and ionice fits into CAP_SYS_NICE's grouping.

Retain CAP_SYS_ADMIN permission for backwards compatibility.

---
 block/ioprio.c                  | 2 +-
 include/uapi/linux/capability.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

v2: fix embarrassing logic mistake

block/ioprio.c +1 -1
index 77bcab11dce5..276496246fe9 100644
@@ -69,7 +69,7 @@ int ioprio_check_cap(int ioprio)
 
 	switch (class) {
 		case IOPRIO_CLASS_RT:
-			if (!capable(CAP_SYS_ADMIN))
+			if (!capable(CAP_SYS_NICE) && !capable(CAP_SYS_ADMIN))
 				return -EPERM;
 			/* fall through */
 			/* rt has prio field too */
include/uapi/linux/capability.h +2 -0
index 395dd0df8d08..c6ca33034147 100644
@@ -288,6 +288,8 @@ struct vfs_ns_cap_data {
    processes and setting the scheduling algorithm used by another
    process. */
 /* Allow setting cpu affinity on other processes */
+/* Allow setting realtime ioprio class */
+/* Allow setting ioprio class on other processes */
 
 #define CAP_SYS_NICE         23
 
Signature · 1 line
2.28.0.297.g1956fa8f8d-goog
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Khazhismel Kumykov

CAP_SYS_ADMIN is too broad, and ionice fits into CAP_SYS_NICE's grouping.

Retain CAP_SYS_ADMIN permission for backwards compatibility.

Quoted 34 lines
---
 block/ioprio.c                  | 2 +-
 include/uapi/linux/capability.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

v2: fix embarrassing logic mistake

block/ioprio.c +1 -1
index 77bcab11dce5..276496246fe9 100644
@@ -69,7 +69,7 @@ int ioprio_check_cap(int ioprio)
 
 	switch (class) {
 		case IOPRIO_CLASS_RT:
-			if (!capable(CAP_SYS_ADMIN))
+			if (!capable(CAP_SYS_NICE) && !capable(CAP_SYS_ADMIN))
 				return -EPERM;
 			/* fall through */
 			/* rt has prio field too */
include/uapi/linux/capability.h +2 -0
index 395dd0df8d08..c6ca33034147 100644
@@ -288,6 +288,8 @@ struct vfs_ns_cap_data {
    processes and setting the scheduling algorithm used by another
    process. */
 /* Allow setting cpu affinity on other processes */
+/* Allow setting realtime ioprio class */
+/* Allow setting ioprio class on other processes */
 
 #define CAP_SYS_NICE         23
 
Signature · 1 line
2.28.0.297.g1956fa8f8d-goog
Reviewed-by on v2 1/1
#2 lore raw
In reply to Khazhismel Kumykov
Quoted 29 lines · Khazhismel Kumykov

CAP_SYS_ADMIN is too broad, and ionice fits into CAP_SYS_NICE's grouping.

Retain CAP_SYS_ADMIN permission for backwards compatibility.

---
 block/ioprio.c                  | 2 +-
 include/uapi/linux/capability.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

v2: fix embarrassing logic mistake

block/ioprio.c +1 -1
index 77bcab11dce5..276496246fe9 100644
@@ -69,7 +69,7 @@ int ioprio_check_cap(int ioprio)
 
 	switch (class) {
 		case IOPRIO_CLASS_RT:
-			if (!capable(CAP_SYS_ADMIN))
+			if (!capable(CAP_SYS_NICE) && !capable(CAP_SYS_ADMIN))
 				return -EPERM;
 			/* fall through */
 			/* rt has prio field too */
include/uapi/linux/capability.h +0 -0
index 395dd0df8d08..c6ca33034147 100644

include/uapi/linux/capability.h struct vfs_ns_cap_data { · line 294

Quoted 7 lines
include/uapi/linux/capability.h +2 -0
@@ -288,6 +288,8 @@ struct vfs_ns_cap_data {
    processes and setting the scheduling algorithm used by another
    process. */
 /* Allow setting cpu affinity on other processes */
+/* Allow setting realtime ioprio class */
+/* Allow setting ioprio class on other processes */
 
 #define CAP_SYS_NICE         23

From https://www.kernel.org/doc/man-pages/linux-api-ml.html:
"all Linux kernel patches that change userspace interfaces should be CCed to [email protected]"

So I have added the linux-api mailing list to the Cc-list. Anyway:

maintainer
#4 lore raw
Quoted 6 lines · Khazhismel Kumykov
Quoted 5 lines · Bart Van Assche

From https://www.kernel.org/doc/man-pages/linux-api-ml.html:
"all Linux kernel patches that change userspace interfaces should be CCed to [email protected]"

Quoted 6 lines
Quoted 1 line

So I have added the linux-api mailing list to the Cc-list. Anyway:

Thanks, sorry for missing that!

Quoted 2 lines

Jens, does this change look good?

Yes, I'll queue it up for 5.10.

Signature · 1 line
Jens Axboe