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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZA4rnMqTX8UNpcnA@pop-os.localdomain>
Date:   Sun, 12 Mar 2023 12:44:28 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Jakub Sitnicki <jakub@...udflare.com>
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org,
        Cong Wang <cong.wang@...edance.com>,
        John Fastabend <john.fastabend@...il.com>,
        Martin KaFai Lau <martin.lau@...ux.dev>
Subject: Re: [Patch net-next] sock_map: dump socket map id via diag

On Tue, Feb 21, 2023 at 10:11:12AM +0100, Jakub Sitnicki wrote:
> On Sat, Feb 11, 2023 at 12:19 PM -08, Cong Wang wrote:
> > From: Cong Wang <cong.wang@...edance.com>
> >
> > Currently there is no way to know which sockmap a socket has been added
> > to from outside, especially for that a socket can be added to multiple
> > sockmap's. We could dump this via socket diag, as shown below.
> >
> > Sample output:
> >
> >   # ./iproute2/misc/ss -tnaie --sockmap
> >   ESTAB  0      344329     127.0.0.1:1234     127.0.0.1:40912 ino:21098 sk:5 cgroup:/user.slice/user-0.slice/session-c1.scope <-> sockmap: 1
> >
> >   # bpftool map
> >   1: sockmap  flags 0x0
> >   	key 4B  value 4B  max_entries 2  memlock 4096B
> > 	pids echo-sockmap(549)
> >   4: array  name pid_iter.rodata  flags 0x480
> > 	key 4B  value 4B  max_entries 1  memlock 4096B
> > 	btf_id 10  frozen
> > 	pids bpftool(624)
> >
> > In the future, we could dump other sockmap related stats too, hence I
> > make it a nested attribute.
> >
> > Cc: John Fastabend <john.fastabend@...il.com>
> > Cc: Jakub Sitnicki <jakub@...udflare.com>
> > Signed-off-by: Cong Wang <cong.wang@...edance.com>
> > ---
> 
> Sorry for not replying sooner. This sounds useful. Another use case I
> can see here is inspecting process' sockets:
> 
> 1. get a dup FD with pidfd_getfd()
> 2. query sock_diag by socket cookie
> 3. find out which maps socket is in.
> 
> 
> I don't know if it makes sense to tie the naming to sockmap. We also
> have also map type that can hold socket references -
> REUSEPORT_SOCKARRAY.
> 
> We might want to add sock_diag support for REUSEPORT_SOCKARRAY in the
> future as well. So a map-type-agnostic name for the new inet_diag ext
> might be more future proof. Like INET_DIAG_BPF_MAP.

Sounds reasonable. I didn't realize REUSEPORT_SOCKARRAY also needs this.

> 
> 
> Also, can you please add a simple selftest? They often serve as the only
> documentation for the features. Perhaps in
> tools/testing/selftests/bpf/prog_tests/sockmap_basic.c.
> 

Not sure if this makes sense, because this is mostly for socket diag, it
does not seem fitting well in bpf selftests.

In case you wonder how I tested it, I have an iproute2 patch which is
not posted here yet.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ