英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论