All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ptp: prevent info leak to userspace
@ 2025-12-17  7:14 Kyle Zeng
  2025-12-17  7:28 ` Gal Pressman
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Zeng @ 2025-12-17  7:14 UTC (permalink / raw)
  To: richardcochran, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev

Somehow the `memset` is lost after refactor, which leaks a lot of kernel
stack data to userspace directly. This patch clears the reserved data
region to prevent the info leak.

Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
---
 drivers/ptp/ptp_chardev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index c61cf9edac48..06f71011fb04 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -195,6 +195,8 @@ static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg)
 	if (caps.adjust_phase)
 		caps.max_phase_adj = ptp->info->getmaxphase(ptp->info);
 
+	memset(caps.rsv, 0, sizeof(caps.rsv));
+
 	return copy_to_user(arg, &caps, sizeof(caps)) ? -EFAULT : 0;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: prevent info leak to userspace
  2025-12-17  7:14 [PATCH] ptp: prevent info leak to userspace Kyle Zeng
@ 2025-12-17  7:28 ` Gal Pressman
  2025-12-17  7:38   ` Kyle Zeng
  0 siblings, 1 reply; 3+ messages in thread
From: Gal Pressman @ 2025-12-17  7:28 UTC (permalink / raw)
  To: Kyle Zeng, richardcochran, andrew+netdev, davem, edumazet, kuba,
	pabeni, netdev

On 17/12/2025 9:14, Kyle Zeng wrote:
> Somehow the `memset` is lost after refactor, which leaks a lot of kernel
> stack data to userspace directly. This patch clears the reserved data
> region to prevent the info leak.
> 
> Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
> ---
>  drivers/ptp/ptp_chardev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> index c61cf9edac48..06f71011fb04 100644
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -195,6 +195,8 @@ static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg)
>  	if (caps.adjust_phase)
>  		caps.max_phase_adj = ptp->info->getmaxphase(ptp->info);
>  
> +	memset(caps.rsv, 0, sizeof(caps.rsv));
> +
>  	return copy_to_user(arg, &caps, sizeof(caps)) ? -EFAULT : 0;
>  }
>  

This is not how C works, the designated initializer clears the field
implicitly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: prevent info leak to userspace
  2025-12-17  7:28 ` Gal Pressman
@ 2025-12-17  7:38   ` Kyle Zeng
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Zeng @ 2025-12-17  7:38 UTC (permalink / raw)
  To: Gal Pressman
  Cc: richardcochran, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev

I apologize for the rookie mistake. Should've known better than this.
And thanks for the correction.

On Wed, Dec 17, 2025 at 12:28 AM Gal Pressman <gal@nvidia.com> wrote:
>
> On 17/12/2025 9:14, Kyle Zeng wrote:
> > Somehow the `memset` is lost after refactor, which leaks a lot of kernel
> > stack data to userspace directly. This patch clears the reserved data
> > region to prevent the info leak.
> >
> > Signed-off-by: Kyle Zeng <zengyhkyle@gmail.com>
> > ---
> >  drivers/ptp/ptp_chardev.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> > index c61cf9edac48..06f71011fb04 100644
> > --- a/drivers/ptp/ptp_chardev.c
> > +++ b/drivers/ptp/ptp_chardev.c
> > @@ -195,6 +195,8 @@ static long ptp_clock_getcaps(struct ptp_clock *ptp, void __user *arg)
> >       if (caps.adjust_phase)
> >               caps.max_phase_adj = ptp->info->getmaxphase(ptp->info);
> >
> > +     memset(caps.rsv, 0, sizeof(caps.rsv));
> > +
> >       return copy_to_user(arg, &caps, sizeof(caps)) ? -EFAULT : 0;
> >  }
> >
>
> This is not how C works, the designated initializer clears the field
> implicitly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-17  7:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17  7:14 [PATCH] ptp: prevent info leak to userspace Kyle Zeng
2025-12-17  7:28 ` Gal Pressman
2025-12-17  7:38   ` Kyle Zeng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.