Merge pull request #3346 from murali-reddy/issue-3206

3206: Protect against CNI plugin being called with the host namespace
This commit is contained in:
Bryan Boreham authored and GitHub committed 2018-07-19 12:02:49 +01:00
commit b8ce722a2c
1 file changed
+10
+10
View File
@@ -117,6 +117,16 @@ func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error {
}
defer ns.Close()
hostNs, err := netns.Get()
if err != nil {
return fmt.Errorf("error accessing host network namespace: %s", err)
}
defer hostNs.Close()
if ns.Equal(hostNs) {
return fmt.Errorf("can not specify host network namespace as network namespace to which container should be added")
}
id := args.ContainerID
if len(id) < 5 {
data := make([]byte, 5)