]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ena: PHC: Check return code before setting timestamp output
authorArthur Kiyanovski <akiyano@amazon.com>
Thu, 7 May 2026 00:35:15 +0000 (00:35 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 May 2026 00:22:48 +0000 (17:22 -0700)
ena_phc_gettimex64() is setting the output parameter regardless
of whether ena_com_phc_get_timestamp() succeeded or failed.

When ena_com_phc_get_timestamp() returns an error, the timestamp
parameter may contain uninitialized stack memory (e.g., when PHC is
disabled or in blocked state) or invalid hardware values. Passing
these to userspace via the PTP ioctl is both a security issue
(information leak) and a correctness bug.

Fix by checking the return code after releasing the lock and only
setting the output timestamp on success.

Fixes: e0ea34158ee8 ("net: ena: Add PHC support in the ENA driver")
Cc: stable@vger.kernel.org
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20260507003518.22554-1-akiyano@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amazon/ena/ena_phc.c

index 7867e893fd15f935ad3becf7cacd7c965313a893..c2a3ff1ef645c5586eb2f49ac9b91c7a0f294601 100644 (file)
@@ -46,9 +46,12 @@ static int ena_phc_gettimex64(struct ptp_clock_info *clock_info,
 
        spin_unlock_irqrestore(&phc_info->lock, flags);
 
+       if (rc)
+               return rc;
+
        *ts = ns_to_timespec64(timestamp_nsec);
 
-       return rc;
+       return 0;
 }
 
 static int ena_phc_settime64(struct ptp_clock_info *clock_info,