summaryrefslogtreecommitdiff
path: root/include/linux/timerfd.h
diff options
context:
space:
mode:
authorYu Zhang <yuz08559@gmail.com>2026-10-26 20:05:35 +1000
committerJakub Kicinski <kuba@kernel.org>2026-10-30 16:04:08 -0700
commit603a0c40d414ea12509fc45f2b930449a8d4aad2 (patch)
treeb13460a9a1656293e3195ad841bf3b1e9b9f9423 /include/linux/timerfd.h
parentcd74322d83d88c8407f751cb09dbc51d0ebc5a41 (diff)
ptp: fix use-after-free in extts_fifo_show() reading tsevqs unlocked
extts_fifo_show() walks ptp->tsevqs with list_count_nodes() and then list_first_entry() without holding ptp->tsevqs_lock, the spinlock that "protects tsevqs from concurrent access". Every other accessor of the list honours it: ptp_open() (list_add_tail), ptp_release() (list_del followed by kfree of the per-fd queue), ptp_clock_release() and ptp_clock_event() all take tsevqs_lock. extts_fifo_show() is the only one that does not. A per-fd timestamp queue is appended to tsevqs on open("/dev/ptpN") and removed and freed on close(), both under tsevqs_lock: scoped_guard(spinlock_irq, &ptp->tsevqs_lock) list_del(&queue->qlist); bitmap_free(queue->mask); kfree(queue); So a read of /sys/class/ptp/ptpN/fifo running concurrently with a close() of a /dev/ptpN fd can have list_count_nodes() walk into the queue that close() is removing and freeing, dereferencing freed memory (use-after-free) or a poisoned list pointer. Take tsevqs_lock around the list walk. The fifo only ever draws from the first queue, which is the registration-time queue created in ptp_clock_register() and freed only in ptp_clock_release(); that cannot run while the sysfs attribute is being read, so the dequeue from queue->buf under queue->lock may stay outside tsevqs_lock and the lock order is unchanged. Fixes: d26ab5a35ad9 ("ptp: Replace timestamp event queue with linked list") Cc: stable@vger.kernel.org Signed-off-by: Yu Zhang <yuz08559@gmail.com> Link: https://patch.msgid.link/20261026100535.68114-1-yuz08559@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux/timerfd.h')
0 files changed, 0 insertions, 0 deletions