专栏中心

EEPW首页 > 专栏 > 征程 6X 之 Memory corruption 问题分析方法

征程 6X 之 Memory corruption 问题分析方法

发布人:地平线开发者 时间:2026-05-07 来源:工程师 发布文章
Memory corruption

对于系统中出现随机、不可解释的异常指针访问或数据错误导致的异常,一般要考虑是内存使用上出现了 UAF(Use-After-Free),OOB(Out-of-Bounds)。

本章所指的”Memory corruption”特指 Linux kernel 侧出现的”Memory corruption”,子系统间的内存踩踏请参考 Firewall 。

通用方法

当怀疑系统有 OOB、UAF 类问题时,打开 CONFIG_KASAN 开关,进行复现。

当出现 memory corruption 问题时,系统默认会 BUG_ON。

检查 panic log 信息,对于 slub、stack、buddy page、全局变量的 UAF 和 OOB 均有关键信息指出,基本通过 log 能够解决所有问题。

典型问题

[ 6.262525] BUG: KASAN: global-out-of-bounds in __of_match_node+0x70/0xb8

[ 6.263391] Read of size 1 at addr ffffff9008d153a8 by task swapper/0/1

[ 6.264231]

[ 6.264439] CPU: 5 PID: 1 Comm: swapper/0 Not tainted 6.1.94-rt33-gac7c113a9bab #2

[ 6.265488] Hardware name: Horizon Robotics 征程 6E Evaluation Module Board (DT)

[ 6.266362] Call trace:

[ 6.266694] [] dump_backtrace+0x0/0x538

[ 6.267391] [] show_stack+0x14/0x20

[ 6.268048] [] dump_stack+0xa4/0xc8

[ 6.268703] [] print_address_description+0x1e4/0x250

[ 6.269539] [] kasan_report+0x2cc/0x300

[ 6.270240] [] __asan_load1+0x44/0x50

[ 6.270912] [] __of_match_node+0x70/0xb8

[ 6.271617] [] of_match_node+0x38/0x60

[ 6.272301] [] of_match_device+0x3c/0x50

[ 6.273012] [] platform_match+0x64/0x118

[ 6.273719] [] __driver_attach+0x40/0x140

[ 6.274435] [] bus_for_each_dev+0xcc/0x140

[ 6.275164] [] driver_attach+0x30/0x40

[ 6.275848] [] bus_add_driver+0x220/0x388

[ 6.276566] [] driver_register+0x108/0x170

[ 6.277295] [] __platform_driver_register+0x7c/0x88

[ 6.278122] [] 征程 6_wdt_driver_init+0x34/0x4c

[ 6.278861] [] do_one_initcall+0xe4/0x1b8

[ 6.279581] [] kernel_init_freeable+0x1ac/0x260

[ 6.280363] [] kernel_init+0x10/0x118

[ 6.281036] [] ret_from_fork+0x10/0x18

[ 6.281713]

[ 6.281911] The buggy address belongs to the variable:

[ 6.282570] 0xffffff9008d153a8

[ 6.282974]

[ 6.283173] Memory state around the buggy address:

[ 6.283794] ffffff9008d15280: fa fa fa fa 07 fa fa fa fa fa fa fa 00 00 00 00

[ 6.284715] ffffff9008d15300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[ 6.285636] >ffffff9008d15380: 00 00 00 00 00 fa fa fa fa fa fa fa 00 00 00 00

[ 6.286552] ^

[ 6.287137] ffffff9008d15400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[ 6.288057] ffffff9008d15480: 00 00 00 fa fa fa fa fa 00 00 fa fa fa fa fa fa

[ 6.288974] ==================================================================

[ 6.289890] Disabling lock debugging due to kernel taint

错误类型 global-out-of-bounds,全局变量越界访问,越界读取访问一个字节。

检查 Calltrace 是在驱动 probe 匹配 device、driver 的过程中。

复杂问题可能需要检查 trace 后面 buggy address(并非实际数据地址,而是在 shadow 区的映射)信息综合分析,此问题可以看到要访问地址 ffffff9008d153a8 里数据为 0xFA,0xFA 代表全局变量的 redzone(越界检测)。

检查逻辑__of_match_node 过程是循环遍历 of_match_table 中所有的项,直到表项中成员为空退出循环。

const struct of_device_id *__of_match_node(const struct of_device_id *matches,

const struct device_node *node)

{

const struct of_device_id *best_match = NULL;

int score, best_score = 0;

if (!matches)

return NULL;

for (; matches->name[0] |matches->type[0] |matches->compatible[0]; matches++) {

score = __of_device_is_compatible(node, matches->compatible,

matches->type, matches->name);

if (score > best_score) {

best_match = matches;

best_score = score;

}

}

return best_match;

}

根据代码可知,越界原因是 of_match_table 变量尾部没有填充 0。

#ifdef CONFIG_OF

static const struct of_device_id 征程 6_wdt_of_match[] = {

  • { .compatible = "snps,征程 6_wdt", }

  • /* sentinel */

  • { .compatible = "snps,征程 6_wdt", },

  • {/* sentinel /} / PRQA S 1041 */};MODULE_D


作者:地平线开发者
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词: 算法 自动驾驶 算法工具链 地平线 征程5

相关推荐

曲面显示屏取代传统汽车挡风玻璃

CRC算法原理及C语言实现

资源下载 2007-02-16

2035年自动驾驶出租车市场规模将达1680亿美元

汽车电子 2026-04-21

高阶智驾要落地,线控底盘为什么必须执行得准

携手ADI赢得未来

视频 2019-11-08

掘金自动驾驶,不要把大坑当机会

汽车电子 2026-04-17

加快实现自动驾驶(完整小组讨论)

视频 2020-06-12

加密算法之MD5算法

数字PID控制算法之一

资源下载 2007-12-28

PID算法

资源下载 2007-02-16

面向算法硬件加速的FPGA实现方法

实时训练驾驶人工智能

恩智浦第三代雷达收发器助力高性能成像雷达规模量产,赋能L2+至L4级自动驾驶

地平线征程 6 系列集成 Cadence Tensilica Vision DSP,实现规模化量产,合作加速智能驾驶解决方案部署

自动驾驶正推动汽车行业加速布局人形机器人

ADI:传感技术助力未来自动驾驶的发展

视频 2020-03-16

76-81GHz自动驾驶CMOS RADAR

视频 2018-05-31

简单实用的单片机CRC 快速算法

资源下载 2007-02-16

Ouster推出 Rev8 OS 激光雷达系列 原生彩色激光雷达正式落地

自动驾驶的现状与未来(节选)

视频 2020-03-16
更多 培训课堂
更多 焦点
更多 视频

技术专区