[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpV3Qm_GTfCX1E_OC0PXu+diT9QHtPt4OYcJdyGRcA37Sw@mail.gmail.com>
Date: Tue, 27 Jul 2021 20:17:45 -0700
From: Cong Wang <xiyou.wangcong@...il.com>
To: Kees Cook <keescook@...omium.org>
Cc: Qitao Xu <qitao.xu@...edance.com>,
"David S. Miller" <davem@...emloft.net>,
Linux Kernel Network Developers <netdev@...r.kernel.org>,
Cong Wang <cong.wang@...edance.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-hardening@...r.kernel.org
Subject: Re: [Patch net-next resend v2] net: use %px to print skb address in trace_netif_receive_skb
On Fri, Jul 23, 2021 at 12:09 AM Kees Cook <keescook@...omium.org> wrote:
>
> On Wed, Jul 14, 2021 at 10:59:23PM -0700, Cong Wang wrote:
> > From: Qitao Xu <qitao.xu@...edance.com>
> >
> > The print format of skb adress in tracepoint class net_dev_template
> > is changed to %px from %p, because we want to use skb address
> > as a quick way to identify a packet.
>
> No; %p was already hashed to uniquely identify unique addresses. This
> is needlessly exposing kernel addresses with no change in utility. See
> [1] for full details on when %px is justified (almost never).
This is clearly not true. Trust us, we _did_ use %p in the beginning,
it does not work at all. See the trace below captured with %p:
<idle>-0 [012] ..s. 385.248024: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=56 <idle>-0 [012] ..s. 385.261602:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=38 <idle>-0
[012] ..s. 387.245617: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 389.293621:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=38 <idle>-0
[012] ..s. 391.277637: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 392.939159:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=60 <idle>-0
[012] .Ns. 392.939197: ip_rcv: skbaddr=000000003fa575fb <idle>-0 [012]
.Ns. 392.939286: ip_local_deliver_finish: skbaddr=000000003fa575fb
kworker/12:1-122 [012] ..s. 392.939369: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=52 kworker/12:1-122 [012] ..s.
392.939371: ip_rcv: skbaddr=000000003fa575fb kworker/12:1-122 [012]
..s. 392.939409: ip_local_deliver_finish: skbaddr=000000003fa575fb
<idle>-0 [012] ..s. 393.261605: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 395.174268:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=56 <idle>-0
[012] ..s. 395.174275: ip_rcv: skbaddr=000000003fa575fb <idle>-0 [012]
..s. 395.174284: sk_data_ready: skaddr=0000000049f7d0d9,
skbaddr=000000003fa575fb <idle>-0 [012] .Ns. 395.174337: tcp_v4_rcv:
sport=8801 dport=15884 saddr=192.168.122.139 daddr=192.168.122.1
saddrv6=::ffff:192.168.122.139 daddrv6=::ffff:192.168.122.1
state=TCP_ESTABLISHED skbaddr=000000003fa575fb <idle>-0 [012] .Ns.
395.174338: ip_local_deliver_finish: skbaddr=000000003fa575fb <idle>-0
[012] ..s. 395.245605: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 397.293632:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=38 <idle>-0
[012] ..s. 397.352766: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=56 <idle>-0 [012] ..s. 397.352771:
ip_rcv: skbaddr=000000003fa575fb <idle>-0 [012] ..s. 397.352813:
sk_data_ready: skaddr=0000000049f7d0d9, skbaddr=000000003fa575fb
<idle>-0 [012] .Ns. 397.352819: tcp_v4_rcv: sport=8801 dport=15884
saddr=192.168.122.139 daddr=192.168.122.1
saddrv6=::ffff:192.168.122.139 daddrv6=::ffff:192.168.122.1
state=TCP_ESTABLISHED skbaddr=000000003fa575fb <idle>-0 [012] .Ns.
397.352819: ip_local_deliver_finish: skbaddr=000000003fa575fb <idle>-0
[012] ..s. 399.277623: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 401.261640:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=38 <idle>-0
[012] ..s. 402.671285: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=56 <idle>-0 [012] ..s. 402.671294:
ip_rcv: skbaddr=000000003fa575fb <idle>-0 [012] ..s. 402.671344:
sk_data_ready: skaddr=0000000049f7d0d9, skbaddr=000000003fa575fb
<idle>-0 [012] .Ns. 402.671355: tcp_v4_rcv: sport=8801 dport=15884
saddr=192.168.122.139 daddr=192.168.122.1
saddrv6=::ffff:192.168.122.139 daddrv6=::ffff:192.168.122.1
state=TCP_ESTABLISHED skbaddr=000000003fa575fb <idle>-0 [012] .Ns.
402.671356: ip_local_deliver_finish: skbaddr=000000003fa575fb <idle>-0
[012] ..s. 403.245617: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 403.688075:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=52 <idle>-0
[012] ..s. 403.688080: ip_rcv: skbaddr=000000003fa575fb <idle>-0 [012]
.Ns. 403.688092: sk_data_ready: skaddr=0000000049f7d0d9,
skbaddr=000000003fa575fb <idle>-0 [012] .Ns. 403.688094: tcp_v4_rcv:
sport=8801 dport=15884 saddr=192.168.122.139 daddr=192.168.122.1
saddrv6=::ffff:192.168.122.139 daddrv6=::ffff:192.168.122.1
state=TCP_CLOSE_WAIT skbaddr=000000003fa575fb <idle>-0 [012] .Ns.
403.688095: ip_local_deliver_finish: skbaddr=000000003fa575fb nc-1044
[012] ..s. 403.688222: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=52 nc-1044 [012] ..s. 403.688222: ip_rcv:
skbaddr=000000003fa575fb nc-1044 [012] ..s. 403.688237: tcp_v4_rcv:
sport=8801 dport=15884 saddr=192.168.122.139 daddr=192.168.122.1
saddrv6=::ffff:192.168.122.139 daddrv6=::ffff:192.168.122.1
state=TCP_CLOSE skbaddr=000000003fa575fb nc-1044 [012] ..s.
403.688246: ip_local_deliver_finish: skbaddr=000000003fa575fb <idle>-0
[012] ..s. 405.293625: netif_receive_skb: dev=eth0
skbaddr=000000003fa575fb len=38 <idle>-0 [012] ..s. 407.137723:
netif_receive_skb: dev=eth0 skbaddr=000000003fa575fb len=222
>
> > Note, trace ring buffer is only accessible to privileged users,
> > it is safe to use a real kernel address here.
>
> That's not accurate either; there is a difference between uid 0 and
> kernel mode privilege levels.
Not sure how accurate we can be just to make you happy. Please
give us a pointer on the accuracy.
Thanks.
Powered by blists - more mailing lists