From: John Fastabend <john.fastabend@gmail.com>
To: jakub@cloudflare.com, rivendell7@gmail.com, kuniyu@amazon.com
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH bpf 0/5] fix sockmap + stream af_unix memleak
Date: Thu, 21 Dec 2023 15:23:22 -0800 [thread overview]
Message-ID: <20231221232327.43678-1-john.fastabend@gmail.com> (raw)
There was a memleak when streaming af_unix sockets were inserted into
multiple sockmap slots and/or maps. This is because each insert would
call a proto update operatino and these must be allowed to be called
multiple times. The streaming af_unix implementation recently added
a refcnt to handle a use after free issue, however it introduced a
memleak when inserted into multiple maps.
This series fixes the memleak, adds a note in the code so we remember
that proto updates need to support this. And then we add three tests
for each of the slightly different iterations of adding sockets into
multiple maps. I kept them as 3 independent test cases here. I have
some slight preference for this they could however be a single test,
but then you don't get to run them independently which was sort of
useful while debugging.
John Fastabend (5):
bpf: sockmap, fix proto update hook to avoid dup calls
bpf: sockmap, added comments describing update proto rules
bpf: sockmap, add tests for proto updates many to single map
bpf: sockmap, add tests for proto updates single socket to many map
bpf: sockmap, add tests for proto updates replace socket
include/linux/skmsg.h | 5 +
net/unix/unix_bpf.c | 21 +-
.../selftests/bpf/prog_tests/sockmap_basic.c | 199 +++++++++++++++++-
3 files changed, 221 insertions(+), 4 deletions(-)
--
2.33.0
next reply other threads:[~2023-12-21 23:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 23:23 John Fastabend [this message]
2023-12-21 23:23 ` [PATCH bpf 1/5] bpf: sockmap, fix proto update hook to avoid dup calls John Fastabend
2024-01-02 12:00 ` Jakub Sitnicki
2024-01-04 1:00 ` Martin KaFai Lau
2024-01-04 3:47 ` John Fastabend
2023-12-21 23:23 ` [PATCH bpf 2/5] bpf: sockmap, added comments describing update proto rules John Fastabend
2023-12-21 23:23 ` [PATCH bpf 3/5] bpf: sockmap, add tests for proto updates many to single map John Fastabend
2023-12-21 23:23 ` [PATCH bpf 4/5] bpf: sockmap, add tests for proto updates single socket to many map John Fastabend
2023-12-21 23:23 ` [PATCH bpf 5/5] bpf: sockmap, add tests for proto updates replace socket John Fastabend
2024-01-02 15:18 ` [PATCH bpf 0/5] fix sockmap + stream af_unix memleak Jakub Sitnicki
2024-01-02 23:49 ` John Fastabend
2024-01-04 1:00 ` patchwork-bot+netdevbpf
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=20231221232327.43678-1-john.fastabend@gmail.com \
--to=john.fastabend@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=jakub@cloudflare.com \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=rivendell7@gmail.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