Skip to contentSkip to conversation

fs/proc01.c:add known issues

PATCH New Xinpeng Liu 3 participants 6 messages Jan 15, 2021 – Jan 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/proc01.c:add known issues

Test in ubuntu20.10,there are several failure tests.

proc01 1 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 2 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 3 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/exec: errno=EINVAL(22): Invalid argument
proc01 4 TFAIL : proc01.c:396: read failed:
/proc/self/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 5 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 6 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

---
 testcases/kernel/fs/proc/proc01.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
testcases/kernel/fs/proc/proc01.c +5 -1
index 9684369..96441d1 100644
@@ -63,7 +63,7 @@ static char *opt_maxmbytesstr;
 static char *procpath = "/proc";
 static const char selfpath[] = "/proc/self";
 size_t buffsize = 1024;
-static long long maxbytes;
+static unsigned long long maxbytes;
 
 unsigned long long total_read;
 unsigned int total_obj;
@@ -97,7 +97,11 @@ static const struct mapping known_issues[] = {
 	{"read", "/proc/self/mem", EIO},
 	{"read", "/proc/self/task/[0-9]*/mem", EIO},
 	{"read", "/proc/self/attr/*", EINVAL},
+	{"read", "/proc/self/attr/smack/*", EINVAL},
+	{"read", "/proc/self/attr/apparmor/*", EINVAL},
 	{"read", "/proc/self/task/[0-9]*/attr/*", EINVAL},
+	{"read", "/proc/self/task/[0-9]*/attr/smack/*", EINVAL},
+	{"read", "/proc/self/task/[0-9]*/attr/apparmor/*", EINVAL},
 	{"read", "/proc/self/ns/*", EINVAL},
 	{"read", "/proc/self/task/[0-9]*/ns/*", EINVAL},
 	{"read", "/proc/ppc64/rtas/error_log", EINVAL},
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 fs/proc01.c:add known issues

Hi,

Quoted 15 lines · Xinpeng Liu

Test in ubuntu20.10,there are several failure tests.

proc01 1 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 2 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 3 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/exec: errno=EINVAL(22): Invalid argument
proc01 4 TFAIL : proc01.c:396: read failed:
/proc/self/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 5 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 6 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

Quoted 1 line

Tested on ubuntu 20.04.
I guess it is ok to completely exclude smack and apparmor folders from the test. Maybe there are some files in there, that can be read without error, but I think that should be up to testcases for these features.

J?rg

#2 lore raw

PATCH 1/1 fs/proc01.c:add known issues

In reply to Xinpeng Liu

----- Original Message -----

Quoted 14 lines

Test in ubuntu20.10,there are several failure tests.

proc01 1 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 2 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 3 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/exec: errno=EINVAL(22): Invalid argument
proc01 4 TFAIL : proc01.c:396: read failed:
/proc/self/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 5 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 6 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

I'm OK with ignoring it, but commit log could explain more why we get EINVAL on read here.

#3 lore raw

PATCH 1/1 fs/proc01.c:add known issues

thanks for good question.

i check the source linux-source-5.8.0,in filesecurity/smack/smack_lsm.c:smack_getprocattr directly return -EINVAL.

static int smack_getprocattr(struct task_struct *p, char *name, char **value)

{
        struct smack_known *skp = smk_of_task_struct(p);
        char *cp;
        int slen;

        if (strcmp(name, "current") != 0 && strcmp(name, "context") != 0)
                return -EINVAL;

        cp = kstrdup(skp->smk_known, GFP_KERNEL);
        if (cp == NULL)
                return -ENOMEM;

        slen = strlen(cp);
        *value = cp;
        return slen;
}

From: Jan Stancek
Date: 2021-01-15 22:54
To: Xinpeng Liu
CC: ltp
Subject: Re: [LTP] [PATCH] fs/proc01.c:add known issues

----- Original Message -----

Quoted 14 lines

Test in ubuntu20.10,there are several failure tests.

proc01 1 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 2 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 3 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/exec: errno=EINVAL(22): Invalid argument
proc01 4 TFAIL : proc01.c:396: read failed:
/proc/self/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 5 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 6 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

I'm OK with ignoring it, but commit log could explain more why we get EINVAL on read here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210118/c5aa8f84/attachment.htm>

#4 lore raw

PATCH 1/1 fs/proc01.c:add known issues

----- Original Message -----

Quoted 6 lines

thanks for good question.

i check the source linux-source-5.8.0,in filesecurity/smack/smack_lsm.c:
smack_getprocattr
directly return -EINVAL.

Quoted 8 lines

static int smack_getprocattr(struct task_struct *p, char *name, char **value) {
struct smack_known *skp = smk_of_task_struct(p);
char *cp;
int slen;

if (strcmp(name, "current") != 0 && strcmp(name, "context") != 0) return -EINVAL;

That doesn't look correct, strcmp when reading "current" returns 0, so you condition above shouldn't be hit.

I'm guessing you don't have smack enabled, and EINVAL is the default LSM ret value in such case:

LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, char *name, char **value)

int security_getprocattr(struct task_struct *p, const char *lsm, char *name, char **value)
{
struct security_hook_list *hp;

hlist_for_each_entry(hp, &security_hook_heads.getprocattr, list) { if (lsm != NULL && strcmp(lsm, hp->lsm))
continue;
return hp->hook.getprocattr(p, name, value);
}
return LSM_RET_DEFAULT(getprocattr);
}

Quoted 4 lines

cp = kstrdup(skp->smk_known, GFP_KERNEL);
if (cp == NULL)
return -ENOMEM;

Quoted 53 lines

slen = strlen(cp);
*value = cp;
return slen;
}

Quoted 47 lines

From: Jan Stancek

Date: 2021-01-15 22:54

To: Xinpeng Liu

CC ltp

Subject: Re: [LTP] [PATCH] fs/proc01.c:add known issues

----- Original Message -----

Quoted 23 lines

Test in ubuntu20.10,there are several failure tests.

proc01 1 TFAIL : proc01.c:396: read failed:

/proc/self/task/61595/attr/smack/current: errno=EINVAL(22): Invalid argument

proc01 2 TFAIL : proc01.c:396: read failed:

/proc/self/task/61595/attr/apparmor/prev: errno=EINVAL(22): Invalid argument

proc01 3 TFAIL : proc01.c:396: read failed:

/proc/self/task/61595/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

proc01 4 TFAIL : proc01.c:396: read failed:

/proc/self/attr/smack/current: errno=EINVAL(22): Invalid argument

Quoted 7 lines

proc01 5 TFAIL : proc01.c:396: read failed:

/proc/self/attr/apparmor/prev: errno=EINVAL(22): Invalid argument

proc01 6 TFAIL : proc01.c:396: read failed:

/proc/self/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

I'm OK with ignoring it, but commit log could explain more why we get EINVAL

on read here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210118/0a7d2e0a/attachment.htm>

#5 lore raw

PATCH 1/1 fs/proc01.c:add known issues

Right, smack is disabled in my system, and enabled appamor.

static int apparmor_getprocattr(struct task_struct *task, char *name,
char **value)

{
        int error = -ENOENT;
        /* released below */
        const struct cred *cred = get_task_cred(task);
        struct aa_task_ctx *ctx = task_ctx(current);
        struct aa_label *label = NULL;
        bool newline = true;

        if (strcmp(name, "current") == 0)
                label = aa_get_newest_label(cred_label(cred));
        else if (strcmp(name, "prev") == 0  && ctx->previous)   //HERE ctx->previous == NULL then return -EINVAL;
                label = aa_get_newest_label(ctx->previous);
        else if (strcmp(name, "exec") == 0 && ctx->onexec)    //HERE ctx->onexec == NULL then return -EINVAL;
                label = aa_get_newest_label(ctx->onexec);
        else if (strcmp(name, "context") == 0) {
                label = aa_get_newest_label(cred_label(cred));
                newline = false;
        } else
                error = -EINVAL;

        if (label)
                error = aa_getprocattr(label, value, newline);

        aa_put_label(label);
        put_cred(cred);

        return error;
}

thanks for your direction.

From: Jan Stancek
Date: 2021-01-18 19:04
To: liuxp11
CC: ltp; lkml
Subject: Re: [LTP] [PATCH] fs/proc01.c:add known issues

thanks for good question.

i check the source linux-source-5.8.0,in filesecurity/smack/smack_lsm.c:smack_getprocattr directly return -EINVAL.

static int smack_getprocattr(struct task_struct *p, char *name, char **value)

{
        struct smack_known *skp = smk_of_task_struct(p);
        char *cp;
        int slen;

        if (strcmp(name, "current") != 0 && strcmp(name, "context") != 0)
                return -EINVAL;

That doesn't look correct, strcmp when reading "current" returns 0, so you condition above shouldn't be hit.

I'm guessing you don't have smack enabled, and EINVAL is the default LSM ret value in such case:

LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, char *name,
char **value)

int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
char **value)

{
        struct security_hook_list *hp;

        hlist_for_each_entry(hp, &security_hook_heads.getprocattr, list) {
                if (lsm != NULL && strcmp(lsm, hp->lsm))
                        continue;
                return hp->hook.getprocattr(p, name, value);
        }
        return LSM_RET_DEFAULT(getprocattr);
}
        cp = kstrdup(skp->smk_known, GFP_KERNEL);
        if (cp == NULL)
                return -ENOMEM;

        slen = strlen(cp);
        *value = cp;
        return slen;
}

From:Jan Stancek
Date: 2021-01-15 22:54
To:Xinpeng Liu
CC:ltp
Subject: Re: [LTP] [PATCH] fs/proc01.c:add known issues ----- Original Message -----

Quoted 14 lines

Test in ubuntu20.10,there are several failure tests.

proc01 1 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 2 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 3 TFAIL : proc01.c:396: read failed:
/proc/self/task/61595/attr/apparmor/exec: errno=EINVAL(22): Invalid argument
proc01 4 TFAIL : proc01.c:396: read failed:
/proc/self/attr/smack/current: errno=EINVAL(22): Invalid argument
proc01 5 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/prev: errno=EINVAL(22): Invalid argument
proc01 6 TFAIL : proc01.c:396: read failed:
/proc/self/attr/apparmor/exec: errno=EINVAL(22): Invalid argument

I'm OK with ignoring it, but commit log could explain more why we get EINVAL on read here.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210118/a495618f/attachment-0001.htm>