new PTP ioctl fixes
Subsystems (13)
v3 cover new PTP ioctl fixes
This series contains patches to fix the various drivers which implemented external pin input/output support. The drivers did not explicitly reject unknown/unsupported flags.
Changes since v2:
* Split the external timestamp changes to separate patches per-driver
* Change the check for external timestamp flags to always accept all three current flags.
* Add cc for authors of the PTP support, hopefully receiving feedback
Jacob Keller (7):
ptp: correctly disable flags on old ioctls
net: reject PTP periodic output requests with unsupported flags
mv88e6xxx: reject unsupported external timestamp flags
dp83640: reject unsupported external timestamp flags
igb: reject unsupported external timestamp flags
mlx5: reject unsupported external timestamp flags
renesas: reject unsupported external timestamp flags
drivers/net/dsa/mv88e6xxx/ptp.c | 6 +++++ drivers/net/ethernet/broadcom/tg3.c | 4 ++++ drivers/net/ethernet/intel/igb/igb_ptp.c | 10 +++++++++ .../ethernet/mellanox/mlx5/core/lib/clock.c | 10 +++++++++ drivers/net/ethernet/microchip/lan743x_ptp.c | 4 ++++ drivers/net/ethernet/renesas/ravb_ptp.c | 10 +++++++++ .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 4 ++++ drivers/net/phy/dp83640.c | 8 +++++++ drivers/ptp/ptp_chardev.c | 4 ++-- include/uapi/linux/ptp_clock.h | 22 +++++++++++++++++++ 10 files changed, 80 insertions(+), 2 deletions(-)
Signature · 1 line
2.23.0.245.gf157bbb9169d
PATCH v3 1/7 ptp: correctly disable flags on old ioctls
Commit 415606588c61 ("PTP: introduce new versions of IOCTLs", 2019-09-13) introduced new versions of the PTP ioctls which actually validate that the flags are acceptable values.
As part of this, it cleared the flags value using a bitwise and+negation, in an attempt to prevent the old ioctl from accidentally enabling new features.
This is incorrect for a couple of reasons. First, it results in accidentally preventing previously working flags on the request ioctl. By clearing the "valid" flags, we now no longer allow setting the enable, rising edge, or falling edge flags.
Second, if we add new additional flags in the future, they must not be set by the old ioctl. (Since the flag wasn't checked before, we could potentially break userspace programs which sent garbage flag data.
The correct way to resolve this is to check for and clear all but the originally valid flags.
Create defines indicating which flags are correctly checked and interpreted by the original ioctls. Use these to clear any bits which will not be correctly interpreted by the original ioctls.
In the future, new flags must be added to the VALID_FLAGS macros, but *not* to the V1_VALID_FLAGS macros. In this way, new features may be exposed over the v2 ioctls, but without breaking previous userspace which happened to not clear the flags value properly. The old ioctl will continue to behave the same way, while the new ioctl gains the benefit of using the flags fields.
--- drivers/ptp/ptp_chardev.c | 4 ++-- include/uapi/linux/ptp_clock.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
drivers/ptp/ptp_chardev.c +2 -2
@@ -155,7 +155,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) err = -EINVAL ;break ; }else if (cmd ==PTP_EXTTS_REQUEST ) { - req.extts.flags &= ~PTP_EXTTS_VALID_FLAGS ; + req.extts.flags &=PTP_EXTTS_V1_VALID_FLAGS ; req.extts.rsv[0 ] =0 ; req.extts.rsv[1 ] =0 ; }
@@ -184,7 +184,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) err = -EINVAL ;break ; }else if (cmd ==PTP_PEROUT_REQUEST ) { - req.perout.flags &= ~PTP_PEROUT_VALID_FLAGS ; + req.perout.flags &=PTP_PEROUT_V1_VALID_FLAGS ; req.perout.rsv[0 ] =0 ; req.perout.rsv[1 ] =0 ; req.perout.rsv[2 ] =0 ;
include/uapi/linux/ptp_clock.h +22 -0
@@ -31,15 +31,37 @@#define PTP_ENABLE_FEATURE (1<<0)#define PTP_RISING_EDGE (1<<1)#define PTP_FALLING_EDGE (1<<2) + +/* +* flag fields valid for the new PTP_EXTTS_REQUEST2 ioctl. +*/ #define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | \ PTP_RISING_EDGE | \ PTP_FALLING_EDGE) +/* +* flag fields valid for the original PTP_EXTTS_REQUEST ioctl. +* DO NOT ADD NEW FLAGS HERE. +*/ +#define PTP_EXTTS_V1_VALID_FLAGS (PTP_ENABLE_FEATURE | \ + PTP_RISING_EDGE | \ + PTP_FALLING_EDGE) +/* * Bits of the ptp_perout_request.flags field: */ #define PTP_PEROUT_ONE_SHOT (1<<0) + +/* +* flag fields valid for the new PTP_PEROUT_REQUEST2 ioctl. +*/ #define PTP_PEROUT_VALID_FLAGS (PTP_PEROUT_ONE_SHOT) + +/* +* No flags are valid for the original PTP_PEROUT_REQUEST ioctl +*/ +#define PTP_PEROUT_V1_VALID_FLAGS (0) +/* * struct ptp_clock_time - represents a time value *
Signature · 1 line
2.23.0.245.gf157bbb9169d
RE: [net-next v3 1/7] ptp: correctly disable flags on old ioctls
Quoted 47 lines
From: netdev-owner at vger.kernel.org [mailto:netdev-owner at vger.kernel.org] On Behalf Of Jacob Keller
Sent: Thursday, September 26, 2019 11:11 AM
To: netdev at vger.kernel.org
Cc: Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>; Keller, Jacob E <[email protected]>; Richard Cochran <[email protected]>; Felipe Balbi <[email protected]>; David S . Miller <[email protected]>; Hall, Christopher S <[email protected]>
Subject: [net-next v3 1/7] ptp: correctly disable flags on old ioctlsCommit
415606588c61("PTP: introduce new versions of IOCTLs", 2019-09-13) introduced new versions of the PTP ioctls which actually validate that the flags are acceptable values.As part of this, it cleared the flags value using a bitwise and+negation, in an attempt to prevent the old ioctl from accidentally enabling new features.
This is incorrect for a couple of reasons. First, it results in accidentally preventing previously working flags on the request ioctl. By clearing the "valid" flags, we now no longer allow setting the enable, rising edge, or falling edge flags.
Second, if we add new additional flags in the future, they must not be set by the old ioctl. (Since the flag wasn't checked before, we could potentially break userspace programs which sent garbage flag data.
The correct way to resolve this is to check for and clear all but the originally valid flags.
Create defines indicating which flags are correctly checked and interpreted by the original ioctls. Use these to clear any bits which will not be correctly interpreted by the original ioctls.
In the future, new flags must be added to the
VALID_FLAGSmacros, but *not* to theV1_VALID_FLAGSmacros. In this way, new features may be exposed over the v2 ioctls, but without breaking previous userspace which happened to not clear the flags value properly. The old ioctl will continue to behave the same way, while the new ioctl gains the benefit of using the flags fields.Cc Richard Cochran <[email protected]>Cc Felipe Balbi <[email protected]>Cc David S. Miller <[email protected]>Cc Christopher Hall <[email protected]>Signed-off-by Jacob Keller <[email protected]>
Quoted 4 lines
--- drivers/ptp/ptp_chardev.c | 4 ++-- include/uapi/linux/ptp_clock.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
PATCH v3 2/7 net: reject PTP periodic output requests with unsupported flags
In reply to Jacob KellerCommit 823eb2a3c4c7 ("PTP: add support for one-shot output") introduced a new flag for the PTP periodic output request ioctl. This flag is not currently supported by any driver.
Fix all drivers which implement the periodic output request ioctl to explicitly reject any request with flags they do not understand. This ensures that the driver does not accidentally misinterpret the PTP_PEROUT_ONE_SHOT flag, or any new flag introduced in the future.
This is important for forward compatibility: if a new flag is introduced, the driver should reject requests to enable the flag until the driver has actually been modified to support the flag in question.
--- drivers/net/ethernet/broadcom/tg3.c | 4 ++++ drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++++ drivers/net/ethernet/microchip/lan743x_ptp.c | 4 ++++ drivers/net/ethernet/renesas/ravb_ptp.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 4 ++++ drivers/net/phy/dp83640.c | 3 +++ 7 files changed, 27 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +4 -0
@@ -6280,6 +6280,10 @@ static int tg3_ptp_enable(struct ptp_clock_info *ptp,switch (rq->type) {case PTP_CLK_REQ_PEROUT : +/* Reject requests with unsupported flags */ +if (rq->perout.flags) +return -EOPNOTSUPP ; +if (rq->perout.index !=0 )return -EINVAL ;
drivers/net/ethernet/intel/igb/igb_ptp.c +4 -0
@@ -551,6 +551,10 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,return 0 ;case PTP_CLK_REQ_PEROUT : +/* Reject requests with unsupported flags */ +if (rq->perout.flags) +return -EOPNOTSUPP ; +if (on) { pin =ptp_find_pin (igb->ptp_clock,PTP_PF_PEROUT , rq->perout.index);
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +4 -0
@@ -290,6 +290,10 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,if (!MLX5_PPS_CAP (mdev))return -EOPNOTSUPP ; +/* Reject requests with unsupported flags */ +if (rq->perout.flags) +return -EOPNOTSUPP ; +if (rq->perout.index >= clock->ptp_info.n_pins)return -EINVAL ;
drivers/net/ethernet/microchip/lan743x_ptp.c +4 -0
@@ -429,6 +429,10 @@ static int lan743x_ptp_perout(struct lan743x_adapter *adapter, int on,int pulse_width =0 ;int perout_bit =0 ; +/* Reject requests with unsupported flags */ +if (perout->flags) +return -EOPNOTSUPP ; +if (!on) {lan743x_ptp_perout_off (adapter);return 0 ;
drivers/net/ethernet/renesas/ravb_ptp.c +4 -0
@@ -211,6 +211,10 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp,unsigned long flags;int error =0 ; +/* Reject requests with unsupported flags */ +if (req->flags) +return -EOPNOTSUPP ; +if (req->index)return -EINVAL ;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +4 -0
@@ -140,6 +140,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp,switch (rq->type) {case PTP_CLK_REQ_PEROUT : +/* Reject requests with unsupported flags */ +if (rq->perout.flags) +return -EOPNOTSUPP ; + cfg = &priv->pps[rq->perout.index]; cfg->start.tv_sec = rq->perout.start.sec;
drivers/net/phy/dp83640.c +3 -0
@@ -491,6 +491,9 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,return 0 ;case PTP_CLK_REQ_PEROUT : +/* Reject requests with unsupported flags */ +if (rq->perout.flags) +return -EOPNOTSUPP ;if (rq->perout.index >=N_PER_OUT )return -EINVAL ;return periodic_output (clock, rq, on, rq->perout.index);
Signature · 1 line
2.23.0.245.gf157bbb9169d
RE: [net-next v3 2/7] net: reject PTP periodic output requests with unsupported flags
Quoted 30 lines
From: netdev-owner at vger.kernel.org [mailto:netdev-owner at vger.kernel.org] On Behalf Of Jacob Keller
Sent: Thursday, September 26, 2019 11:11 AM
To: netdev at vger.kernel.org
Cc: Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>; Keller, Jacob E <[email protected]>; Richard Cochran <[email protected]>; Felipe Balbi <[email protected]>; David S . Miller <[email protected]>; Hall, Christopher S <[email protected]>
Subject: [net-next v3 2/7] net: reject PTP periodic output requests with unsupported flagsCommit
823eb2a3c4c7("PTP: add support for one-shot output") introduced a new flag for the PTP periodic output request ioctl. This flag is not currently supported by any driver.Fix all drivers which implement the periodic output request ioctl to explicitly reject any request with flags they do not understand. This ensures that the driver does not accidentally misinterpret the
PTP_PEROUT_ONE_SHOTflag, or any new flag introduced in the future.This is important for forward compatibility: if a new flag is introduced, the driver should reject requests to enable the flag until the driver has actually been modified to support the flag in question.
Cc Richard Cochran <[email protected]>Cc Felipe Balbi <[email protected]>Cc David S. Miller <[email protected]>Cc Christopher Hall <[email protected]>Signed-off-by Jacob Keller <[email protected]>
Quoted 10 lines
--- drivers/net/ethernet/broadcom/tg3.c | 4 ++++ drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++++ drivers/net/ethernet/microchip/lan743x_ptp.c | 4 ++++ drivers/net/ethernet/renesas/ravb_ptp.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 4 ++++ drivers/net/phy/dp83640.c | 3 +++ 7 files changed, 27 insertions(+)
For the igb sections...
Re: [net-next v3 2/7] net: reject PTP periodic output requests with unsupported flags
In reply to Jacob KellerQuoted 13 lines · Jacob Keller
Commit
823eb2a3c4c7("PTP: add support for one-shot output") introduced a new flag for the PTP periodic output request ioctl. This flag is not currently supported by any driver.Fix all drivers which implement the periodic output request ioctl to explicitly reject any request with flags they do not understand. This ensures that the driver does not accidentally misinterpret the
PTP_PEROUT_ONE_SHOTflag, or any new flag introduced in the future.This is important for forward compatibility: if a new flag is introduced, the driver should reject requests to enable the flag until the driver has actually been modified to support the flag in question.
Quoted 5 lines
Cc Richard Cochran <[email protected]>Cc Felipe Balbi <[email protected]>Cc David S. Miller <[email protected]>Cc Christopher Hall <[email protected]>Signed-off-by Jacob Keller <[email protected]>
PATCH v3 3/7 mv88e6xxx: reject unsupported external timestamp flags
In reply to Jacob KellerFix the mv88e6xxx PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently.
--- drivers/net/dsa/mv88e6xxx/ptp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/dsa/mv88e6xxx/ptp.c +6 -0
@@ -273,6 +273,12 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,int pin;int err; +/* Reject requests with unsupported flags */ +if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | +PTP_RISING_EDGE | +PTP_FALLING_EDGE )) +return -EOPNOTSUPP ; + pin =ptp_find_pin (chip->ptp_clock,PTP_PF_EXTTS , rq->extts.index);if (pin <0 )
Signature · 1 line
2.23.0.245.gf157bbb9169d
Re: [net-next v3 3/7] mv88e6xxx: reject unsupported external timestamp flags
Quoted 6 lines · Jacob Keller
Fix the mv88e6xxx PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics
For the record, the semantics are (or should be):
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE invalid PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp both edges
Quoted 2 lines
and each driver seems to
have interpreted them slightly differently.
This driver has:
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp rising edge
Quoted 2 lines
Cc Brandon Streiff <[email protected]>Signed-off-by Jacob Keller <[email protected]>
RE: [net-next v3 3/7] mv88e6xxx: reject unsupported external timestamp flags
Quoted 39 lines
-----Original Message-----
From: Richard Cochran <[email protected]>
Sent: Saturday, October 12, 2019 11:24 AM
To: Keller, Jacob E <[email protected]>
Cc: netdev at vger.kernel.org; Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>; Brandon Streiff <[email protected]>
Subject: Re: [net-next v3 3/7] mv88e6xxx: reject unsupported external timestamp flagsQuoted 6 lines · Jacob Keller
Fix the mv88e6xxx PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semanticsFor the record, the semantics are (or should be):
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE invalid PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stampboth edges
Quoted 2 lines
and each driver seems to
have interpreted them slightly differently.This driver has:
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp
Quoted 6 lines
rising edge
Quoted 2 lines
Cc Brandon Streiff <[email protected]>Signed-off-by Jacob Keller <[email protected]>Reviewed-by Richard Cochran <[email protected]>
Right, so in practice, unless it supports both edges, it should reject setting both RISING and FALLING together.
Thanks,
Jake
Richard Cochran
maintainerRe: [net-next v3 3/7] mv88e6xxx: reject unsupported external timestamp flags
Quoted 1 line · Jacob E
Right, so in practice, unless it supports both edges, it should reject setting both RISING and FALLING together.
Enforcing that now *could* break existing user space, but I wonder whether any programs would actually be affected.
Maybe we can add a STRICT flag than requests strict checking. If user space uses the "2" ioctl, then we would add this flag before invoking the driver callback.
Thanks,
Richard
RE: [net-next v3 3/7] mv88e6xxx: reject unsupported external timestamp flags
Quoted 17 lines
-----Original Message-----
From: Richard Cochran <[email protected]>
Sent: Saturday, October 12, 2019 4:27 PM
To: Keller, Jacob E <[email protected]>
Cc: netdev at vger.kernel.org; Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>; Brandon Streiff <[email protected]>
Subject: Re: [net-next v3 3/7] mv88e6xxx: reject unsupported external timestamp flagsQuoted 1 line · Jacob E
Right, so in practice, unless it supports both edges, it should reject setting both
RISING and FALLING together.
Enforcing that now *could* break existing user space, but I wonder whether any programs would actually be affected.
Quoted 6 lines
Maybe we can add a STRICT flag than requests strict checking. If user space uses the "2" ioctl, then we would add this flag before invoking the driver callback.
Thanks,
Richard
That could work. I don't know how much it's worth fixing it, but that would be the right way to fix it, I think.
I think the strict flag should do the following:
a) enforce that you must set at least one of the two edge flags (ensuring that a request to timestamp without one of the edges is rejected)
b) drivers *must* honor the edge flags or exit with a rejection if they can't support it. (unlike without 'strict', which would be like today and driver defined).
c) possibly: reject both flags at once since it doesn't really make sense to create a timestamp for each edge. At least, I think that makes it harder to actually use the timestamps since you need to be more careful to separate the two timestamps.
I'm not 100% sure on (c) but (b) can only be implemented in drivers, since the stack wouldn't know which modes the driver supports.
Thanks,
Jake
PATCH v3 4/7 dp83640: reject unsupported external timestamp flags
In reply to Jacob KellerFix the dp83640 PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently.
--- drivers/net/phy/dp83640.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/phy/dp83640.c +5 -0
@@ -469,6 +469,11 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,switch (rq->type) {case PTP_CLK_REQ_EXTTS : +/* Reject requests with unsupported flags */ +if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | +PTP_RISING_EDGE | +PTP_FALLING_EDGE )) +return -EOPNOTSUPP ; index = rq->extts.index;if (index >=N_EXT_TS )return -EINVAL ;
Signature · 1 line
2.23.0.245.gf157bbb9169d
Re: [net-next v3 4/7] dp83640: reject unsupported external timestamp flags
Quoted 7 lines · Jacob Keller
Fix the dp83640 PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics and each driver seems to have interpreted them slightly differently.
This driver has:
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp falling edge
Quoted 3 lines
Cc Stefan S?rensen <[email protected]>Cc Richard Cochran <[email protected]>Signed-off-by Jacob Keller <[email protected]>
PATCH v3 5/7 igb: reject unsupported external timestamp flags
In reply to Jacob KellerFix the igb PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently.
--- drivers/net/ethernet/intel/igb/igb_ptp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/igb/igb_ptp.c +6 -0
@@ -521,6 +521,12 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,switch (rq->type) {case PTP_CLK_REQ_EXTTS : +/* Reject requests with unsupported flags */ +if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | +PTP_RISING_EDGE | +PTP_FALLING_EDGE )) +return -EOPNOTSUPP ; +if (on) { pin =ptp_find_pin (igb->ptp_clock,PTP_PF_EXTTS , rq->extts.index);
Signature · 1 line
2.23.0.245.gf157bbb9169d
RE: [Intel-wired-lan] [net-next v3 5/7] igb: reject unsupported external timestamp flags
Quoted 16 lines
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Jacob Keller
Sent: Thursday, September 26, 2019 11:11 AM
To: netdev at vger.kernel.org
Cc: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next v3 5/7] igb: reject unsupported external timestamp flagsFix the igb PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics and each driver seems to have interpreted them slightly differently.
Quoted 4 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/igb/igb_ptp.c | 6 ++++++ 1 file changed, 6 insertions(+)
Re: [net-next v3 5/7] igb: reject unsupported external timestamp flags
In reply to Jacob KellerQuoted 7 lines · Jacob Keller
Fix the igb PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics and each driver seems to have interpreted them slightly differently.
This HW always time stamps both edges:
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp both edges PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp both edges PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp both edges PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp both edges
Quoted 1 line
Signed-off-by Jacob Keller <[email protected]>
PATCH v3 6/7 mlx5: reject unsupported external timestamp flags
In reply to Jacob KellerFix the mlx5 core PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently.
--- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +6 -0
@@ -236,6 +236,12 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp,if (!MLX5_PPS_CAP (mdev))return -EOPNOTSUPP ; +/* Reject requests with unsupported flags */ +if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | +PTP_RISING_EDGE | +PTP_FALLING_EDGE )) +return -EOPNOTSUPP ; +if (rq->extts.index >= clock->ptp_info.n_pins)return -EINVAL ;
Signature · 1 line
2.23.0.245.gf157bbb9169d
Re: [net-next v3 6/7] mlx5: reject unsupported external timestamp flags
Quoted 7 lines · Jacob Keller
Fix the mlx5 core PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics and each driver seems to have interpreted them slightly differently.
I'm not 100% sure what this driver does, but if I'm not wrong it follows the dp83640:
flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp falling edge
Quoted 3 lines
Cc Feras Daoud <[email protected]>Cc Eugenia Emantayev <[email protected]>Signed-off-by Jacob Keller <[email protected]>
PATCH v3 7/7 renesas: reject unsupported external timestamp flags
In reply to Jacob KellerFix the renesas PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently.
--- drivers/net/ethernet/renesas/ravb_ptp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/renesas/ravb_ptp.c +6 -0
@@ -182,6 +182,12 @@ static int ravb_ptp_extts(struct ptp_clock_info *ptp,struct net_device *ndev = priv->ndev;unsigned long flags; +/* Reject requests with unsupported flags */ +if (req->flags & ~(PTP_ENABLE_FEATURE | +PTP_RISING_EDGE | +PTP_FALLING_EDGE )) +return -EOPNOTSUPP ; +if (req->index)return -EINVAL ;
Signature · 1 line
2.23.0.245.gf157bbb9169d
Re: [net-next v3 7/7] renesas: reject unsupported external timestamp flags
Quoted 10 lines · Jacob Keller
Fix the renesas PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics and each driver seems to have interpreted them slightly differently.Cc Sergei Shtylyov <[email protected]>Signed-off-by Jacob Keller <[email protected]>
[...]
MBR, Sergei
Re: [net-next v3 7/7] renesas: reject unsupported external timestamp flags
In reply to Jacob KellerQuoted 7 lines · Jacob Keller
Fix the renesas PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl.
In order to maintain currently functioning code, this patch accepts all three current flags. This is because the
PTP_RISING_EDGEandPTP_FALLING_EDGEflags have unclear semantics and each driver seems to have interpreted them slightly differently.
This driver doesn't check the flags. Not knowing this HW, I can't say which edges are time stamped.
Quoted 2 lines
Cc Sergei Shtylyov <[email protected]>Signed-off-by Jacob Keller <[email protected]>
David Miller
maintainerBug fixes should target 'net' not 'net-next'
Quoted 10 lines
-----Original Message-----
From: David Miller [mailto:davem at davemloft.net]
Sent: Friday, September 27, 2019 11:30 AM
To: Keller, Jacob E <[email protected]>
Cc: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org; Kirsher, Jeffrey T <[email protected]>
Subject: Re: [net-next v3 0/7] new PTP ioctl fixesBug fixes should target 'net' not 'net-next'
Right, that was my mistake. I think I saw the ioctl change only on the net-next tree so I built the whole series on net-next. Come to think of it, I didn't check the net tree at all. I'll aim to do that better going forward.
Thanks Dave.
Regards,
Jake
Richard Cochran
maintainerJacob,
Quoted 2 lines · Jacob Keller
Jacob Keller (7):
ptp: correctly disable flags on old ioctls
This patch made it into net, but ...
Quoted 6 lines
net: reject PTP periodic output requests with unsupported flags
mv88e6xxx: reject unsupported external timestamp flags
dp83640: reject unsupported external timestamp flags
igb: reject unsupported external timestamp flags
mlx5: reject unsupported external timestamp flags
renesas: reject unsupported external timestamp flags
.. these did not.
There is still time before v5.4 gets released. Would you care to re-submit the missing six patches?
Thanks,
Richard
Richard Cochran
maintainerQuoted 2 lines · Richard Cochran
There is still time before v5.4 gets released. Would you care to re-submit the missing six patches?
Or, if you don't mind, I can submit these for you, along with the STRICT flag checking for v2 ioctls that we discussed.
Thanks,
Richard
Richard Cochran
maintainerQuoted 6 lines · Richard Cochran
Quoted 2 lines · Richard Cochran
There is still time before v5.4 gets released. Would you care to re-submit the missing six patches?
Or, if you don't mind, I can submit these for you, along with the STRICT flag checking for v2 ioctls that we discussed.
Okay, so I took the liberty of taking your series, picking up the tags, and adding the new strict checking. I'll post it later today or early tomorrow after testing.
Thanks,
Richard
Quoted 16 lines
-----Original Message-----
From: Richard Cochran <[email protected]>
Sent: Wednesday, November 13, 2019 11:35 AM
To: Keller, Jacob E <[email protected]>
Cc: netdev at vger.kernel.org; Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>
Subject: Re: [net-next v3 0/7] new PTP ioctl fixesQuoted 6 lines · Richard Cochran
Quoted 2 lines · Richard Cochran
There is still time before v5.4 gets released. Would you care to re-submit the missing six patches?
Or, if you don't mind, I can submit these for you, along with the STRICT flag checking for v2 ioctls that we discussed.
Quoted 6 lines
Okay, so I took the liberty of taking your series, picking up the tags, and adding the new strict checking. I'll post it later today or early tomorrow after testing.
Thanks,
Richard
Yes, that is fine with me. Thanks Richard!
I will take a look at them once they hit the lists.
Regards,
Jake