tcp: Add preempt_{disable,enable}_nested() in reqsk_queue_hash_req().
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
tcp: Add preempt_{disable,enable}_nested() in reqsk_queue_hash_req().
syzbot reported a weird reqsk->rsk_refcnt underflow in __inet_csk_reqsk_queue_drop().
The captured reqsk_put() in __inet_csk_reqsk_queue_drop() is called only when it successfully removes reqsk from ehash.
Moreover, reqsk_timer_handler() calls another reqsk_put() after that.
This indicates that the reqsk was missing both refcnts for ehash and the timer itself.
Since all the syzbot reports had PREEMPT_RT enabled, the only possible scenario is that reqsk_queue_hash_req() is preempted after mod_timer() and before refcount_set(), and then the timer triggered after 1s aborts the reqsk due to its listener's close().
Let's wrap mod_timer() and refcount_set() with preempt_disable_nested() and preempt_enable_nested().
From the CVE record · Linux
A race in Linux kernel TCP request socket handling can cause a reference-count underflow and a use-after-free warning. The reported scenario requires PREEMPT_RT: request socket setup is preempted after its timer is set, and the timer fires after the listener closes. The input does not establish whether an attacker can trigger this over the network or locally, or whether authentication or user interaction is required.
Engineers running Linux kernels with PREEMPT_RT should check their kernel versions against the vendor advisory; affected versions are not specified in the input.