linux/net
Jamal Hadi Salim 54e0d01bb6 net sched filters: fix notification of filter delete with proper handle
[ Upstream commit 9ee7837449 ]

Daniel says:

While trying out [1][2], I noticed that tc monitor doesn't show the
correct handle on delete:

$ tc monitor
qdisc clsact ffff: dev eno1 parent ffff:fff1
filter dev eno1 ingress protocol all pref 49152 bpf handle 0x2a [...]
deleted filter dev eno1 ingress protocol all pref 49152 bpf handle 0xf3be0c80

some context to explain the above:
The user identity of any tc filter is represented by a 32-bit
identifier encoded in tcm->tcm_handle. Example 0x2a in the bpf filter
above. A user wishing to delete, get or even modify a specific filter
uses this handle to reference it.
Every classifier is free to provide its own semantics for the 32 bit handle.
Example: classifiers like u32 use schemes like 800:1:801 to describe
the semantics of their filters represented as hash table, bucket and
node ids etc.
Classifiers also have internal per-filter representation which is different
from this externally visible identity. Most classifiers set this
internal representation to be a pointer address (which allows fast retrieval
of said filters in their implementations). This internal representation
is referenced with the "fh" variable in the kernel control code.

When a user successfuly deletes a specific filter, by specifying the correct
tcm->tcm_handle, an event is generated to user space which indicates
which specific filter was deleted.

Before this patch, the "fh" value was sent to user space as the identity.
As an example what is shown in the sample bpf filter delete event above
is 0xf3be0c80. This is infact a 32-bit truncation of 0xffff8807f3be0c80
which happens to be a 64-bit memory address of the internal filter
representation (address of the corresponding filter's struct cls_bpf_prog);

After this patch the appropriate user identifiable handle as encoded
in the originating request tcm->tcm_handle is generated in the event.
One of the cardinal rules of netlink rules is to be able to take an
event (such as a delete in this case) and reflect it back to the
kernel and successfully delete the filter. This patch achieves that.

Note, this issue has existed since the original TC action
infrastructure code patch back in 2004 as found in:
https://git.kernel.org/cgit/linux/kernel/git/history/history.git/commit/

[1] http://patchwork.ozlabs.org/patch/682828/
[2] http://patchwork.ozlabs.org/patch/682829/

Fixes: 4e54c4816bfe ("[NET]: Add tc extensions infrastructure.")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2017-10-12 15:28:14 +01:00
..
9p p9_client_readdir() fix 2017-07-18 18:40:36 +01:00
802 neigh: use NEIGH_VAR_INIT in ndo_neigh_setup functions. 2014-01-16 11:31:58 -08:00
8021q net: Always untag vlan-tagged traffic on input. 2014-10-15 12:05:26 +02:00
appletalk appletalk: Fix socket referencing in skb 2014-07-08 19:39:43 -07:00
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2014-06-12 14:27:40 -07:00
ax25 Revert "ax25: add link layer header validation function" 2016-06-15 21:29:20 +01:00
batman-adv batman-adv: Fix rx packet/bytes stats on local ARP reply 2017-09-15 18:29:46 +01:00
bluetooth Bluetooth: Properly check L2CAP config option output buffer length 2017-10-12 15:28:11 +01:00
bridge net: bridge: fix old ioctl unlocked net device walk 2017-03-16 02:27:17 +00:00
caif unix/caif: sk_socket can disappear when state is unlocked 2015-06-12 13:30:18 +01:00
can can: Fix kernel panic at security_sock_rcv_skb 2017-03-16 02:27:24 +00:00
ceph libceph: NULL deref on crush_decode() error path 2017-09-15 18:29:49 +01:00
core net: handle NAPI_GRO_FREE_STOLEN_HEAD case also in napi_frags_finish() 2017-09-15 18:30:16 +01:00
dcb net: Use netlink_ns_capable to verify the permisions of netlink messages 2014-04-24 13:44:54 -04:00
dccp dccp/tcp: fix routing redirect race 2017-07-18 18:40:12 +01:00
decnet decnet: Do not build routes to devices without decnet private data. 2017-03-16 02:27:15 +00:00
dns_resolver dns_resolver: Null-terminate the right string 2014-07-20 22:33:32 -07:00
dsa net: dsa: Fix off-by-one in switch address parsing 2015-08-10 17:10:19 +01:00
ethernet net: eth_type_trans() should use skb_header_pointer() 2014-01-16 15:30:31 -08:00
hsr hsr: replace del_timer by del_timer_sync 2014-03-27 15:28:06 -04:00
ieee802154 ieee802154: Fix sockaddr_ieee802154 implicit padding information leak. 2015-07-15 10:00:19 +01:00
ipv4 ipv4/fib: don't warn when primary address is missing if in_dev is dead 2017-10-12 15:28:12 +01:00
ipv6 net/route: enforce hoplimit max value 2017-10-12 15:28:12 +01:00
ipx ipx: call ipxitf_put() in ioctl error path 2017-06-05 21:17:23 +01:00
irda irda: Fix lockdep annotations in hashbin_delete(). 2017-03-16 02:27:15 +00:00
iucv af_iucv: Move sockaddr length checks to before accessing sa_family in bind and connect handlers 2017-10-12 15:27:52 +01:00
key xfrm: NULL dereference on allocation failure 2017-09-15 18:30:11 +01:00
l2tp l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv 2017-10-12 15:28:11 +01:00
lapb net/lapb: re-send packets on timeout 2013-09-23 16:52:45 -04:00
llc net/llc: avoid BUG_ON() in skb_orphan() 2017-03-16 02:27:13 +00:00
mac80211 mac80211/wpa: use constant time memory comparison for MACs 2017-09-15 18:30:10 +01:00
mac802154 mac802154: don't deliver packets to devices that are down 2014-06-11 12:10:19 -07:00
mpls net: gso: use feature flag argument in all protocol gso handlers 2015-08-27 14:27:14 +01:00
netfilter netfilter: ctnetlink: fix incorrect nf_ct_put during hash resize 2017-09-15 18:29:50 +01:00
netlabel netlabel: add address family checks to netlbl_{sock,req}_delattr() 2016-11-20 01:16:39 +00:00
netlink netlink: remove mmapped netlink support 2017-04-04 22:21:56 +01:00
netrom net: Fix use after free by removing length arg from sk_data_ready callbacks. 2014-04-11 16:15:36 -04:00
nfc NFC: fix broken device allocation 2017-10-12 15:27:50 +01:00
openvswitch ovs: do not allocate memory from offline numa node 2015-10-28 10:33:20 +00:00
packet packet: fix tp_reserve race in packet_set_ring 2017-08-26 02:14:49 +01:00
phonet phonet: properly unshare skbs in phonet_rcv() 2016-01-28 10:51:50 +00:00
rds rds: fix an infoleak in rds_inc_info_copy 2016-08-22 22:38:28 +01:00
rfkill rfkill: fix rfkill_fop_read wait_event usage 2016-02-25 00:18:36 +00:00
rose rose: limit sk_filter trim to payload 2017-02-23 03:54:46 +00:00
rxrpc rxrpc: Fix several cases where a padded len isn't checked in ticket decode 2017-07-02 17:13:03 +01:00
sched net sched filters: fix notification of filter delete with proper handle 2017-10-12 15:28:14 +01:00
sctp sctp: do not inherit ipv6_{mc|ac|fl}_list from parent 2017-06-05 21:17:24 +01:00
sunrpc sunrpc: use constant time memory comparison for mac 2017-10-12 15:28:06 +01:00
tipc tipc: check minimum bearer MTU 2017-02-23 03:54:42 +00:00
unix net: unix: properly re-increment inflight counter of GC discarded candidates 2017-07-18 18:40:20 +01:00
vmw_vsock VSOCK: do not disconnect socket when peer has shutdown SEND only 2017-03-16 02:27:16 +00:00
wimax wimax: remove dead code 2013-11-21 13:09:42 -05:00
wireless nl80211: check for the required netlink attributes presence 2017-10-12 15:28:10 +01:00
x25 net: fix a kernel infoleak in x25 module 2016-06-15 21:29:34 +01:00
xfrm xfrm: policy: check policy direction value 2017-09-15 18:30:18 +01:00
compat.c net: compat: Update get_compat_msghdr() to match copy_msghdr_from_user() behaviour 2015-03-24 10:48:46 +00:00
Kconfig Merge branch 'for-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup 2014-04-03 13:05:42 -07:00
Makefile net: move 6lowpan compression code to separate module 2014-01-15 15:36:38 -08:00
nonet.c llseek: automatically add .llseek fop 2010-10-15 15:53:27 +02:00
socket.c net: socket: fix recvmmsg not returning error from sock_error 2017-03-16 02:27:23 +00:00
sysctl_net.c net: Update the sysctl permissions handler to test effective uid/gid 2013-10-07 15:57:56 -04:00