Commit 3f6ad33f authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Pavel Emelyanov

sysctl: add CTL_FLAGS_HAS to mark successful sysctl_op request

v4: replace separate has pointer to CTL_FLAGS_HAS flag, second part in
patch "net/ipv4: add net_conf_op to reuse for ipv6"
v6: define CTL_FLAGS_HAS
v7: also allow EIO on do_sysctl_op for optional sysctls like
stable_secret and fix sysctl file to close in error path
v9: add CTL_FLAGS_READ_EIO_SKIP to skip dumping stable_secret on EIO
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Reviewed-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 99a7895e
...@@ -35,5 +35,7 @@ enum { ...@@ -35,5 +35,7 @@ enum {
* Some entries might be missing mark them as optional. * Some entries might be missing mark them as optional.
*/ */
#define CTL_FLAGS_OPTIONAL 1 #define CTL_FLAGS_OPTIONAL 1
#define CTL_FLAGS_HAS 2
#define CTL_FLAGS_READ_EIO_SKIP 4
#endif /* __CR_SYSCTL_H__ */ #endif /* __CR_SYSCTL_H__ */
...@@ -303,8 +303,13 @@ static int __userns_sysctl_op(void *arg, int proc_fd, pid_t pid) ...@@ -303,8 +303,13 @@ static int __userns_sysctl_op(void *arg, int proc_fd, pid_t pid)
close(nsfd); close(nsfd);
for (i = 0; i < userns_req->nr_req; i++) { for (i = 0; i < userns_req->nr_req; i++) {
if (do_sysctl_op(fds[i], reqs[i], op) < 0) if (do_sysctl_op(fds[i], reqs[i], op) < 0) {
exit(1); if (op != CTL_READ || errno != EIO || !(req->flags & CTL_FLAGS_READ_EIO_SKIP))
exit(1);
} else {
/* mark sysctl in question exists */
req->flags |= CTL_FLAGS_HAS;
}
} }
exit(0); exit(0);
...@@ -372,8 +377,16 @@ static int __nonuserns_sysctl_op(struct sysctl_req *req, size_t nr_req, int op) ...@@ -372,8 +377,16 @@ static int __nonuserns_sysctl_op(struct sysctl_req *req, size_t nr_req, int op)
} }
ret = do_sysctl_op(fd, req, op); ret = do_sysctl_op(fd, req, op);
if (ret) if (ret) {
goto out; if (op != CTL_READ || errno != EIO || !(req->flags & CTL_FLAGS_READ_EIO_SKIP)) {
close(fd);
goto out;
}
} else {
/* mark sysctl in question exists */
req->flags |= CTL_FLAGS_HAS;
}
close(fd); close(fd);
req++; req++;
} }
......
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