Skip to contentSkip to conversation

block: grant IOPRIO_CLASS_RT to CAP_SYS_NICE

PATCH Superseded Khazhismel Kumykov 1 participant 2 messages Aug 24, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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(-)
block/ioprio.c +1 -1
index 77bcab11dce5..4572456430f9 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_ADMIN) || !capable(CAP_SYS_NICE))
 				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
#1 lore raw
Quoted 16 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(-)
block/ioprio.c +0 -0
index 77bcab11dce5..4572456430f9 100644

block/ioprio.c int ioprio_check_cap(int ioprio) · line 72

Quoted 5 lines
block/ioprio.c +1 -1
@@ -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_ADMIN) || !capable(CAP_SYS_NICE))

yikes, sorry for the spam

Quoted 19 lines
block/ioprio.c +0 -0
                                return -EPERM;
                        /* fall through */
                        /* rt has prio field too */
include/uapi/linux/capability.h +2 -1
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
 
--

2.28.0.297.g1956fa8f8d-goog