watchdog: ping frequency can exceed the timeout the driver accepted

未关闭
#57 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

@thc1006 已经在做这个了。

开始于 2026年10月18日。

  • #58 来自 @thc1006 —— 未关闭
  • #59 来自 @thc1006 —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
15/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
c, linux

调研方向

The issue points to the watchdog decision block in system.c (watchdog_set) and links the fix in #58. Read that handler and compare the accepted timeout with the frequency it selects; the issue’s softdog reproduction starts at 30 s and requests {"timeout":200000,"frequency":90000}. Done means the frequency is capped against the timeout the driver actually keeps, so this case leaves a 30 s timeout and 15 s frequency.

由索引模型根据 Issue 内容生成。

描述

Follow-up to #55, in the ubus handler (system.c:watchdog_set).

ubus call system watchdog can set the timeout and the ping frequency in one call. The handler caps the frequency at half the timeout, but it does that against the timeout the caller requested, and before the timeout is applied. When the driver cannot accept the requested timeout (EINVAL, for example above 107 s on rt2880_wdt at 40 MHz), the timeout keeps its old value. The frequency can still be as high as half the requested timeout. If that frequency is larger than the timeout now in force, procd pings less often than the timeout requires and the board can reset while it is still running.

#55 did not cause this. Before it the handler reported the requested timeout, so the timeout and frequency it returned still looked consistent; now it reports the timeout in force, so the mismatch shows.

How I saw it, on x86-64 with GCC 13.3.0: I copied the handler's decision block, old and new, out of system.c and ran both against a real softdog, with watchdog.c from main. softdog was loaded with soft_noboot=1, so an expiry is only logged. It refuses any timeout above 65535 s. From a 30 s timeout, {"timeout":200000,"frequency":90000} leaves a 30 s timeout and a 90000 s frequency with the current code. Re-checking the frequency against the timeout the driver kept leaves 30 s and 15 s.

Setting the watchdog over ubus is normally a root operation, so the effect is a misconfiguration that can reset a live board.

The fix is in #58.

主要语言
C
星标
13
派生
49
平均合并
11 天 12 小时
30 天内合并 PR
3

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openwrt/procd 的其他 Issue

查看 openwrt/procd 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。