mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bastien Curutchet <bastien.curutchet@bootlin.com>
To: netdev-bot+sashiko@kernel.org
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
	andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	richardcochran@gmail.com, pascal.eberhard@se.com,
	miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v4 07/11] net: dsa: microchip: extract compute_width
Date: Tue, 29 Sep 2026 16:48:21 +0200	[thread overview]
Message-ID: <5e4d7332-e756-4014-98f8-22edd2a36802@bootlin.com> (raw)
In-Reply-To: <179068488049.434549.2405268057372474748@kernel.org>

Hi all,

On 9/29/26 2:28 PM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 1 · Medium: 1 · Low: 0
> 
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
> 
> - [High] The new check in ksz_ptp_compute_perout_cycle() does not fully
>    stop the divide-by-zero on restart that the commit message says it…
> - [Medium] The new `request->period.sec < 0` check in
>    ksz_ptp_compute_perout_cycle() fixes a crash that userspace can…
> 
> --
> 
> net: dsa: microchip: extract compute_width
> 
> This moves the period and pulse width calculation out of
> ksz_ptp_enable_perout() into a new helper, ksz_ptp_compute_perout_cycle().
> The helper will be reused later for KSZ8463 periodic output support. It
> also adds checks that reject negative or zero periods, so that a restart
> of the periodic output cannot divide by zero.
> 
>> diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
>> index 79520d345efcf..4b57cf076bb4f 100644
>> --- a/drivers/net/dsa/microchip/ksz_ptp.c
>> +++ b/drivers/net/dsa/microchip/ksz_ptp.c
>> @@ -203,12 +203,50 @@ static int ksz_ptp_get_pin(struct ksz_device *dev,
>>   	return pin;
>>   }
>>   
>> +static int ksz_ptp_compute_perout_cycle(struct ksz_device *dev,
>> +					struct ptp_perout_request const *request,
>> +					u64 max_pulse_width,
>> +					u64 *cycle_width_ns,
>> +					u64 *pulse_width_ns)
>> +{
>> +	struct timespec64 tmp;
>> +
>> +	if (request->period.sec < 0)
>> +		return -EINVAL;
> 
> [Severity: Medium]
> Is this check fixing a crash in the existing code? If so, should it go to
> net with a Fixes: tag?
> 

I added these checks to address Sashiko comments from last iteration. I 
don't think they worth a fix in net.

[...]

> 
> [Severity: High]
> Can a zero cycle width still get through here on 32-bit kernels?
> 
> ptp_perout_request.period.nsec is a __u32. Neither ptp_perout_request()
> nor the sysfs period_store() checks that it is below NSEC_PER_SEC. On
> 32-bit, struct timespec64.tv_nsec is a signed 32-bit long, so the
> assignment to tmp.tv_nsec can wrap to a negative value.
> 
> Take period.sec = 1 and period.nsec = 3294967296 (0xC4653600). Both new
> checks pass. tmp.tv_nsec becomes -1000000000, so timespec64_to_ns()
> returns 0, and the TRIG_CYCLE_WIDTH_M check accepts 0. The pair
> sec = 2, nsec = 2962947296 also gives 0.
> 

In these two cases the nsec field is greater than one second, it seems 
very unlikely to me to receive this kind of request.


Best regards,
Bastien

  reply	other threads:[~2026-09-29 14:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 11:38 [PATCH net-next v4 00/11] net: dsa: microchip: add periodic output support for the KSZ8463 Bastien Curutchet (Schneider Electric)
2026-09-25 11:38 ` [PATCH net-next v4 01/11] net: dsa: microchip: fully save the periodic output request Bastien Curutchet (Schneider Electric)
2026-09-29 12:27   ` netdev-bot+sashiko
2026-09-29 14:42     ` Bastien Curutchet
2026-09-25 11:38 ` [PATCH net-next v4 02/11] net: dsa: microchip: add the number of pins to chip infos Bastien Curutchet (Schneider Electric)
2026-09-29 12:27   ` netdev-bot+sashiko
2026-09-25 11:38 ` [PATCH net-next v4 03/11] net: dsa: microchip: add the number of periodic signals " Bastien Curutchet (Schneider Electric)
2026-09-29 12:27   ` netdev-bot+sashiko
2026-09-25 11:38 ` [PATCH net-next v4 04/11] net: dsa: microchip: use dynamic mask to check pulse width validity Bastien Curutchet (Schneider Electric)
2026-09-25 11:38 ` [PATCH net-next v4 05/11] net: dsa: microchip: extract PTP callbacks configuration from PTP registration Bastien Curutchet (Schneider Electric)
2026-09-25 11:38 ` [PATCH net-next v4 06/11] net: dsa: microchip: extract ptp_get_pin Bastien Curutchet (Schneider Electric)
2026-09-25 11:38 ` [PATCH net-next v4 07/11] net: dsa: microchip: extract compute_width Bastien Curutchet (Schneider Electric)
2026-09-29 12:28   ` netdev-bot+sashiko
2026-09-29 14:48     ` Bastien Curutchet [this message]
2026-09-25 11:38 ` [PATCH net-next v4 08/11] net: dsa: microchip: extract prepare reset Bastien Curutchet (Schneider Electric)
2026-09-29 12:28   ` netdev-bot+sashiko
2026-09-25 11:38 ` [PATCH net-next v4 09/11] net: dsa: microchip: extract time update Bastien Curutchet (Schneider Electric)
2026-09-25 11:38 ` [PATCH net-next v4 10/11] net: dsa: microchip: extract time adjustment Bastien Curutchet (Schneider Electric)
2026-09-25 11:38 ` [PATCH net-next v4 11/11] net: dsa: microchip: add periodic output support for the KSZ8463 Bastien Curutchet (Schneider Electric)
2026-09-29 12:28   ` netdev-bot+sashiko

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=5e4d7332-e756-4014-98f8-22edd2a36802@bootlin.com \
    --to=bastien.curutchet@bootlin.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pascal.eberhard@se.com \
    --cc=richardcochran@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=woojung.huh@microchip.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

all inboxes | Powered by JetHome®