Skip to content

Commit

Permalink
netfilter: x_tables: fix cgroup matching on non-full sks
Browse files Browse the repository at this point in the history
While originally only being intended for outgoing traffic, commit
a00e763 ("netfilter: x_tables: allow to use cgroup match for
LOCAL_IN nf hooks") enabled xt_cgroups for the NF_INET_LOCAL_IN hook
as well, in order to allow for nfacct accounting.

Besides being currently limited to early demuxes only, commit
a00e763 forgot to add a check if we deal with full sockets,
i.e. in this case not with time wait sockets. TCP time wait sockets
do not have the same memory layout as full sockets, a lower memory
footprint and consequently also don't have a sk_classid member;
probing for sk_classid member there could potentially lead to a
crash.

Fixes: a00e763 ("netfilter: x_tables: allow to use cgroup match for LOCAL_IN nf hooks")
Cc: Alexey Perevalov <a.perevalov@samsung.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Daniel Borkmann authored and Pablo Neira Ayuso committed Apr 1, 2015
1 parent 9d09829 commit afb7718
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/netfilter/xt_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cgroup_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
const struct xt_cgroup_info *info = par->matchinfo;

if (skb->sk == NULL)
if (skb->sk == NULL || !sk_fullsock(skb->sk))
return false;

return (info->id == skb->sk->sk_classid) ^ info->invert;
Expand Down

0 comments on commit afb7718

Please sign in to comment.