[02/13] namespaces: Make sure we're not getting stripped inode value

Submitted by Cyrill Gorcunov on Oct. 19, 2017, 9:59 p.m.

Details

Message ID 1508450384-29215-3-git-send-email-gorcunov@openvz.org
State New
Series "Clean up image format and fix anon shmem bits strip"
Headers show

Commit Message

Cyrill Gorcunov Oct. 19, 2017, 9:59 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 criu/include/namespaces.h | 6 ++++++
 criu/namespaces.c         | 1 +
 2 files changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index ef6083c9a944..dab7c84e1a23 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -98,6 +98,12 @@  struct net_link {
 	struct list_head	node;
 };
 
+/*
+ * While kernel uses long numbers for ns
+ * enumeration, we don't plan to support
+ * that many namespaces, thus int numbers
+ * are used.
+ */
 struct ns_id {
 	unsigned int kid;
 	unsigned int id;
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 5c46976410e4..d31983a32ed0 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -484,6 +484,7 @@  static unsigned int __get_ns_id(int pid, struct ns_desc *nd, bool alternative,
 		return 0;
 	}
 	kid = st.st_ino;
+	BUG_ON((unsigned long)st.st_ino > (unsigned long)(UINT_MAX));
 	BUG_ON(!kid);
 
 out: