Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ptp_clock_info in ena 2.13 is missing .adjfine #322

Open
3 tasks done
gemorin opened this issue Sep 25, 2024 · 1 comment
Open
3 tasks done

[Bug]: ptp_clock_info in ena 2.13 is missing .adjfine #322

gemorin opened this issue Sep 25, 2024 · 1 comment
Labels
bug Report errors or unexpected behavior Linux ENA driver triage Determine the priority and severity

Comments

@gemorin
Copy link

gemorin commented Sep 25, 2024

Preliminary Actions

Driver Type

Linux kernel driver for Elastic Network Adapter (ENA)

Driver Tag/Commit

ena 2.13.0

Custom Code

No

OS Platform and Distribution

Linux 6.2+ with ena.phc_enable=1

Bug description

Starting from Linux 6.2 (commit 75ab70ec5cef), .adjfine (introduced in 4.10) is required in struct ptp_clock_info and will trigger a NULL pointer dereference in (at least) ptp_clock_adjtime()

testing this change:

--- a/kernel/linux/ena/ena_phc.c
+++ b/kernel/linux/ena/ena_phc.c
@@ -15,6 +15,15 @@ static int ena_phc_adjfreq(struct ptp_cl
 }
 
 #endif /* ENA_PHC_SUPPORT_ADJFREQ */
+
+#ifdef ENA_PHC_SUPPORT_ADJFINE
+static int ena_phc_adjfine(struct ptp_clock_info *clock_info, long delta)
+{
+       return -EOPNOTSUPP;
+}
+
+#endif /* ENA_PHC_SUPPORT_ADJFINE */
+
 static int ena_phc_adjtime(struct ptp_clock_info *clock_info, s64 delta)
 {
        return -EOPNOTSUPP;
@@ -113,6 +122,9 @@ static struct ptp_clock_info ena_ptp_clo
 #ifdef ENA_PHC_SUPPORT_ADJFREQ
        .adjfreq        = ena_phc_adjfreq,
 #endif /* ENA_PHC_SUPPORT_ADJFREQ */
+#ifdef ENA_PHC_SUPPORT_ADJFINE
+       .adjfine        = ena_phc_adjfine,
+#endif /* ENA_PHC_SUPPORT_ADJFINE */
        .adjtime        = ena_phc_adjtime,
 #ifdef ENA_PHC_SUPPORT_GETTIME64
 #ifdef ENA_PHC_SUPPORT_GETTIME64_EXTENDED
--- a/kernel/linux/ena/kcompat.h
+++ b/kernel/linux/ena/kcompat.h
@@ -995,6 +995,10 @@ static inline bool ktime_after(const kti
 #define ptp_clock_register(info, parent) ptp_clock_register(info)
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
+#define ENA_PHC_SUPPORT_ADJFINE
+#endif /* ENA_PHC_SUPPORT_ADJFINE */
+
 #endif /* CONFIG_PTP_1588_CLOCK */
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)) && \

Reproduction steps

1. boot a Linux 6.2+ kernel

Expected Behavior

not crash

Actual Behavior

crash :-)

Additional Data

No response

Relevant log output

abbreviated kernel log:

BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 149927067 P4D 149927067 PUD 143ccf067 PMD 0 
Oops: 0010 [#1] SMP NOPTI
CPU: 0 PID: 9217 Comm: t Tainted: G           O        #1
Hardware name: Amazon EC2/Not Specified, BIOS 1.0 10/16/2017
RIP: 0010:0x0
Code: Unable to access opcode bytes at 0xffffffffffffffd6.
Call Trace:
 <TASK>
 ptp_clock_adjtime+0xd1/0x1d0
 pc_clock_adjtime+0x5b/0xa0
 __do_sys_clock_adjtime+0x8a/0x110
 __x64_sys_clock_adjtime+0x16/0x20
 x64_sys_call+0x1321/0x2020
 do_syscall_64+0x33/0x80
 entry_SYSCALL_64_after_hwframe+0x78/0xe2

Contact Details

[email protected]

@gemorin gemorin added bug Report errors or unexpected behavior triage Determine the priority and severity labels Sep 25, 2024
@davidarinzon
Copy link
Contributor

davidarinzon commented Sep 26, 2024

Thank you for raising this issue, @gemorin

We will resolve it in the next driver release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report errors or unexpected behavior Linux ENA driver triage Determine the priority and severity
Projects
None yet
Development

No branches or pull requests

2 participants