Commit 5f77ddb
gtp: serialize PDP context updates
commit 498386b upstream.
PDP contexts can be deleted through GTP_CMD_DELPDP or while the GTP
network device is being unregistered. The latter is serialized by RTNL,
but the generic-netlink delete path only holds RCU.
Running both paths concurrently can therefore make both paths delete the
same PDP context. The issue was found through static analysis and
reproduced on a KASAN-enabled kernel by a simple two-thread program
racing GTP_CMD_DELPDP against RTM_DELLINK:
Oops: general protection fault, probably for non-canonical address
KASAN: maybe wild-memory-access in range
[0xdead000000000120-0xdead000000000127]
RIP: gtp_genl_del_pdp+0x1c1/0x420 [gtp]
RBP: dead000000000122
The second deletion dereferenced the poisoned hlist pprev pointer.
Serialize gtp_pdp_add(), gtp_genl_del_pdp(), and gtp_dellink() with a
shared mutex. Keep the mutex held until the final use of a PDP context in
the NEWPDP path, and keep the RCU read-side section around the complete
PDP context use in the DELPDP path.
Fixes: 459aa66 ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Cc: stable@vger.kernel.org
Signed-off-by: Qing Ming <a0yami@mailbox.org>
Link: https://patch.msgid.link/20260818150000.7670-1-a0yami@mailbox.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent b7f10d4 commit 5f77ddb
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | | - | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
168 | | - | |
| 171 | + | |
| 172 | + | |
169 | 173 | | |
170 | 174 | | |
171 | 175 | | |
| |||
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
185 | | - | |
| 189 | + | |
| 190 | + | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
| |||
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
220 | | - | |
| 225 | + | |
| 226 | + | |
221 | 227 | | |
222 | 228 | | |
223 | 229 | | |
| |||
1550 | 1556 | | |
1551 | 1557 | | |
1552 | 1558 | | |
| 1559 | + | |
1553 | 1560 | | |
1554 | 1561 | | |
1555 | 1562 | | |
| 1563 | + | |
1556 | 1564 | | |
1557 | 1565 | | |
1558 | 1566 | | |
| |||
2051 | 2059 | | |
2052 | 2060 | | |
2053 | 2061 | | |
| 2062 | + | |
2054 | 2063 | | |
2055 | 2064 | | |
2056 | 2065 | | |
2057 | 2066 | | |
2058 | 2067 | | |
2059 | 2068 | | |
2060 | 2069 | | |
| 2070 | + | |
2061 | 2071 | | |
2062 | 2072 | | |
2063 | 2073 | | |
| |||
2135 | 2145 | | |
2136 | 2146 | | |
2137 | 2147 | | |
| 2148 | + | |
| 2149 | + | |
2138 | 2150 | | |
2139 | 2151 | | |
2140 | 2152 | | |
| |||
2155 | 2167 | | |
2156 | 2168 | | |
2157 | 2169 | | |
| 2170 | + | |
2158 | 2171 | | |
2159 | 2172 | | |
2160 | 2173 | | |
| |||
0 commit comments