All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3] syscalls/add_key05: add maxbytes/maxkeys test under unprivileged user
Date: Fri, 20 Mar 2020 12:50:48 +0100	[thread overview]
Message-ID: <20200320115048.GA27677@dell5510> (raw)
In-Reply-To: <c65a46ee-3355-d9b8-dd27-905962384af9@cn.fujitsu.com>

Hi Xu,

> > > This case is designed to test whether we can reach maxbytes/maxkeys
> > > quota exactly under unprivileged users. It is a regression test for
> > > commit a08bf91ce28e ("KEYS: allow reaching the keys quotas exactly").
> > > But this kenrel commit is a incomplete fix, it still fails on lastest
> > nit: typos: kenrel, lastest (will be fixed during merge).
> > > upstream kernel. Fix patch[1] is on linux-next branch.

> > > [1]https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=2e356101e72a
> > I guess this commit get's preserved when merged in mainline, so we don't have to
> > wait for it.
> This morning, I got email about this patch[1](change subject"keys: Fix the
> keys quotas limit check"). I'm not sure whether they will recycle and modify
> this.

> [1]https://patchwork.kernel.org/patch/11411507/

Although the maintainers were discussing commit message change, in the end
Jarkko has sent it:
https://lkml.org/lkml/2020/3/15/314
Well, if the commit hash changes, we'll just fix it.

> > > +struct passwd *ltpuser;
> > ...
> > > +static void add_user(void)
> > > +{
> > > +	if (user_added)
> > > +		return;
> > > +
> > > +	const char *const cmd_useradd[] = {"useradd", username, NULL};
> > > +	int rc;
> > > +
> > > +	switch ((rc = tst_run_cmd(cmd_useradd, NULL, NULL, 1))) {
> > > +	case 0:
> > > +		user_added = 1;
> > > +		ltpuser = SAFE_GETPWNAM(username);
> > > +		break;
> > > +	case 1:
> > > +	case 255:
> > > +		break;
> > > +	default:
> > > +		tst_brk(TBROK, "Useradd failed (%d)", rc);
> > > +	}
> > > +	sprintf(fmt, "%5u: %%*5d %%*d/%%*d %%d/%%d %%d/%%d", ltpuser->pw_uid);
> > > +}
> > ltpuser is undefined for 1 and 255, therefore it gets SIGSEGV. It should either
> > require tst_run_cmd to exit 0 or use 0 as UID (root UID).
> Oh, sorry for this obvious mistake, thanks for pointing out it.
> Yes, I prefer to exit when running into 0 or 255.

Fine :). I'm going to merge with handling specially only 255:

Kind regards,
Petr

index a0c8c00cc..a39bfa0b7 100644
--- testcases/kernel/syscalls/add_key/add_key05.c
+++ testcases/kernel/syscalls/add_key/add_key05.c
@@ -43,11 +43,11 @@ static void add_user(void)
                user_added = 1;
                ltpuser = SAFE_GETPWNAM(username);
                break;
-       case 1:
        case 255:
+               tst_brk(TCONF, "useradd not found");
                break;
        default:
-               tst_brk(TBROK, "Useradd failed (%d)", rc);
+               tst_brk(TBROK, "useradd failed (%d)", rc);
        }
        sprintf(fmt, "%5u: %%*5d %%*d/%%*d %%d/%%d %%d/%%d", ltpuser->pw_uid);
 }

  reply	other threads:[~2020-03-20 11:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 13:14 [LTP] [PATCH] syscalls/add_key05: add maxbytes/maxkeys test under unprivileged user Yang Xu
2020-02-24 15:31 ` Cyril Hrubis
2020-02-26 10:19   ` Yang Xu
2020-02-28  7:00     ` Yang Xu
2020-02-28  8:47   ` [LTP] [PATCH v2] " Yang Xu
2020-03-17 12:32     ` Petr Vorel
2020-03-18  9:55       ` Yang Xu
2020-03-18 13:16         ` Petr Vorel
2020-03-18 13:17           ` Petr Vorel
2020-03-18 10:32       ` [LTP] [PATCH v3] " Yang Xu
2020-03-19 11:23         ` Petr Vorel
2020-03-20  5:15           ` Yang Xu
2020-03-20 11:50             ` Petr Vorel [this message]
2020-03-20 12:36           ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200320115048.GA27677@dell5510 \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.