2022-05-07 16:57:01

by Peilin Ye

[permalink] [raw]
Subject: Re: [PATCH net-next] net: use the %px format to display sock

Hi Jason,

On Thu, May 05, 2022 at 09:08:26PM +0800, [email protected] 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



2022-05-09 07:55:32

by Jason Xing

[permalink] [raw]
Subject: Re: [PATCH net-next] net: use the %px format to display sock

On Sat, May 7, 2022 at 2:56 AM Peilin Ye <[email protected]> wrote:
>
> Hi Jason,
>
> On Thu, May 05, 2022 at 09:08:26PM +0800, [email protected] 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
>