{"id":7155,"date":"2022-12-20T19:35:39","date_gmt":"2022-12-20T22:35:39","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/avc_open-man3\/"},"modified":"2022-12-20T19:35:39","modified_gmt":"2022-12-20T22:35:39","slug":"avc_open-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/avc_open-man3\/","title":{"rendered":"avc_open (man3)"},"content":{"rendered":"<h1 align=\"center\">avc_open<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#KERNEL STATUS PAGE\">KERNEL STATUS PAGE<\/a><br \/> <a href=\"#NETLINK NOTIFICATION\">NETLINK NOTIFICATION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">avc_open, avc_destroy, avc_reset, avc_cleanup \u2212 userspace SELinux AVC setup and teardown<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <selinux\/selinux.h> <br \/> #include <selinux\/avc.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int avc_open(struct selinux_opt *<\/b><i>options<\/i><b>, unsigned<\/b> <i>nopt<\/i><b>);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void avc_destroy(void);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>int avc_reset(void);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void avc_cleanup(void);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>avc_open<\/b>() initializes the userspace AVC and must be called before any other AVC operation can be performed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>avc_destroy<\/b>() destroys the userspace AVC, freeing all internal memory structures. After this call has been made, <b>avc_open<\/b>() must be called again before any AVC operations can be performed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>avc_reset<\/b>() flushes the userspace AVC, causing it to forget any cached access decisions. The userspace AVC normally calls this function automatically when needed, see <b>NETLINK NOTIFICATION<\/b> below.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>avc_cleanup<\/b>() attempts to free unused memory within the userspace AVC, but does not flush any cached access decisions. Under normal operation, calling this function should not be necessary.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The userspace AVC obeys callbacks set via <b>selinux_set_callback<\/b>(3), in particular the logging and audit callbacks.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The options which may be passed to <b>avc_open<\/b>() include the following: <b><br \/> AVC_OPT_SETENFORCE<\/b><\/p>\n<p style=\"margin-left:22%;\">This option forces the userspace AVC into enforcing mode if the option value is non-NULL; permissive mode otherwise. The system enforcing mode will be ignored.<\/p>\n<h2>KERNEL STATUS PAGE <a name=\"KERNEL STATUS PAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Linux kernel version 2.6.37 supports the SELinux kernel status page, enabling userspace applications to <b>mmap<\/b>(2) SELinux status state in read-only mode to avoid system calls during the cache hit code path.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>avc_open<\/b>() calls <b>selinux_status_open<\/b>(3) to initialize the selinux status state.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>avc_has_perm<\/b>(3) and <b>selinux_check_access<\/b>(3) both check for status updates through calls to <b>selinux_status_updated<\/b>(3) at the start of each permission query and take the appropriate action.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Two status types are currently implemented. <b>setenforce<\/b> events will change the effective enforcing state used within the AVC, and <b>policyload<\/b> events will result in a cache flush.<\/p>\n<h2>NETLINK NOTIFICATION <a name=\"NETLINK NOTIFICATION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">In the event that the kernel status page is not successfully <b>mmap<\/b>(2)\u2019ed the AVC will default to the netlink fallback mechanism, which opens a netlink socket for receiving status updates. <b>setenforce<\/b> and <b>policyload<\/b> events will have the same results as for the status page implementation, but all status update checks will now require a system call.<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Functions with a return value return zero on success. On error, \u22121 is returned and <i>errno<\/i> is set appropriately.<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Eamon Walsh <ewalsh@tycho.nsa.gov><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>selinux<\/b>(8), <b>selinux_check_access<\/b>(3), <b>avc_has_perm<\/b>(3), <b>avc_context_to_sid<\/b>(3), <b>avc_cache_stats<\/b>(3), <b>avc_add_callback<\/b>(3), <b>selinux_status_open<\/b>(3), <b>selinux_status_updated<\/b>(3), <b>selinux_set_callback<\/b>(3), <b>security_compute_av<\/b>(3)<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  avc_open, avc_destroy, avc_reset, avc_cleanup \u2212 userspace SELinux AVC setup and teardown <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3490,3007],"class_list":["post-7155","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-avc_open","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7155"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7155\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}