p11-kit: Update to 0.23.15
[feed/packages.git] / net / haproxy / patches / 008-BUG-MINOR-stick_table-Prevent-conn_cur-from-underflowing.patch
1 commit 93b3994091b5bd17b43c9d91ecae470d33157e25
2 Author: Tim Duesterhus <tim@bastelstu.be>
3 Date: Fri Jan 4 00:11:59 2019 +0100
4
5 BUG/MINOR: stick_table: Prevent conn_cur from underflowing
6
7 When using the peers feature a race condition could prevent
8 a connection from being properly counted. When this connection
9 exits it is being "uncounted" nonetheless, leading to a possible
10 underflow (-1) of the conn_curr stick table entry in the following
11 scenario :
12
13 - Connect to peer A (A=1, B=0)
14 - Peer A sends 1 to B (A=1, B=1)
15 - Kill connection to A (A=0, B=1)
16 - Connect to peer B (A=0, B=2)
17 - Peer A sends 0 to B (A=0, B=0)
18 - Peer B sends 0/2 to A (A=?, B=0)
19 - Kill connection to B (A=?, B=-1)
20 - Peer B sends -1 to A (A=-1, B=-1)
21
22 This fix may be backported to all supported branches.
23
24 (cherry picked from commit 8b87c01c4d59247d9fb51a38cd12d5d94324b6a4)
25 Signed-off-by: Willy Tarreau <w@1wt.eu>
26 (cherry picked from commit 4ceecc8a4ee6f46f20c7729056e14af5a8757121)
27 Signed-off-by: William Lallemand <wlallemand@haproxy.org>
28
29 diff --git a/include/proto/session.h b/include/proto/session.h
30 index f48c0d4f..7265f5a7 100644
31 --- a/include/proto/session.h
32 +++ b/include/proto/session.h
33 @@ -59,7 +59,8 @@ static inline void session_store_counters(struct session *sess)
34 if (ptr) {
35 HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
36
37 - stktable_data_cast(ptr, conn_cur)--;
38 + if (stktable_data_cast(ptr, conn_cur) > 0)
39 + stktable_data_cast(ptr, conn_cur)--;
40
41 HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
42
43 diff --git a/include/proto/stream.h b/include/proto/stream.h
44 index 8521957e..c9bcac37 100644
45 --- a/include/proto/stream.h
46 +++ b/include/proto/stream.h
47 @@ -104,7 +104,8 @@ static inline void stream_store_counters(struct stream *s)
48 if (ptr) {
49 HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
50
51 - stktable_data_cast(ptr, conn_cur)--;
52 + if (stktable_data_cast(ptr, conn_cur) > 0)
53 + stktable_data_cast(ptr, conn_cur)--;
54
55 HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
56
57 @@ -142,7 +143,8 @@ static inline void stream_stop_content_counters(struct stream *s)
58 if (ptr) {
59 HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
60
61 - stktable_data_cast(ptr, conn_cur)--;
62 + if (stktable_data_cast(ptr, conn_cur) > 0)
63 + stktable_data_cast(ptr, conn_cur)--;
64
65 HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
66