Warning: mkdir(): No space left on device in /var/www/tg-me/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/ManjusakaH/--): Failed to open stream: No such file or directory in /var/www/tg-me/post.php on line 50
Manjusaka 的碎碎念(以及摇曳露营 S4 制作确定!) | Telegram Webview: ManjusakaH/452 -
Telegram Group & Telegram Channel
Forwarded from Welcome to the Black Parade
开始吹 bpfsnoop (https://github.com/bpfsnoop/bpfsnoop),我至少会在三个场景使用它

1. disas kernel

之前我都是用 gdb -ex 'x/100i 0x'$(ksym skb_gso_validate_network_len) -ex q vmlinux /proc/kcore 这种蹩脚的方式去看汇编;若是 bpf prog 会用 bpftool p d 。但前者要手算 call 的目标函数,后者又长期有 bug (https://github.com/libbpf/bpftool/issues/109)。

但是以后我会用
bpfsnoop -d -k ip_rcv


bpfsnoop -d -p n:cil_to_overlay

来代替 gdb。输出非常好(图一),有颜色,有行号,有正确的 call 指令解析。

2. 用 --output-arg --filter-arg --filter-pkt 做 skb 观测

之前讨论过一个 nf postrouting 不会两次处理同一个 skb 的问题,本质是要观测 skb->_nfct 在生命期内的变化,用 bpfsnoop 可以一步到位:
bpfsnoop --filter-pkt 'icmp and dst host 10.244.2.2'  -t '*:(struct sk_buff *)skb' --output-pkt --output-arg 'skb->_nfct' 

虽然目前还不支持更复杂的操作,比如想观测 skb_sec_path(skb) 则需要写成 --output-arg 'skb->extensions->offset[1] << 3' 然而并不支持,但大部分简单的场景够用了。

3. 用 --output-lbr 观测 bpf prog

bpf prog 自身的观测性一直比较恶心,用 lbr 和 kprobe on bpf helpers 是目前为止我所知的唯二办法,而 bpfsnoop 是唯一实现了前者工程化的工具。(其实两者结合才是最吼的)

比如排查 https://github.com/cilium/cilium/issues/35023 的时候需要找到 bpf 运行的提前返回点,可以先无脑观测 bpf prog 退出时的 lbr
bpfsnoop -p i:7963 --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m exit

然后再根据结果往上以 bpf helper 为节点回溯
bpfsnoop -k bpf_skb_event_output --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m entry

最终定位代码执行流



tg-me.com/ManjusakaH/452
Create:
Last Update:

开始吹 bpfsnoop (https://github.com/bpfsnoop/bpfsnoop),我至少会在三个场景使用它

1. disas kernel

之前我都是用 gdb -ex 'x/100i 0x'$(ksym skb_gso_validate_network_len) -ex q vmlinux /proc/kcore 这种蹩脚的方式去看汇编;若是 bpf prog 会用 bpftool p d 。但前者要手算 call 的目标函数,后者又长期有 bug (https://github.com/libbpf/bpftool/issues/109)。

但是以后我会用

bpfsnoop -d -k ip_rcv


bpfsnoop -d -p n:cil_to_overlay

来代替 gdb。输出非常好(图一),有颜色,有行号,有正确的 call 指令解析。

2. 用 --output-arg --filter-arg --filter-pkt 做 skb 观测

之前讨论过一个 nf postrouting 不会两次处理同一个 skb 的问题,本质是要观测 skb->_nfct 在生命期内的变化,用 bpfsnoop 可以一步到位:
bpfsnoop --filter-pkt 'icmp and dst host 10.244.2.2'  -t '*:(struct sk_buff *)skb' --output-pkt --output-arg 'skb->_nfct' 

虽然目前还不支持更复杂的操作,比如想观测 skb_sec_path(skb) 则需要写成 --output-arg 'skb->extensions->offset[1] << 3' 然而并不支持,但大部分简单的场景够用了。

3. 用 --output-lbr 观测 bpf prog

bpf prog 自身的观测性一直比较恶心,用 lbr 和 kprobe on bpf helpers 是目前为止我所知的唯二办法,而 bpfsnoop 是唯一实现了前者工程化的工具。(其实两者结合才是最吼的)

比如排查 https://github.com/cilium/cilium/issues/35023 的时候需要找到 bpf 运行的提前返回点,可以先无脑观测 bpf prog 退出时的 lbr
bpfsnoop -p i:7963 --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m exit

然后再根据结果往上以 bpf helper 为节点回溯
bpfsnoop -k bpf_skb_event_output --output-lbr --filter-pkt 'dst host 1.1.1.1 and tcp[tcpflags]=tcp-syn' -m entry

最终定位代码执行流

BY Manjusaka 的碎碎念(以及摇曳露营 S4 制作确定!)




Share with your friend now:
tg-me.com/ManjusakaH/452

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

The SSE was the first modern stock exchange to open in China, with trading commencing in 1990. It has now grown to become the largest stock exchange in Asia and the third-largest in the world by market capitalization, which stood at RMB 50.6 trillion (US$7.8 trillion) as of September 2021. Stocks (both A-shares and B-shares), bonds, funds, and derivatives are traded on the exchange. The SEE has two trading boards, the Main Board and the Science and Technology Innovation Board, the latter more commonly known as the STAR Market. The Main Board mainly hosts large, well-established Chinese companies and lists both A-shares and B-shares.

In many cases, the content resembled that of the marketplaces found on the dark web, a group of hidden websites that are popular among hackers and accessed using specific anonymising software.“We have recently been witnessing a 100 per cent-plus rise in Telegram usage by cybercriminals,” said Tal Samra, cyber threat analyst at Cyberint.The rise in nefarious activity comes as users flocked to the encrypted chat app earlier this year after changes to the privacy policy of Facebook-owned rival WhatsApp prompted many to seek out alternatives.telegram from id


Telegram Manjusaka 的碎碎念(以及摇曳露营 S4 制作确定!)
FROM USA