tun: fix re-attaching the socket filter
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v12 Latest2 patches 1 replyIn review
- v112 patches 4 repliesSuperseded
- v10 posting 2/22 patches 4 repliesSuperseded
Earlier versions · 11
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v10 posting 1/2 | 1 of 2 patches | 0 replies | Superseded | |
| v9 | 2 patches | 5 replies | Superseded | |
| v8 | 2 patches | 3 replies | Superseded | |
| v7 | 2 patches | 4 replies | Superseded | |
| v6 | 2 patches | 1 reply | Superseded | |
| v5 posting 2/2 | 2 patches | 1 reply | Superseded | |
| v5 posting 1/2 | 2 patches | 1 reply | Superseded | |
| v4 | 2 patches | 3 replies | Superseded | |
| v3 | 3 patches | 7 replies | Superseded | |
| v2 | 4 patches | 6 replies | Superseded | |
| v1 | 1 patch | 2 replies | Superseded |
Changes in v12 from the cover letter
- drop the EXPORT_SYMBOL_GPL() of sk_attach_filter() and sk_detach_filter(), as Alexei asked. It is a cleanup on its own, so it goes in a separate patch and the stable backport of the fix does not carry it
Patches in v12 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | tun: run the socket filter from tun_net_xmit()drivers/ net/ | +43 | 0 replies | |
| 2/2 | selftests: net: add TAP socket filter attach teststools/ | +358 | 0 replies |
Reviews trailers per patch
None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Alexei Starovoitov |
|---|---|
| Series | A-b |
| 1/2 | |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net v12 0/2] tun: fix re-attaching the socket filter
From: Rongguang Wei <[email protected]>
This series fixes attaching a queue to a TAP device, which re-installs the socket filter of a persistent device.
TUNATTACHFILTER keeps only the sock_fprog header, so the instructions are read from user space again for every queue that is attached later. Keep the program on the device instead, run it from tun_net_xmit(), and record IFF_NOFILTER per queue. Patch 1 does that. Also removes the exports of sk_attach_filter() and sk_detach_filter() because no caller in a module.
Patch 2 adds selftests for the re-attach, for bad programs with and without queues, and for the IFF_NOFILTER paths.
Thanks to Willem de Bruijn and Alexei Starovoitov for the reviews.
---
v12:
- drop the EXPORT_SYMBOL_GPL() of sk_attach_filter() and sk_detach_filter(), as Alexei asked. It is a cleanup on its own, so it goes in a separate patch and the stable backport of the fix does not carry it
v11:
- keep one program on the device instead of a copy per queue, as Alexei suggested; sk_attach_filter_kern() and bpf_prog_validate_classic() are gone with it
- TUNDETACHFILTER now applies to queues detached with IFF_DETACH_QUEUE too
- selftests: cover the zero-queue and detached-queue paths
- https://lore.kernel.org/netdev/[email protected]/
v10:
- add [email protected] and the BPF maintainers to Cc
- selftests: fix the queue numbering and add a zero-queue case
- https://lore.kernel.org/netdev/[email protected]/
v9:
- zero the whole sock_fprog header, so that the padding TUNGETFILTER copies is not uninitialized stack
- https://lore.kernel.org/netdev/[email protected]/
v8:
- narrow the bpf_prog_validate_classic() contract to the classic verifier and note that it can also return -ENOMEM
- commit the new program only after every queue took it
- https://lore.kernel.org/netdev/[email protected]/
v7:
- verify the instructions before anything is replaced
- fix the kernel-doc of sk_attach_filter_kern()
- reject a program whose length is out of range before allocating memory
- selftests: add a case for a rejected program with valid length and bad instructions
- https://lore.kernel.org/netdev/[email protected]/
v6:
- add description for return value of sk_attach_filter_kern()
- https://lore.kernel.org/netdev/[email protected]/
v5:
- add kernel-doc for sk_attach_filter_kern()
- fix the wording of the mprotect() comment
- https://lore.kernel.org/netdev/[email protected]/
v4:
- merge the kernel copy and the error check into one patch
- charge the kernel copy to the caller's memory cgroup
- https://lore.kernel.org/netdev/[email protected]/
v3:
- reorder: the kernel copy of the program comes before the corrected error check
- add sk_attach_filter_kern() in the patch that first uses it
- https://lore.kernel.org/netdev/[email protected]/
v2:
- roll back the filter attach when a later step of tun_attach() fails
- keep a copy of the program in the kernel
- add selftests for the re-attach and for a rejected TUNATTACHFILTER
- https://lore.kernel.org/netdev/[email protected]/
v1:
- https://lore.kernel.org/netdev/[email protected]/
Rongguang Wei (2):
tun: run the socket filter from tun_net_xmit()
selftests: net: add TAP socket filter attach tests
drivers/net/tun.c | 93 ++++---- net/core/filter.c | 2 - tools/testing/selftests/net/tun.c | 358 ++++++++++++++++++++++++++++++ 3 files changed, 401 insertions(+), 52 deletions(-)
base-commit: c44104f3642da720164042623e4832836aefdd8e
Signature · 5 lines
2.25.1 No virus found Checked by Hillstone Network AntiVirus