Netdev List
 help / color / mirror / Atom feed
From: Gal Pressman <gal@nvidia.com>
To: Kyle Zeng <zengyhkyle@gmail.com>,
	richardcochran@gmail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH] ptp: prevent info leak to userspace
Date: Wed, 17 Dec 2025 09:28:43 +0200	[thread overview]
Message-ID: <a5ef868d-b957-4124-a9ed-030f863dcd29@nvidia.com> (raw)
In-Reply-To: <aUJYSv6kqb9QauMI@westworld>

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.

  reply	other threads:[~2025-12-17  7:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17  7:14 [PATCH] ptp: prevent info leak to userspace Kyle Zeng
2025-12-17  7:28 ` Gal Pressman [this message]
2025-12-17  7:38   ` Kyle Zeng

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=a5ef868d-b957-4124-a9ed-030f863dcd29@nvidia.com \
    --to=gal@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=zengyhkyle@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox