[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADW8OBstQyqcrt6f0qt9EQOr4_LrFgMd1ve15ZerTw0P-qQN6w@mail.gmail.com>
Date: Wed, 17 Dec 2025 00:38:11 -0700
From: Kyle Zeng <zengyhkyle@...il.com>
To: Gal Pressman <gal@...dia.com>
Cc: richardcochran@...il.com, andrew+netdev@...n.ch, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
netdev@...r.kernel.org
Subject: Re: [PATCH] ptp: prevent info leak to userspace
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@...dia.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@...il.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.
Powered by blists - more mailing lists