1. Jul 29, 2011
    • Jesper Juhl's avatar
      netfilter: ip_queue: Fix small leak in ipq_build_packet_message() · 91c66c68
      Jesper Juhl authored
      
      
      ipq_build_packet_message() in net/ipv4/netfilter/ip_queue.c and
      net/ipv6/netfilter/ip6_queue.c contain a small potential mem leak as
      far as I can tell.
      
      We allocate memory for 'skb' with alloc_skb() annd then call
       nlh = NLMSG_PUT(skb, 0, 0, IPQM_PACKET, size - sizeof(*nlh));
      
      NLMSG_PUT is a macro
       NLMSG_PUT(skb, pid, seq, type, len) \
        		NLMSG_NEW(skb, pid, seq, type, len, 0)
      
      that expands to NLMSG_NEW, which is also a macro which expands to:
       NLMSG_NEW(skb, pid, seq, type, len, flags) \
        	({	if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
        			goto nlmsg_failure; \
        		__nlmsg_put(skb, pid, seq, type, len, flags); })
      
      If we take the true branch of the 'if' statement and 'goto
      nlmsg_failure', then we'll, at that point, return from
      ipq_build_packet_message() without having assigned 'skb' to anything
      and we'll leak the memory we allocated for it when it goes out of
      scope.
      
      Fix this by placing a 'kfree(skb)' at 'nlmsg_failure'.
      
      I admit that I do not know how likely this to actually happen or even
      if there's something that guarantees that it will never happen - I'm
      not that familiar with this code, but if that is so, I've not been
      able to spot it.
      
      Signed-off-by: default avatarJesper Juhl <jj@chaosbits.net>
      Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
      91c66c68
    • Eric Dumazet's avatar
      netfilter: xt_rateest: fix xt_rateest_mt_checkentry() · 00fe1ae9
      Eric Dumazet authored
      commit 4a5a5c73
      
       (slightly better error reporting) added some
      useless code in xt_rateest_mt_checkentry().
      
      Fix this so that different error codes can really be returned.
      
      Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      CC: Jan Engelhardt <jengelh@medozas.de>
      Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
      00fe1ae9
  2. Jul 28, 2011