Re: [PATCH net] ethtool: vclock: propagate errors from ptp_get_vclocks_index()

From
Matthieu Baerts <matttbe@kernel.org>
Date
2026-05-26 23:34:13
Reply to
Willem de Bruijn, 2026-05-26
Hi Willem,

Thank you for the Cc!

On 27/05/2026 04:46, Willem de Bruijn wrote:
Jakub Kicinski wrote:
quoted
ptp_get_vclocks_index() was written with sock_timestamping_bind_phc()
in mind. Any return <= 0 will get converted to EINVAL by the virtue
of sock_timestamping_bind_phc() not finding a matching vclock.

ethtool's phc_vclocks_prepare_data(), however, should not be silently
returning empty messages on allocation errors or when PHC does not
exist at all.

Commit c156174a6707 ("ethtool: add a new command for getting PHC virtual
clocks") added phc_vclocks_prepare_data(), but let's not treat this
as a fix in case some user space app now depends on the failures being
silent.
(...)
quoted
diff --git a/net/core/sock.c b/net/core/sock.c
index b37b664b6eb9..9e33e979a283 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -870,6 +870,8 @@ static int sock_timestamping_bind_phc(struct sock *sk, int phc_index)
 
 	num = ethtool_get_phc_vclocks(dev, &vclock_index);
 	dev_put(dev);
+	if (num < 0)
+		return num;
 
 	for (i = 0; i < num; i++) {
 		if (*(vclock_index + i) == phc_index) {
Not for this patch:

This is called by sk_setsockopt and by MPTCP for every subflow.
Apparently MPTCP does not check the return value. Should it?
Good point! I guess there was a confusion between sock_set_timestamp()
(SO_TIMESTAMPNS) and sock_set_timestamping() (SO_TIMESTAMPING).

I can send a patch to fix that.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Thread (4 messages) 4 messages, 3 authors, last reply 2026-05-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help