]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-varlink: refuse accepting more than 253 fds to send along with a Varlink message
authorLennart Poettering <lennart@poettering.net>
Fri, 25 Apr 2025 17:58:22 +0000 (19:58 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 17 May 2025 11:43:20 +0000 (12:43 +0100)
253 is the max number of fds one can send at once on a Linux AF_UNIX
socket. Hence refuse to send more early.

(cherry picked from commit 92c52a9ba6eea2d3bbb6289a512eeca083ec2578)
(cherry picked from commit d80f2b149cb282c9a0737a6cdf847be2ee81bfeb)

src/shared/varlink.c

index 89fc5aa976c15e1ee2909988a8b914e66bf7a200..4a8671f8e583e546b7eb5c93573fa19a8204044d 100644 (file)
@@ -3043,8 +3043,8 @@ int varlink_push_fd(Varlink *v, int fd) {
         if (!v->allow_fd_passing_output)
                 return -EPERM;
 
-        if (v->n_pushed_fds >= INT_MAX)
-                return -ENOMEM;
+        if (v->n_pushed_fds >= SCM_MAX_FD) /* Kernel doesn't support more than 253 fds per message, refuse early hence */
+                return -ENOBUFS;
 
         if (!GREEDY_REALLOC(v->pushed_fds, v->n_pushed_fds + 1))
                 return -ENOMEM;