Skip to content

Commit b590c92

Browse files
committed
net, pidfd: report EINVAL for ESRCH
dbus-broker relies -EINVAL being returned to indicate ESRCH in [1]. This causes issues for some workloads as reported in [2]. Paper over it until this is fixed in userspace. Link: https://lore.kernel.org/20250416-gegriffen-tiefbau-70cfecb80ac8@brauner Link: https://github.com/bus1/dbus-broker/blob/5d34d91b138fc802a016aa68c093eb81ea31139c/src/util/sockopt.c#L241 [1] Link: https://lore.kernel.org/20250415223454.GA1852104@ax162 [2] Tested-by: Nathan Chancellor <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 0a36bad commit b590c92

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/core/sock.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,8 +1893,16 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
18931893

18941894
pidfd = pidfd_prepare(peer_pid, 0, &pidfd_file);
18951895
put_pid(peer_pid);
1896-
if (pidfd < 0)
1896+
if (pidfd < 0) {
1897+
/*
1898+
* dbus-broker relies on -EINVAL being returned
1899+
* to indicate ESRCH. Paper over it until this
1900+
* is fixed in userspace.
1901+
*/
1902+
if (pidfd == -ESRCH)
1903+
pidfd = -EINVAL;
18971904
return pidfd;
1905+
}
18981906

18991907
if (copy_to_sockptr(optval, &pidfd, len) ||
19001908
copy_to_sockptr(optlen, &len, sizeof(int))) {

0 commit comments

Comments
 (0)