<div dir="ltr">Working on an embedded system with customized Linux kernel based on 3.14 and lxc-2.0.0. The Kernel has been configured to support file capability. The lxc-checkconfig reports kernel configured for file capability correctly. <div><br><div><div><i># lxc-checkconfig</i></div><div><i>--- Namespaces ---</i></div><div><i>Namespaces: enabled</i></div><div><i>Utsname namespace: enabled</i></div><div><i>Ipc namespace: enabled</i></div><div><i>Pid namespace: enabled</i></div><div><i>User namespace: enabled</i></div><div><i>Network namespace: enabled</i></div><div><i>Multiple /dev/pts instances: enabled</i></div><div><i><br></i></div><div><i>--- Control groups ---</i></div><div><i>Cgroup: enabled</i></div><div><i>Cgroup clone_children flag: enabled</i></div><div><i>Cgroup device: enabled</i></div><div><i>Cgroup sched: enabled</i></div><div><i>Cgroup cpu account: enabled</i></div><div><i>Cgroup memory controller: enabled</i></div><div><i>Cgroup cpuset: enabled</i></div><div><i><br></i></div><div><i>--- Misc ---</i></div><div><i>Veth pair device: enabled</i></div><div><i>Macvlan: missing</i></div><div><i>Vlan: missing</i></div><div><i>Bridges: enabled</i></div><div><i>Advanced netfilter: enabled</i></div><div><i>CONFIG_NF_NAT_IPV4: enabled</i></div><div><i>CONFIG_NF_NAT_IPV6: enabled</i></div><div><i>CONFIG_IP_NF_TARGET_<wbr>MASQUERADE: enabled</i></div><div><i>CONFIG_IP6_NF_TARGET_<wbr>MASQUERADE: enabled</i></div><div><i>CONFIG_NETFILTER_XT_TARGET_<wbr>CHECKSUM: missing</i></div><div><i>FUSE (for use with lxcfs): enabled</i></div><div><i><br></i></div><div><i>--- Checkpoint/Restore ---</i></div><div><i>checkpoint restore: missing</i></div><div><i>CONFIG_FHANDLE: enabled</i></div><div><i>CONFIG_EVENTFD: enabled</i></div><div><i>CONFIG_EPOLL: enabled</i></div><div><i>CONFIG_UNIX_DIAG: missing</i></div><div><i>CONFIG_INET_DIAG: enabled</i></div><div><i>CONFIG_PACKET_DIAG: missing</i></div><div><i>CONFIG_NETLINK_DIAG: missing</i></div><div><i>File capabilities: enabled</i></div><div><i><br></i></div><div><i>Note : Before booting a new kernel, you can check its configuration</i></div><div><i>usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig</i></div></div><div><br></div><div>In fact, the file capability works inside host. <br></div><div><div>Here is execution in host;</div><div>dropRootPrivilege is a wrapper function which call prctl with SECURE_NOROOT to make root as no privilege user. </div><div><div><i># getcap /usr/bin/tmp.sh</i></div><div><i>/usr/bin/tmp.sh = cap_net_raw+ep</i></div></div><div><i>#  ./dropRootPrivilege  "tmp.sh" 2 &</i></div><div><i># cat /proc/21992/task/21992/status</i></div><div><div><i>CapInh: 0000000000000000</i></div><div><i>CapPrm: 0000000000002000</i></div><div><i>CapEff: 0000000000002000</i></div><div><i>CapBnd: 0000001fffffffff</i></div></div><div><br></div><div>However, the same function execute inside container, tmp.sh's file capability does not take effect. All effective and permitted privilege is zero.</div><div>Executed inside container:</div><div><div><i>~ # getcap /usr/bin/tmp.sh</i></div><div><i>/usr/bin/tmp.sh = cap_net_raw+ep</i></div></div><div><i>~ # dropRootPrivilege  "tmp.sh" 2 &<br></i></div><div><i>~ # cat /proc/380/task/380/status<br></i></div><div><div><i>CapInh: 0000000000000000</i></div><div><i>CapPrm: 0000000000000000</i></div><div><i>CapEff: 0000000000000000</i></div><div><i>CapBnd: 00000000882135c0</i></div></div><div><br></div><div>The process (which executes tmp.sh) did not get the cap_net_raw capability. Also, the lx configuration file has the following capabilities:</div><div><div>lxc.cap.keep = none</div><div>lxc.cap.keep = net_admin</div><div>lxc.cap.keep = net_raw</div><div>lxc.cap.keep = setgid</div><div>lxc.cap.keep = setuid</div><div>lxc.cap.keep = mknod</div><div>lxc.cap.keep = sys_admin</div><div>lxc.cap.keep = sys_module</div><div>#lxc.cap.keep = sys_nice</div><div>lxc.cap.keep = net_bind_service</div><div>lxc.cap.keep = setpcap</div><div>lxc.cap.keep = setfcap</div></div><div>Even I enabled all the capability, the running process still can not get the file capability.  </div><div><br></div><div>Here is the questions:</div><div>1) Does the lxc-2.0.0 supports file capability? If not, is there way make it works. </div><div>If yes, any suggestions on how I should debug this issue?</div><div>2) For Linux kernel 3.14, what kind of configuration shall be selected to support lxc container file capability?</div><div>Already have the following kernel setting:</div><div><div><i>CONFIG_SECURITY=y</i></div><div><i>CONFIG_SECURITY_CAPABILITIES=y</i></div><div><i>CONFIG_SECURITY_FILE_<wbr>CAPABILITIES=y</i></div><div><i>CONFIG_EXT4_FS_SECURITY=y</i></div></div><div><i>CONFIG_EXT4_FS_XATTR=y<br></i></div><div><div><i>CONFIG_EXT4_FS_SECURITY=y<br></i></div></div><div><i>CONFIG_CGROUP_FREEZER=y<br></i></div><div><div><i>CONFIG_CGROUP_DEVICE=y</i></div><div><i>CONFIG_CPUSETS=y</i></div><div><i>CONFIG_PROC_PID_CPUSET=y</i></div><div><i>CONFIG_CGROUP_CPUACCT=y</i></div><div><i>CONFIG_RESOURCE_COUNTERS=y</i></div><div><i>CONFIG_MEMCG=y</i></div><div><i>CONFIG_MEMCG_KMEM=y</i></div><div><i>CONFIG_MEM_OWNER=y</i></div><div><i>CONFIG_CGROUP_SCHED=y</i></div><div><i>CONFIG_RT_GROUP_SCHED=y</i></div><div><i>CONFIG_FAIR_GROUP_SCHED=y</i></div><div><i>CONFIG_NAMESPACES=y</i></div><div><i>CONFIG_USER_NS=y</i></div><div><i>CONFIG_PID_NS=y</i></div><div><i>CONFIG_UTS_NS=y</i></div><div><i>CONFIG_IPC_NS=y</i></div><div><i>CONFIG_NET_NS=y</i></div></div><div><br></div><div>Thanks!</div><div><br></div><div><br></div><div><br></div></div></div></div>