netfilter: nf_tables: don't call nfnetlink_set_err() if nfnetlink_send() fails
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v2 1/1 netfilter: nf_tables: don't call nfnetlink_set_err() if nfnetlink_send() fails
The underlying nlmsg_multicast() already sets sk->sk_err for us to notify socket overruns, so we should not do anything with this return value. So we just call nfnetlink_set_err() if:
1) We fail to allocate the netlink message.
or
2) We don't have enough space in the netlink message to place the attribute, which means that we likely need to allocate a larger message.
Before this patch, the internal ESRCH netlink error code which is very misleading. Netlink semantics mandate that listeners hit ENOBUFS if the socket buffer overruns.
---
v2: Previous patch was still calling nfnetlink_set_err() when nfnetlink_send()
fails, this is not correct. Fix it in this new round.
include/net/netfilter/nf_tables.h | 6 +- net/netfilter/nf_tables_api.c | 133 ++++++++++++++++---------------------- 2 files changed, 58 insertions(+), 81 deletions(-)
include/net/netfilter/nf_tables.h +3 -3
@@ -988,9 +988,9 @@ struct nft_object *nf_tables_obj_lookup(const struct nft_table *table, const struct nlattr *nla, u32 objtype, u8 genmask); -int nft_obj_notify (struct net *net,struct nft_table *table, -struct nft_object *obj,u32 portid,u32 seq, -int event,int family,int report,gfp_t gfp); +void nft_obj_notify (struct net *net,struct nft_table *table, +struct nft_object *obj,u32 portid,u32 seq, +int event,int family,int report,gfp_t gfp);/** * struct nft_object_type - stateful object type
net/netfilter/nf_tables_api.c +55 -78
277 lines not on this page · raw message
Signature · 1 line
2.1.4
Quoted 11 lines · Pablo Neira Ayuso
The underlying
nlmsg_multicast()already setssk->sk_errfor us to notify socket overruns, so we should not do anything with this return value. So we just callnfnetlink_set_err()if:1) We fail to allocate the netlink message.
or
2) We don't have enough space in the netlink message to place the attribute, which means that we likely need to allocate a larger message.
Quoted 6 lines
Before this patch, the internal ESRCH netlink error code which is very misleading. Netlink semantics mandate that listeners hit ENOBUFS if the socket buffer overruns.
Reported-by Alexander Alemayhu <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>
Signature · 3 lines
Mit freundlichen Grüßen Alexander Alemayhu