]> www.infradead.org Git - users/jedix/linux-maple.git/commit
RDS: Fix potential race around rds_i[bw]_allocation
authorAndy Grover <andy.grover@oracle.com>
Thu, 13 Aug 2009 20:30:36 +0000 (13:30 -0700)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 7 Jul 2015 23:41:18 +0000 (16:41 -0700)
commit318034a5230d356733b1110243d3f1cc27c81af7
tree0aba2874e6c990d80bd1f8e1df5eb521276ea962
parentc2b68e202cfe0bea8079b047987958120436c8f7
RDS: Fix potential race around rds_i[bw]_allocation

From Shin Hong:

"At rds_ib_recv_refill_one(), it first executes atomic_read(&rds_ib_allocation)
for if-condition checking,

and then executes atomic_inc(&rds_ib_allocation) if the condition was
not satisfied.

However, if any other code which updates rds_ib_allocation executes
between these two atomic operation executions,
it seems that it may result race condition. (especially when
rds_ib_allocation + 1 == rds_ib_sysctl_max_recv_allocation)"

This patch fixes this by using atomic_inc_unless to eliminate the
possibility of allocating more than rds_ib_sysctl_max_recv_allocation
and then decrementing the count if the allocation fails. It also
makes an identical change to the iwarp transport.

Reported-by: Shin Hong <hongshin@gmail.com>
Signed-off-by: Andy Grover <andy.grover@oracle.com>
net/rds/ib_recv.c
net/rds/iw_recv.c