Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: Qitao Xu <qitao.xu@bytedance.com>,
	"David S. Miller" <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Cong Wang <cong.wang@bytedance.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-hardening@vger.kernel.org
Subject: Re: [Patch net-next resend v2] net: use %px to print skb address in trace_netif_receive_skb
Date: Tue, 27 Jul 2021 20:17:45 -0700	[thread overview]
Message-ID: <CAM_iQpV3Qm_GTfCX1E_OC0PXu+diT9QHtPt4OYcJdyGRcA37Sw@mail.gmail.com> (raw)
In-Reply-To: <202107230000.B52B102@keescook>

On Fri, Jul 23, 2021 at 12:09 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Jul 14, 2021 at 10:59:23PM -0700, Cong Wang wrote:
> > From: Qitao Xu <qitao.xu@bytedance.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.

  reply	other threads:[~2021-07-28  3:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  5:59 Cong Wang
2021-07-15 17:40 ` patchwork-bot+netdevbpf
2021-07-23  7:09 ` Kees Cook
2021-07-28  3:17   ` Cong Wang [this message]
2021-07-28 15:13   ` tracepoints and %p [was: Re: [Patch net-next resend v2] net: use %px to print skb address in trace_netif_receive_skb] Jann Horn
2021-07-28 15:56     ` Steven Rostedt
2021-07-28 18:48       ` Kees Cook
2021-07-28 18:56         ` Jann Horn
2021-07-28 20:41         ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM_iQpV3Qm_GTfCX1E_OC0PXu+diT9QHtPt4OYcJdyGRcA37Sw@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=cong.wang@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=qitao.xu@bytedance.com \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [Patch net-next resend v2] net: use %px to print skb address in trace_netif_receive_skb' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).