gve: Fix NULL dereferencing with PTP clock
Subsystems (3)
Joshua Washington
maintainercover gve: Fix NULL dereferencing with PTP clock
From: Tim Hostetler <[email protected]>
This patch series fixes NULL dereferences that are possible with gve's PTP clock due to not stubbing certain ptp_clock_info callbacks.
Tim Hostetler (2):
gve: Implement gettimex64 with -EOPNOTSUPP
gve: Implement settime64 with -EOPNOTSUPP
drivers/net/ethernet/google/gve/gve_ptp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Signature · 1 line
2.51.2.997.g839fc31de9-goog
Joshua Washington
maintainerPATCH 1/2 gve: Implement gettimex64 with -EOPNOTSUPP
From: Tim Hostetler <[email protected]>
gve implemented a ptp_clock for sole use of do_aux_work at this time. ptp_clock_gettime() and ptp_sys_offset() assume every ptp_clock has implemented either gettimex64 or gettime64. Stub gettimex64 and return -EOPNOTSUPP to prevent NULL dereferencing.
--- drivers/net/ethernet/google/gve/gve_ptp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/google/gve/gve_ptp.c +8 -0
@@ -26,6 +26,13 @@ int gve_clock_nic_ts_read(struct gve_priv *priv)return 0 ; } +static int gve_ptp_gettimex64 (struct ptp_clock_info *info, +struct timespec64 *ts, +struct ptp_system_timestamp *sts) +{ +return -EOPNOTSUPP ; +} +static long gve_ptp_do_aux_work (struct ptp_clock_info *info) { const struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
@@ -47,6 +54,7 @@ static long gve_ptp_do_aux_work(struct ptp_clock_info *info)static const struct ptp_clock_info gve_ptp_caps = { .owner =THIS_MODULE , .name ="gve clock" , + .gettimex64 = gve_ptp_gettimex64, .do_aux_work = gve_ptp_do_aux_work, };
Signature · 1 line
2.51.2.997.g839fc31de9-goog
Joshua Washington
maintainerPATCH 2/2 gve: Implement settime64 with -EOPNOTSUPP
In reply to Joshua WashingtonFrom: Tim Hostetler <[email protected]>
ptp_clock_settime() assumes every ptp_clock has implemented settime64(). Stub it with -EOPNOTSUPP to prevent a NULL dereference.
--- drivers/net/ethernet/google/gve/gve_ptp.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/google/gve/gve_ptp.c +7 -0
@@ -33,6 +33,12 @@ static int gve_ptp_gettimex64(struct ptp_clock_info *info,return -EOPNOTSUPP ; } +static int gve_ptp_settime64 (struct ptp_clock_info *info, +const struct timespec64 *ts) +{ +return -EOPNOTSUPP ; +} +static long gve_ptp_do_aux_work (struct ptp_clock_info *info) { const struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
@@ -55,6 +61,7 @@ static const struct ptp_clock_info gve_ptp_caps = { .owner = THIS_MODULE, .name = "gve clock", .gettimex64 = gve_ptp_gettimex64, + .settime64 = gve_ptp_settime64, .do_aux_work = gve_ptp_do_aux_work, };
Signature · 1 line
2.51.2.997.g839fc31de9-goog
Simon Horman
reviewerQuoted 11 lines · Joshua Washington
From: Tim Hostetler <[email protected]>
This patch series fixes NULL dereferences that are possible with gve's PTP clock due to not stubbing certain
ptp_clock_infocallbacks.Tim Hostetler (2):
gve: Implement gettimex64 with-EOPNOTSUPP
gve: Implement settime64 with-EOPNOTSUPPdrivers/net/ethernet/google/gve/gve_ptp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Hi Joshua and Tim,
I think that the approach of enhancing the caller to only call these callbacks if they are non NULL, as per the patch below, seems more robust. It would fix all drivers in one go.
- [PATCH] ptp: guard ptp_clock_gettime() if neither gettimex64 nor
https://lore.kernel.org/all/[email protected]/
Simon Horman
reviewerQuoted 13 lines · Simon Horman
Quoted 11 lines · Joshua Washington
From: Tim Hostetler <[email protected]>
This patch series fixes NULL dereferences that are possible with gve's PTP clock due to not stubbing certain
ptp_clock_infocallbacks.Tim Hostetler (2):
gve: Implement gettimex64 with-EOPNOTSUPP
gve: Implement settime64 with-EOPNOTSUPPdrivers/net/ethernet/google/gve/gve_ptp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Quoted 8 lines
Hi Joshua and Tim,
I think that the approach of enhancing the caller to only call these callbacks if they are non NULL, as per the patch below, seems more robust. It would fix all drivers in one go.
- [PATCH] ptp: guard
ptp_clock_gettime()if neither gettimex64 nor
https://lore.kernel.org/all/[email protected]/
Oops, I see that I should have read to the end of that thread where Tim joins the discussion.
It seems that this patchset is appropriate as it's expected that drivers expect an implementation of a variant of these callbacks.
Quoted 21 lines · Simon Horman
Quoted 19 lines · Simon Horman
Quoted 11 lines · Joshua Washington
From: Tim Hostetler <[email protected]>
This patch series fixes NULL dereferences that are possible with gve's PTP clock due to not stubbing certain
ptp_clock_infocallbacks.Tim Hostetler (2):
gve: Implement gettimex64 with-EOPNOTSUPP
gve: Implement settime64 with-EOPNOTSUPPdrivers/net/ethernet/google/gve/gve_ptp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Hi Joshua and Tim,
I think that the approach of enhancing the caller to only call these callbacks if they are non NULL, as per the patch below, seems more robust. It would fix all drivers in one go.
Quoted 8 lines
Quoted 2 lines
- [PATCH] ptp: guard
ptp_clock_gettime()if neither gettimex64 nor
https://lore.kernel.org/all/[email protected]/Oops, I see that I should have read to the end of that thread where Tim joins the discussion.
It seems that this patchset is appropriate as it's expected that drivers expect an implementation of a variant of these callbacks.
Right, one of the gettime64 variants and settime64 are required (whereas the other function callbacks aren't required from my inspection). I actually have a patch I'll be sending out pretty soon that will prevent the registration of a ptp_clock that doesn't implement the required callbacks to prevent a bug like this from happening again.
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 29 Oct 2025 11:45:38 -0700 you wrote:
From: Tim Hostetler <[email protected]>
This patch series fixes NULL dereferences that are possible with gve's PTP clock due to not stubbing certain
ptp_clock_infocallbacks.Tim Hostetler (2):
gve: Implement gettimex64 with-EOPNOTSUPP
gve: Implement settime64 with-EOPNOTSUPP[...]
Here is the summary with links:
- [net,1/2] gve: Implement gettimex64 with -EOPNOTSUPP
https://git.kernel.org/netdev/net/c/6ab753b5d8e5 - [net,2/2] gve: Implement settime64 with -EOPNOTSUPP https://git.kernel.org/netdev/net/c/329d050bbe63
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html