diff --git a/module/lsm.c b/module/lsm.c index 092146b5f..3bf5457da 100644 --- a/module/lsm.c +++ b/module/lsm.c @@ -667,11 +667,6 @@ static int subdomain_getprocattr(struct task_struct *p, char *name, void *value, goto out; } - if (!size) { - error = -ERANGE; - goto out; - } - /* must be task querying itself or admin */ if (current != p && !capable(CAP_SYS_ADMIN)) { error = -EPERM; diff --git a/module/procattr.c b/module/procattr.c index 952ae0e41..4eb1d7b4a 100644 --- a/module/procattr.c +++ b/module/procattr.c @@ -52,6 +52,8 @@ size_t sd_getprocattr(struct subdomain *sd, char *str, size_t size) str += lenm; *str++ = '\n'; error = len; + } else if (size == 0) { + error = len; } else { error = -ERANGE; } @@ -63,6 +65,8 @@ size_t sd_getprocattr(struct subdomain *sd, char *str, size_t size) if (len <= size) { memcpy(str, unconstrained_str, len); error = len; + } else if (size == 0) { + error = len; } else { error = -ERANGE; }