From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Richard Cochran <richardcochran@gmail.com>
Cc: <bryan.whitehead@microchip.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<anna-maria@linutronix.de>, <frederic@kernel.org>,
<UNGLinuxDriver@microchip.com>, <mbenes@suse.cz>,
<jstultz@google.com>, <andrew@lunn.ch>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next v3 1/2] posix-timers: Check timespec64 before call clock_set()
Date: Tue, 10 Sep 2024 20:30:22 +0800 [thread overview]
Message-ID: <1cae2765-65cc-7dc5-8321-76c8b7ef1b8c@huawei.com> (raw)
In-Reply-To: <875xr3btou.ffs@tglx>
On 2024/9/10 20:05, Thomas Gleixner wrote:
> On Tue, Sep 10 2024 at 19:23, Jinjie Ruan wrote:
>> On 2024/9/9 23:19, Richard Cochran wrote:
>>> On Mon, Sep 09, 2024 at 03:41:23PM +0800, Jinjie Ruan wrote:
>>>> diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
>>>> index 1cc830ef93a7..34deec619e17 100644
>>>> --- a/kernel/time/posix-timers.c
>>>> +++ b/kernel/time/posix-timers.c
>>>> @@ -1137,6 +1137,9 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
>>>> if (get_timespec64(&new_tp, tp))
>>>> return -EFAULT;
>>>>
>>>> + if (!timespec64_valid(&new_tp))
>>>> + return -ERANGE;
>>>
>>> Why not use timespec64_valid_settod()?
>>
>> It seems more limited and is only used in timekeeping or
>> do_sys_settimeofday64().
>
> For a very good reason.
>
>> And the timespec64_valid() is looser and wider used, which I think is
>> more appropriate here.
>
> Can you please stop this handwaving and provide proper technical
> arguments?
>
> Why would PTP have less strict requirements than settimeofday()?
I checked all the PTP driver, most of them use timespec64_to_ns()
convert them to ns which already have a check, but the others not check
them, and lan743x_ptp check them differently and more, so i think this
is a minimum check.
Use timespec64_to_ns()
- drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:
- drivers/net/ethernet/cavium/liquidio/lio_main.c:
- drivers/net/ethernet/engleder/tsnep_ptp.c
- drivers/net/ethernet/freescale/fec_ptp.c
- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c:
- drivers/net/ethernet/intel/i40e/i40e_ptp.c
- drivers/net/ethernet/intel/ice/ice_ptp.c
- drivers/net/ethernet/intel/igc/igc_ptp.c
- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.c
- drivers/net/ethernet/qlogic/qede/qede_ptp.c
- drivers/ptp/ptp_idt82p33.c
Not check:
- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
- drivers/net/ethernet/intel/igb/igb_ptp.c (only one igb_ptp_settime_i210())
- drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
- drivers/net/ethernet/renesas/rcar_gen4_ptp.c
-
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
- drivers/net/phy/micrel.c
- drivers/ptp/ptp_dfl_tod.c
Self check and check more:
- drivers/net/ethernet/microchip/lan743x_ptp.c
>
> Thanks,
>
> tglx
>
>
next prev parent reply other threads:[~2024-09-10 12:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 7:41 [PATCH -next v3 0/2] " Jinjie Ruan
2024-09-09 7:41 ` [PATCH -next v3 1/2] " Jinjie Ruan
2024-09-09 15:19 ` Richard Cochran
2024-09-10 11:23 ` Jinjie Ruan
2024-09-10 12:05 ` Thomas Gleixner
2024-09-10 12:30 ` Jinjie Ruan [this message]
2024-09-10 15:48 ` Thomas Gleixner
2024-09-12 2:53 ` Jinjie Ruan
2024-09-12 12:04 ` Thomas Gleixner
2024-09-12 12:24 ` Jinjie Ruan
2024-09-13 10:46 ` Thomas Gleixner
2024-09-14 9:00 ` Jinjie Ruan
2024-09-09 7:41 ` [PATCH -next v3 2/2] net: lan743x: Remove duplicate check Jinjie Ruan
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=1cae2765-65cc-7dc5-8321-76c8b7ef1b8c@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=anna-maria@linutronix.de \
--cc=bryan.whitehead@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=tglx@linutronix.de \
/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®