Skip to content

Commit b3cff71

Browse files
author
root
committed
fix: restricted SO_PASS{CRED,PIDFD,SEC} to AF_{UNIX,NETLINK,BLUETOOTH}
Signed-off-by: root <[email protected]>
1 parent bd23be2 commit b3cff71

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

criu/sockets.c

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include <linux/filter.h>
1010
#include <string.h>
1111
#include <netinet/in.h>
12-
#include <linux/version.h>
13-
#include <sys/utsname.h>
1412

1513
#include "int.h"
1614
#include "bitops.h"
@@ -33,7 +31,6 @@
3331
#include "fdstore.h"
3432
#include "cr_options.h"
3533

36-
3734
#undef LOG_PREFIX
3835
#define LOG_PREFIX "sockets: "
3936

@@ -658,6 +655,7 @@ int dump_socket_opts(int sk, SkOptsEntry *soe)
658655
int ret = 0, val;
659656
struct timeval tv;
660657
struct linger so_linger = { 0, 0 };
658+
int family;
661659

662660
ret |= dump_opt(sk, SOL_SOCKET, SO_SNDBUF, &soe->so_sndbuf);
663661
ret |= dump_opt(sk, SOL_SOCKET, SO_RCVBUF, &soe->so_rcvbuf);
@@ -692,28 +690,23 @@ int dump_socket_opts(int sk, SkOptsEntry *soe)
692690
soe->so_reuseport = val ? true : false;
693691
soe->has_so_reuseport = true;
694692

695-
/*
696-
* Restrict SO_PASS{CRED,PIDFD,SEC} to AF_{UNIX,NETLINK,BLUETOOTH} while
697-
* kernel >= 6.16.
698-
*/
699-
700-
701-
ret |= dump_opt(sk, SOL_SOCKET, SO_PASSCRED, &val);
702-
soe->has_so_passcred = true;
703-
soe->so_passcred = val ? true : false;
704-
705-
ret |= dump_opt(sk, SOL_SOCKET, SO_PASSSEC, &val);
706-
soe->has_so_passsec = true;
707-
soe->so_passsec = val ? true : false;
708-
693+
if (dump_opt(sk, SOL_SOCKET, SO_DOMAIN, &family))
694+
return -1;
695+
switch (family) {
696+
case AF_UNIX:
709697

710-
ret |= dump_opt(sk, SOL_SOCKET, SO_PASSCRED, &val);
711-
soe->has_so_passcred = true;
712-
soe->so_passcred = val ? true : false;
698+
case AF_NETLINK:
699+
ret |= dump_opt(sk, SOL_SOCKET, SO_PASSCRED, &val);
700+
soe->has_so_passcred = true;
701+
soe->so_passcred = val ? true : false;
713702

714-
ret |= dump_opt(sk, SOL_SOCKET, SO_PASSSEC, &val);
715-
soe->has_so_passsec = true;
716-
soe->so_passsec = val ? true : false;
703+
ret |= dump_opt(sk, SOL_SOCKET, SO_PASSSEC, &val);
704+
soe->has_so_passsec = true;
705+
soe->so_passsec = val ? true : false;
706+
break;
707+
default:
708+
break;
709+
}
717710

718711
ret |= dump_opt(sk, SOL_SOCKET, SO_DONTROUTE, &val);
719712
soe->has_so_dontroute = true;

0 commit comments

Comments
 (0)