* [PATCH net-next] net: use the %px format to display sock
@ 2022-05-05 13:08 kerneljasonxing
2022-05-06 18:56 ` Peilin Ye
0 siblings, 1 reply; 4+ messages in thread
From: kerneljasonxing @ 2022-05-05 13:08 UTC (permalink / raw)
To: davem, yoshfuji, dsahern, kuba, pabeni, ast, daniel, andrii,
kafai, songliubraving, yhs, john.fastabend, kpsingh
Cc: netdev, linux-kernel, bpf, kerneljasonxing, Jason Xing
From: Jason Xing <xingwanli@kuaishou.com>
I found that the current socket address, say 000000009842d952, cannot be
searched in messages because %p format function hashes and converts it
into an unique identifier which is currently useless for debugging.
Signed-off-by: Jason Xing <xingwanli@kuaishou.com>
---
net/ipv4/af_inet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 72fde28..b17a4d4 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -139,12 +139,12 @@ void inet_sock_destruct(struct sock *sk)
sk_mem_reclaim_final(sk);
if (sk->sk_type == SOCK_STREAM && sk->sk_state != TCP_CLOSE) {
- pr_err("Attempt to release TCP socket in state %d %p\n",
+ pr_err("Attempt to release TCP socket in state %d %px\n",
sk->sk_state, sk);
return;
}
if (!sock_flag(sk, SOCK_DEAD)) {
- pr_err("Attempt to release alive inet socket %p\n", sk);
+ pr_err("Attempt to release alive inet socket %px\n", sk);
return;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: use the %px format to display sock
2022-05-05 13:08 [PATCH net-next] net: use the %px format to display sock kerneljasonxing
@ 2022-05-06 18:56 ` Peilin Ye
2022-05-07 1:26 ` Jason Xing
0 siblings, 1 reply; 4+ messages in thread
From: Peilin Ye @ 2022-05-06 18:56 UTC (permalink / raw)
To: kerneljasonxing
Cc: davem, yoshfuji, dsahern, kuba, pabeni, ast, daniel, andrii,
kafai, songliubraving, yhs, john.fastabend, kpsingh, netdev,
linux-kernel, bpf, Jason Xing
Hi Jason,
On Thu, May 05, 2022 at 09:08:26PM +0800, kerneljasonxing@gmail.com wrote:
> - pr_err("Attempt to release TCP socket in state %d %p\n",
> + pr_err("Attempt to release TCP socket in state %d %px\n",
I think we cannot use %px here for security reasons? checkpatch is also
warning about it:
WARNING: Using vsprintf specifier '%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '%p'.
#21: FILE: net/ipv4/af_inet.c:142:
+ pr_err("Attempt to release TCP socket in state %d %px\n",
sk->sk_state, sk);
Thanks,
Peilin Ye
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: use the %px format to display sock
2022-05-06 18:56 ` Peilin Ye
@ 2022-05-07 1:26 ` Jason Xing
2022-05-07 14:22 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: Jason Xing @ 2022-05-07 1:26 UTC (permalink / raw)
To: Peilin Ye
Cc: davem, yoshfuji, dsahern, kuba, pabeni, ast, daniel, andrii,
kafai, songliubraving, yhs, john.fastabend, kpsingh, netdev,
linux-kernel, bpf, Jason Xing
On Sat, May 7, 2022 at 2:56 AM Peilin Ye <yepeilin.cs@gmail.com> wrote:
>
> Hi Jason,
>
> On Thu, May 05, 2022 at 09:08:26PM +0800, kerneljasonxing@gmail.com wrote:
> > - pr_err("Attempt to release TCP socket in state %d %p\n",
> > + pr_err("Attempt to release TCP socket in state %d %px\n",
>
> I think we cannot use %px here for security reasons? checkpatch is also
> warning about it:
>
I noticed this warning before submitting. Since the %p format doesn't
print the real address, printing the address here will be helpless and
we cannot trace what exactly the bad socket is.
What do you suggest?
Thanks,
Jason
> WARNING: Using vsprintf specifier '%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '%p'.
> #21: FILE: net/ipv4/af_inet.c:142:
> + pr_err("Attempt to release TCP socket in state %d %px\n",
> sk->sk_state, sk);
>
> Thanks,
> Peilin Ye
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: use the %px format to display sock
2022-05-07 1:26 ` Jason Xing
@ 2022-05-07 14:22 ` Andrew Lunn
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2022-05-07 14:22 UTC (permalink / raw)
To: Jason Xing
Cc: Peilin Ye, davem, yoshfuji, dsahern, kuba, pabeni, ast, daniel,
andrii, kafai, songliubraving, yhs, john.fastabend, kpsingh,
netdev, linux-kernel, bpf, Jason Xing
On Sat, May 07, 2022 at 09:26:07AM +0800, Jason Xing wrote:
> On Sat, May 7, 2022 at 2:56 AM Peilin Ye <yepeilin.cs@gmail.com> wrote:
> >
> > Hi Jason,
> >
> > On Thu, May 05, 2022 at 09:08:26PM +0800, kerneljasonxing@gmail.com wrote:
> > > - pr_err("Attempt to release TCP socket in state %d %p\n",
> > > + pr_err("Attempt to release TCP socket in state %d %px\n",
> >
> > I think we cannot use %px here for security reasons? checkpatch is also
> > warning about it:
> >
>
> I noticed this warning before submitting. Since the %p format doesn't
> print the real address, printing the address here will be helpless and
> we cannot trace what exactly the bad socket is.
>
> What do you suggest?
How is a socket identified in places like /proc/<PID>/net/tcp ?
Could you print the local and remote port to identify the socket?
How does the address of the structure actually help you? Do you see
this address somewhere else?
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-07 14:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 13:08 [PATCH net-next] net: use the %px format to display sock kerneljasonxing
2022-05-06 18:56 ` Peilin Ye
2022-05-07 1:26 ` Jason Xing
2022-05-07 14:22 ` Andrew Lunn
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).