Commit ae8f160
netlink: Fix wraparounds of sk->sk_rmem_alloc.
Netlink has this pattern in some places
if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf)
atomic_add(skb->truesize, &sk->sk_rmem_alloc);
, which has the same problem fixed by commit 5a465a0 ("udp:
Fix multiple wraparounds of sk->sk_rmem_alloc.").
For example, if we set INT_MAX to SO_RCVBUFFORCE, the condition
is always false as the two operands are of int.
Then, a single socket can eat as many skb as possible until OOM
happens, and we can see multiple wraparounds of sk->sk_rmem_alloc.
Let's fix it by using atomic_add_return() and comparing the two
variables as unsigned int.
Before:
[root@fedora ~]# ss -f netlink
Recv-Q Send-Q Local Address:Port Peer Address:Port
-1668710080 0 rtnl:nl_wraparound/293 *
After:
[root@fedora ~]# ss -f netlink
Recv-Q Send-Q Local Address:Port Peer Address:Port
2147483072 0 rtnl:nl_wraparound/290 *
^
`--- INT_MAX - 576
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Jason Baron <jbaron@akamai.com>
Closes: https://lore.kernel.org/netdev/cover.1750285100.git.jbaron@akamai.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250704054824.1580222-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>1 parent 4e2bba3 commit ae8f160
1 file changed
Lines changed: 49 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
391 | 390 | | |
392 | 391 | | |
393 | 392 | | |
| |||
1212 | 1211 | | |
1213 | 1212 | | |
1214 | 1213 | | |
| 1214 | + | |
1215 | 1215 | | |
| 1216 | + | |
1216 | 1217 | | |
1217 | 1218 | | |
| 1219 | + | |
1218 | 1220 | | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1232 | 1226 | | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
| 1227 | + | |
1237 | 1228 | | |
1238 | | - | |
1239 | | - | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
1240 | 1232 | | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1241 | 1236 | | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1247 | 1253 | | |
1248 | | - | |
1249 | | - | |
| 1254 | + | |
| 1255 | + | |
1250 | 1256 | | |
1251 | 1257 | | |
1252 | 1258 | | |
| |||
1307 | 1313 | | |
1308 | 1314 | | |
1309 | 1315 | | |
| 1316 | + | |
1310 | 1317 | | |
1311 | 1318 | | |
1312 | 1319 | | |
| |||
1383 | 1390 | | |
1384 | 1391 | | |
1385 | 1392 | | |
| 1393 | + | |
1386 | 1394 | | |
1387 | | - | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1388 | 1399 | | |
1389 | 1400 | | |
1390 | 1401 | | |
1391 | | - | |
| 1402 | + | |
1392 | 1403 | | |
| 1404 | + | |
| 1405 | + | |
1393 | 1406 | | |
1394 | 1407 | | |
1395 | 1408 | | |
| |||
2249 | 2262 | | |
2250 | 2263 | | |
2251 | 2264 | | |
| 2265 | + | |
2252 | 2266 | | |
2253 | 2267 | | |
2254 | 2268 | | |
| |||
2258 | 2272 | | |
2259 | 2273 | | |
2260 | 2274 | | |
2261 | | - | |
2262 | | - | |
2263 | | - | |
2264 | 2275 | | |
2265 | 2276 | | |
2266 | 2277 | | |
| |||
2283 | 2294 | | |
2284 | 2295 | | |
2285 | 2296 | | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
2286 | 2303 | | |
2287 | 2304 | | |
2288 | 2305 | | |
| |||
0 commit comments