Skip to content

Commit

Permalink
tipc: fix potential bug in function tipc_backlog_rcv
Browse files Browse the repository at this point in the history
In commit 4f4482d ("tipc: compensate
for double accounting in socket rcv buffer") we access 'truesize' of
a received buffer after it might have been released by the function
filter_rcv().

In this commit we correct this by reading the value of 'truesize' to
the stack before delivering the buffer to filter_rcv().

Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jon Paul Maloy authored and David S. Miller committed Jun 11, 2014
1 parent cf97b8f commit 02c00c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* net/tipc/socket.c: TIPC socket API
* net/tipc/socket.c: TIPC socket API
*
* Copyright (c) 2001-2007, 2012-2014, Ericsson AB
* Copyright (c) 2004-2008, 2010-2013, Wind River Systems
Expand Down Expand Up @@ -1431,13 +1431,14 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *buf)
{
u32 res;
struct tipc_sock *tsk = tipc_sk(sk);
uint truesize = buf->truesize;

res = filter_rcv(sk, buf);
if (unlikely(res))
tipc_reject_msg(buf, res);

if (atomic_read(&tsk->dupl_rcvcnt) < TIPC_CONN_OVERLOAD_LIMIT)
atomic_add(buf->truesize, &tsk->dupl_rcvcnt);
atomic_add(truesize, &tsk->dupl_rcvcnt);

return 0;
}
Expand Down

0 comments on commit 02c00c2

Please sign in to comment.