1f08c3bdfSopenharmony_ciPOSIX capabilities are pieces of root privilege, for instance 2f08c3bdfSopenharmony_ciCAP_SYS_NICE to set priority on other tasks and CAP_SYS_TIME 3f08c3bdfSopenharmony_cito set system time. See 4f08c3bdfSopenharmony_cihttp://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.4/capfaq-0.2.txt 5f08c3bdfSopenharmony_cifor more information. 6f08c3bdfSopenharmony_ci 7f08c3bdfSopenharmony_ciA task's capabilities are set when it executes a new file, and 8f08c3bdfSopenharmony_ciwhen it explicitly changes them (see capset(2)). After exec, 9f08c3bdfSopenharmony_cithe task's new capabilities are a function of its previous 10f08c3bdfSopenharmony_cicapabilities and the file's capabilities: 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ci pI' = pI 13f08c3bdfSopenharmony_ci pP' = fP | (fI & pI) 14f08c3bdfSopenharmony_ci pE' = fE ? pP' : 0 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ciWhere pX is capability set X for process p before exec, pX' is 17f08c3bdfSopenharmony_cicapability set X for process P after exec and fX is file 18f08c3bdfSopenharmony_cicapability set X. The capability sets are I for inheritable, 19f08c3bdfSopenharmony_ciP for permitted, and E for effective. Note that fE is a 20f08c3bdfSopenharmony_ciboolean rather than a set. 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ciFile capabilities are stored in extended attributes named 23f08c3bdfSopenharmony_ci'security.capability.' Setting this xattr requires the 24f08c3bdfSopenharmony_ciCAP_SETFCAP capability when the capability security module is 25f08c3bdfSopenharmony_ciloaded, or CAP_SYS_ADMIN when it is not. 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ciThe following tests are implemented here: 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ciinh_capped: check whether a process without CAP_SETPCAP 30f08c3bdfSopenharmony_ci is properly prohibited from raising bits in its 31f08c3bdfSopenharmony_ci inheritable set using setcap. 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_civerify_caps_exec: 34f08c3bdfSopenharmony_ci 1. check that privilege is needed to set file capabilities 35f08c3bdfSopenharmony_ci 2. check that pI', pP', and pE' are properly 36f08c3bdfSopenharmony_ci calculated upon exec. 37f08c3bdfSopenharmony_ciThe Underlying kernel needs to be built with the following options for filecaps testing: 38f08c3bdfSopenharmony_ciCONFIG_SECURITY_CAPABILITIES=y 39f08c3bdfSopenharmony_ci 40