Repository navigation
[libc][posix] fix: validate fd type in timerfd_settime/gettime - #11996
Conversation
timerfd_do_settime() and timerfd_do_gettime() used vnode->data from any file descriptor as struct rt_timerfd. Validate that the descriptor's file operations are timerfd_fops before dereferencing the private data, using df->fops under DFS v2 and vnode->fops under DFS v1.
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_libcReviewers: @GorrayLi @mysterywolf Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-11-07 03:04 CST)
📝 Review Instructions
|
|
Summary
timerfd_settime()/timerfd_gettime()accepted any file descriptor and treatedvnode->dataasstruct rt_timerfd. This validates the descriptor's file operations before touching the private data, matching the check Linux performs infs/timerfd.c.Fixes #11984.
Change
In
timerfd_do_settime()andtimerfd_do_gettime():timerfd_fops(df->fopsunder DFS v2,vnode->fopsunder DFS v1);-EINVAL/ seterrnoconsistently.Validation
bsp/simulator(host gcc, DFS v1,RT_USING_POSIX_TIMERFD=y);timerfd.ocompiles cleanly.Scope
Only the two descriptor-based entry points are changed.
close/read/pollare reached through fops dispatch and do not need an extra type check.