Skip to content

Commit

Permalink
[NETFILTER]: Fix potential memory corruption in NAT code (aka memory …
Browse files Browse the repository at this point in the history
…NAT)

The portptr pointing to the port in the conntrack tuple is declared static,
which could result in memory corruption when two packets of the same
protocol are NATed at the same time and one conntrack goes away.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Jul 22, 2005
1 parent 4c1217d commit d04b4f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion net/ipv4/netfilter/ip_nat_proto_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ tcp_unique_tuple(struct ip_conntrack_tuple *tuple,
enum ip_nat_manip_type maniptype,
const struct ip_conntrack *conntrack)
{
static u_int16_t port, *portptr;
static u_int16_t port;
u_int16_t *portptr;
unsigned int range_size, min, i;

if (maniptype == IP_NAT_MANIP_SRC)
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/netfilter/ip_nat_proto_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ udp_unique_tuple(struct ip_conntrack_tuple *tuple,
enum ip_nat_manip_type maniptype,
const struct ip_conntrack *conntrack)
{
static u_int16_t port, *portptr;
static u_int16_t port;
u_int16_t *portptr;
unsigned int range_size, min, i;

if (maniptype == IP_NAT_MANIP_SRC)
Expand Down

0 comments on commit d04b4f8

Please sign in to comment.