Commit 14a7aff2 authored by Pavel Emelyanov's avatar Pavel Emelyanov

rst: Read sys.last_cap only once in kerndat

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d393e5d1
......@@ -59,7 +59,6 @@
#include "cpu.h"
#include "file-lock.h"
#include "page-read.h"
#include "sysctl.h"
#include "vdso.h"
#include "stats.h"
#include "tun.h"
......@@ -1934,17 +1933,6 @@ static int prepare_creds(int pid, struct task_restore_core_args *args)
int fd, ret;
CredsEntry *ce;
struct sysctl_req req[] = {
{ "kernel/cap_last_cap", &args->cap_last_cap, CTL_U32 },
{ },
};
ret = sysctl_op(req, CTL_READ);
if (ret < 0) {
pr_err("Failed to read max IPC message size\n");
return -1;
}
fd = open_image(CR_FD_CREDS, O_RSTR, pid);
if (fd < 0)
return fd;
......@@ -1988,6 +1976,8 @@ static int prepare_creds(int pid, struct task_restore_core_args *args)
creds_entry__free_unpacked(ce, NULL);
args->cap_last_cap = kern_last_cap;
/* XXX -- validate creds here? */
return 0;
......
......@@ -17,4 +17,6 @@ extern bool kerndat_has_dirty_track;
extern int tcp_max_wshare;
extern int tcp_max_rshare;
extern int kern_last_cap;
#endif
......@@ -156,13 +156,31 @@ int kerndat_init(void)
return ret;
}
int kern_last_cap;
int get_last_cap(void)
{
struct sysctl_req req[] = {
{ "kernel/cap_last_cap", &kern_last_cap, CTL_U32 },
{ },
};
return sysctl_op(req, CTL_READ);
}
int kerndat_init_rst(void)
{
int ret;
/*
* Read TCP sysctls before anything else,
* since the limits we're interested in are
* not available inside namespaces.
*/
return tcp_read_sysctl_limits();
ret = tcp_read_sysctl_limits();
if (!ret)
ret = get_last_cap();
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment