Commit 85569e8d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: prevent dumping nested mount namespace without mnt_id in fdinfo

When we don't know mnt_id, we don't know to which namespace a file
belongs.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8620912d
...@@ -249,7 +249,7 @@ static int check_one_sfd(union fdinfo_entries *e, void *arg) ...@@ -249,7 +249,7 @@ static int check_one_sfd(union fdinfo_entries *e, void *arg)
return 0; return 0;
} }
static int check_mnt_id(void) int check_mnt_id(void)
{ {
struct fdinfo_common fdinfo = { .mnt_id = -1 }; struct fdinfo_common fdinfo = { .mnt_id = -1 };
int ret; int ret;
......
...@@ -176,4 +176,6 @@ extern int parse_file_locks(void); ...@@ -176,4 +176,6 @@ extern int parse_file_locks(void);
struct pid; struct pid;
extern int parse_threads(int pid, struct pid **_t, int *_n); extern int parse_threads(int pid, struct pid **_t, int *_n);
extern int check_mnt_id(void);
#endif /* __CR_PROC_PARSE_H__ */ #endif /* __CR_PROC_PARSE_H__ */
...@@ -1902,7 +1902,7 @@ err: ...@@ -1902,7 +1902,7 @@ err:
int dump_mnt_namespaces(void) int dump_mnt_namespaces(void)
{ {
struct ns_id *ns; struct ns_id *ns;
int ret = 0; int ret = 0, n = 0;
for (ns = ns_ids; ns; ns = ns->next) { for (ns = ns_ids; ns; ns = ns->next) {
/* Skip current namespaces, which are in the list too */ /* Skip current namespaces, which are in the list too */
...@@ -1917,6 +1917,13 @@ int dump_mnt_namespaces(void) ...@@ -1917,6 +1917,13 @@ int dump_mnt_namespaces(void)
if (!(ns->nd->cflag & CLONE_NEWNS)) if (!(ns->nd->cflag & CLONE_NEWNS))
continue; continue;
n++;
if (n == 2 && check_mnt_id()) {
pr_err("Nested mount namespaces are not supported "
"without mnt_id in fdinfo\n");
return -1;
}
pr_info("Dump MNT namespace (mountpoints) %d via %d\n", pr_info("Dump MNT namespace (mountpoints) %d via %d\n",
ns->id, ns->pid); ns->id, ns->pid);
ret = dump_mnt_ns(ns); ret = dump_mnt_ns(ns);
......
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