Linux: net/rds: acquire RDS_IN_XMIT in rds_tcp_reset_callbacks()
What fixes it
- 670af4e4a4de5e6bb5daee3838485571a0caa5faLinuxCVE List
- 830a2e21b200c6b6fdccc63dd3f23932bf7a894bLinuxCVE List
- 8e4c3b7844c906c7097b4cfedd9dd1f48c9a6a92LinuxCVE List
- 062d9e008c67289e8e1b221ecdd8f9d60566d012LinuxCVE List
- 02c5f9dc2efd823e061954d564ce00bacd1bebebLinuxCVE List
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
In the Linux kernel, the following vulnerability has been resolved:
net/rds: acquire RDS_IN_XMIT in rds_tcp_reset_callbacks()
rds_tcp_reset_callbacks() quiesces the transmit path by setting the path state to RDS_CONN_RESETTING and then waiting for RDS_IN_XMIT to be sampled clear before swapping the underlying socket and calling rds_send_path_reset().
Sampling the bit clear is not the same as owning it: rds_send_xmit() can re-acquire RDS_IN_XMIT right after the wait_event() returns. Its state recheck after taking the lock is a store-buffering pattern (the resetter writes the state and reads the bit, the sender writes the bit and reads the state) and acquire_in_xmit() is only an acquire operation, so on weakly ordered architectures both sides can miss each other's write and the transmit path then runs concurrently with rds_send_path_reset() rewriting cp_xmit_* state - which is exactly what the comment above rds_send_path_reset() tells its callers to prevent.
Take the lock instead, hold it across the socket swap and rds_send_path_reset(), and release it with a wake-up at the end. The lock-ordering constraint documented above the wait still holds: the lock is acquired before lock_sock(), so a sender inside tcp_sendmsg() can never be waited on while we hold the socket lock.
Two details of the old code go away with the same change:
- t_sock is now read only after the lock is acquired. The old code
cached it before waiting; the teardown in rds_conn_shutdown() releases that socket and clears t_sock, so a pointer cached before the wait can be stale by the time the accept path resumes. Reading it under RDS_IN_XMIT is what makes the exclusion complete once the teardown owns the same lock, which the next patch arranges; until then the teardown still only samples the bit, and the two paths remain as exposed to each other as they are today.
- The old !osock early path called rds_send_path_reset() with no
serialization at all. It now runs under the lock like the normal path. The conditional RDS_CONN_RESETTING transition of the previous patch happens before the socket check either way: a path found without a socket is either still connecting (its reconnect worker blocked on t_conn_path_lock) and legitimately goes RESETTING -> UP on the new socket, or it has been torn down meanwhile and is dropped.
The in-function comment describing the old wait-based quiesce is rewritten to describe the lock-based one, and the stale block comment above the function (which still described a return value and an incomplete list of t_sock writers) is refreshed to name all four writers - the connect, accept, teardown and swap paths - and what serializes each of them.
Text from CVE List
Affected versions 18
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before 670af4e4a4de5e6bb5daee3838485571a0caa5faCVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before 830a2e21b200c6b6fdccc63dd3f23932bf7a894bCVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before a05790cb4ff03f797d76906990b148d83f63e7a3CVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before d184e6dd4b8f3c20c018595fd09795a66b46c8efCVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before d625112564c3e980e02504270222b49b82690ceeCVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before 8e4c3b7844c906c7097b4cfedd9dd1f48c9a6a92CVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before 062d9e008c67289e8e1b221ecdd8f9d60566d012CVE List
- Linuxaffected: 335b48d980f631fbc5b233cbb3625ac0c86d67cb before 02c5f9dc2efd823e061954d564ce00bacd1bebebCVE List
- Linuxaffected: 4.7CVE List
- Linuxunaffected: all versions before 4.7CVE List
- Linuxunaffected: 5.10.271 through 5.10.*CVE List
- Linuxunaffected: 5.15.222 through 5.15.*CVE List
- Linuxunaffected: 6.1.189 through 6.1.*CVE List
- Linuxunaffected: 6.6.158 through 6.6.*CVE List
- Linuxunaffected: 6.12.111 through 6.12.*CVE List
- Linuxunaffected: 6.18.53 through 6.18.*CVE List
- Linuxunaffected: 7.2.7 through 7.2.*CVE List
- Linuxunaffected: 7.3CVE List
References 8
- git.kernel.org/stable/c/670af4e4a4de5e6bb5daee3838485571a0caa5faReferencevia CVE List
- git.kernel.org/stable/c/830a2e21b200c6b6fdccc63dd3f23932bf7a894bReferencevia CVE List
- git.kernel.org/stable/c/a05790cb4ff03f797d76906990b148d83f63e7a3Referencevia CVE List
- git.kernel.org/stable/c/d184e6dd4b8f3c20c018595fd09795a66b46c8efReferencevia CVE List
- git.kernel.org/stable/c/d625112564c3e980e02504270222b49b82690ceeReferencevia CVE List
- git.kernel.org/stable/c/8e4c3b7844c906c7097b4cfedd9dd1f48c9a6a92Referencevia CVE List
- git.kernel.org/stable/c/062d9e008c67289e8e1b221ecdd8f9d60566d012Referencevia CVE List
- git.kernel.org/stable/c/02c5f9dc2efd823e061954d564ce00bacd1bebebReferencevia CVE List