bpf_probe_read的原子性?

huangapple go评论58阅读模式
英文:

are bpf_probe_read's atomic?

问题

bpf_probe_read函数等是否是原子操作?它们是否会增加它们正在读取的数据结构的引用计数?因为如果读操作不是原子操作,当读取正在进行时,内核释放该数据结构,是否会导致内核恶性错误(段错误)?

未找到bpf_probe_read的定义,因此无法自行确认。

英文:

Are bpf_probe_read functions etc, atomic ? And do they inc ref counts of the data structure they're are reading, because if the operation is not atomic while the read is going through the kernel deallocates that data structure can it not cause a kernel panic (SEG FAULT).

Did not find the defintion of bpf_probe_read so could not confirm the same on my own.

答案1

得分: 1

bpf_probe_read函数用于读取内核内存,它是使用copy_from_kernel_nofault函数实现的。该函数在读取时禁用页面故障处理,因此内核不会发生恶化或出现段错误。从技术上讲,"Atomic"也许并不是正确的术语,因为据我所知,没有内存锁定,所以在读取时内存可能会被修改。

英文:

Atomic is perhaps not the the correct term since, as far as I can tell there is no memory locking, so it would technically be possible that memory is modified while you are reading it.

But the bpf_probe_read for kernel memory is implemented using the copy_from_kernel_nofault function which disables page faults while reading, so the kernel will not panic or get a seg fault.

huangapple
  • 本文由 发表于 2023年2月24日 17:00:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75554504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定