From: KP Singh <kpsingh@chromium.org>
To: Martin KaFai Lau <kafai@fb.com>
Cc: open list <linux-kernel@vger.kernel.org>,
bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Song Liu <songliubraving@fb.com>, Paul Turner <pjt@google.com>,
Jann Horn <jannh@google.com>, Hao Luo <haoluo@google.com>
Subject: Re: [PATCH bpf-next v4 8/9] bpf: Add tests for task_local_storage
Date: Thu, 5 Nov 2020 23:32:49 +0100 [thread overview]
Message-ID: <CACYkzJ4sNH+PjrjzTYBQ-wcRqCN+b+v+qSk6otx-b3M-U-V3-A@mail.gmail.com> (raw)
In-Reply-To: <20201105220250.uvm3unmbne36lsoz@kafai-mbp.dhcp.thefacebook.com>
On Thu, Nov 5, 2020 at 11:03 PM Martin KaFai Lau <kafai@fb.com> wrote:
>
> On Thu, Nov 05, 2020 at 03:47:54PM +0100, KP Singh wrote:
> > From: KP Singh <kpsingh@google.com>
> >
> > The test exercises the syscall based map operations by creating a pidfd
> > for the current process.
> >
[...]
> > +}
> > +
> > +unsigned int duration;
> static
Fixed.
>
> > +
> > +#define TEST_STORAGE_VALUE 0xbeefdead
> > +
> > +struct storage {
> > + void *inode;
> > + unsigned int value;
> > + /* Lock ensures that spin locked versions of local stoage operations
> > + * also work, most operations in this tests are still single threaded
> > + */
> > + struct bpf_spin_lock lock;
> > +};
> > +
> > +/* Copies an rm binary to a temp file. dest is a mkstemp template */
> > +int copy_rm(char *dest)
> static
FIxed.
[...]
> > + ret = chmod(dest, 0100);
> > + if (ret == -1)
> > + return errno;
> > +
> > + close(fd_in);
> > + close(fd_out);
> fd_in and fd_out are not closed in error cases.
Fixed.
>
> > {
> > - char fname[PATH_MAX] = "/tmp/fileXXXXXX";
> > - int fd;
> > + int ret, fd_in, fd_out;
> > + struct stat stat;
> >
[...]
> > + */
> > +int run_self_unlink(int *monitored_pid, const char *rm_path)
> static
Fixed.
>
> [ ... ]
>
> > +bool check_syscall_operations(int map_fd, int obj_fd)
> static
Fixed.
>
> [ ... ]
>
> > void test_test_local_storage(void)
> > {
> > + char tmp_exec_path[PATH_MAX] = "/tmp/copy_of_rmXXXXXX";
> > + int err, serv_sk = -1, task_fd = -1;
> > struct local_storage *skel = NULL;
> > - int err, duration = 0, serv_sk = -1;
> >
[...]
> > + err = unlink(tmp_exec_path);
> Will tmp_exec_path file be removed if there is error earlier?
No. Since I cannot move this unlink as inode_unlink LSM hook sets the
inode_storage
result, I added another label close_prog_unlink which cleans it up for
the errors
before this succeeds.
>
> > + if (CHECK(err != 0, "unlink", "unable to unlink %s: %d", tmp_exec_path,
> > + errno))
> > goto close_prog;
> >
> > CHECK(skel->data->inode_storage_result != 0, "inode_storage_result",
> > @@ -56,5 +200,6 @@ void test_test_local_storage(void)
> > close(serv_sk);
> >
> > close_prog:
> > + close(task_fd);
> > local_storage__destroy(skel);
> > }
next prev parent reply other threads:[~2020-11-05 22:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 14:47 [PATCH bpf-next v4 0/9] Implement task_local_storage KP Singh
2020-11-05 14:47 ` [PATCH bpf-next v4 1/9] bpf: Allow LSM programs to use bpf spin locks KP Singh
2020-11-05 18:45 ` Song Liu
2020-11-05 20:39 ` Martin KaFai Lau
2020-11-05 14:47 ` [PATCH bpf-next v4 2/9] bpf: Implement task local storage KP Singh
2020-11-05 21:16 ` Martin KaFai Lau
2020-11-05 14:47 ` [PATCH bpf-next v4 3/9] libbpf: Add support for " KP Singh
2020-11-05 14:47 ` [PATCH bpf-next v4 4/9] bpftool: " KP Singh
2020-11-05 21:18 ` Martin KaFai Lau
2020-11-05 14:47 ` [PATCH bpf-next v4 5/9] bpf: Implement get_current_task_btf and RET_PTR_TO_BTF_ID KP Singh
2020-11-05 21:24 ` Martin KaFai Lau
2020-11-05 14:47 ` [PATCH bpf-next v4 6/9] bpf: Fix tests for local_storage KP Singh
2020-11-05 14:47 ` [PATCH bpf-next v4 7/9] bpf: Update selftests for local_storage to use vmlinux.h KP Singh
2020-11-05 14:47 ` [PATCH bpf-next v4 8/9] bpf: Add tests for task_local_storage KP Singh
2020-11-05 22:02 ` Martin KaFai Lau
2020-11-05 22:32 ` KP Singh [this message]
2020-11-05 14:47 ` [PATCH bpf-next v4 9/9] bpf: Exercise syscall operations for inode and sk storage KP Singh
2020-11-05 22:07 ` Martin KaFai Lau
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=CACYkzJ4sNH+PjrjzTYBQ-wcRqCN+b+v+qSk6otx-b3M-U-V3-A@mail.gmail.com \
--to=kpsingh@chromium.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=jannh@google.com \
--cc=kafai@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pjt@google.com \
--cc=songliubraving@fb.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).