lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 5 Aug 2020 20:00:34 +0200 From: Jiri Olsa <jolsa@...hat.com> To: Andrii Nakryiko <andrii.nakryiko@...il.com> Cc: Jiri Olsa <jolsa@...nel.org>, Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andriin@...com>, Wenbo Zhang <ethercflow@...il.com>, Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>, Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>, Martin KaFai Lau <kafai@...com>, David Miller <davem@...hat.com>, John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...omium.org>, Brendan Gregg <bgregg@...flix.com>, Florent Revest <revest@...omium.org>, Al Viro <viro@...iv.linux.org.uk> Subject: Re: [PATCH v9 bpf-next 13/14] selftests/bpf: Add test for d_path helper On Tue, Aug 04, 2020 at 11:40:05PM -0700, Andrii Nakryiko wrote: SNIP > > +SEC("fentry/vfs_getattr") > > +int BPF_PROG(prog_stat, struct path *path, struct kstat *stat, > > + __u32 request_mask, unsigned int query_flags) > > +{ > > + pid_t pid = bpf_get_current_pid_tgid() >> 32; > > + int ret; > > + > > + if (pid != my_pid) > > + return 0; > > + > > + if (cnt_stat >= MAX_FILES) > > + return 0; > > + ret = bpf_d_path(path, paths_stat[cnt_stat], MAX_PATH_LEN); > > + > > + /* We need to recheck cnt_stat for verifier. */ > > + if (cnt_stat >= MAX_FILES) > > + return 0; > > + rets_stat[cnt_stat] = ret; > > + > > + cnt_stat++; > > + return 0; > > +} > > + > > +SEC("fentry/filp_close") > > +int BPF_PROG(prog_close, struct file *file, void *id) > > +{ > > + pid_t pid = bpf_get_current_pid_tgid() >> 32; > > + int ret; > > + > > + if (pid != my_pid) > > + return 0; > > + > > + if (cnt_close >= MAX_FILES) > > + return 0; > > + ret = bpf_d_path(&file->f_path, > > + paths_close[cnt_close], MAX_PATH_LEN); > > + > > + /* We need to recheck cnt_stat for verifier. */ > > you need to do it because you are re-reading a global variable; if you > stored cnt_close in a local variable, then did >= MAX_FILES check > once, you probably could have avoided this duplication. Same for > another instance above. I see, nice.. I'll update both comments thanks, jirka
Powered by blists - more mailing lists