Deleted Added
full compact
mac_net.c (121507) mac_net.c (122159)
1/*-
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * Copyright (c) 2001 Ilmar S. Habibulin
4 * Copyright (c) 2001, 2002, 2003 Networks Associates Technology, Inc.
5 * All rights reserved.
6 *
7 * This software was developed by Robert Watson and Ilmar Habibulin for the
8 * TrustedBSD Project.

--- 21 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * Copyright (c) 2001 Ilmar S. Habibulin
4 * Copyright (c) 2001, 2002, 2003 Networks Associates Technology, Inc.
5 * All rights reserved.
6 *
7 * This software was developed by Robert Watson and Ilmar Habibulin for the
8 * TrustedBSD Project.

--- 21 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/security/mac/mac_net.c 121507 2003-10-25 15:28:20Z rwatson $");
38__FBSDID("$FreeBSD: head/sys/security/mac/mac_net.c 122159 2003-11-06 03:42:43Z rwatson $");
39
40#include "opt_mac.h"
41
42#include <sys/param.h>
43#include <sys/kernel.h>
44#include <sys/lock.h>
45#include <sys/malloc.h>
46#include <sys/mutex.h>

--- 281 unchanged lines hidden (view full) ---

328 * mac_init_mbuf_tag() is called on the target tag in
329 * m_tag_copy(), so we don't need to call it here.
330 */
331 MAC_PERFORM(copy_mbuf_label, src_label, dest_label);
332}
333
334static int
335mac_externalize_ifnet_label(struct label *label, char *elements,
39
40#include "opt_mac.h"
41
42#include <sys/param.h>
43#include <sys/kernel.h>
44#include <sys/lock.h>
45#include <sys/malloc.h>
46#include <sys/mutex.h>

--- 281 unchanged lines hidden (view full) ---

328 * mac_init_mbuf_tag() is called on the target tag in
329 * m_tag_copy(), so we don't need to call it here.
330 */
331 MAC_PERFORM(copy_mbuf_label, src_label, dest_label);
332}
333
334static int
335mac_externalize_ifnet_label(struct label *label, char *elements,
336 char *outbuf, size_t outbuflen, int flags)
336 char *outbuf, size_t outbuflen)
337{
338 int error;
339
340 MAC_EXTERNALIZE(ifnet, label, elements, outbuf, outbuflen);
341
342 return (error);
343}
344
345static int
346mac_externalize_socket_label(struct label *label, char *elements,
337{
338 int error;
339
340 MAC_EXTERNALIZE(ifnet, label, elements, outbuf, outbuflen);
341
342 return (error);
343}
344
345static int
346mac_externalize_socket_label(struct label *label, char *elements,
347 char *outbuf, size_t outbuflen, int flags)
347 char *outbuf, size_t outbuflen)
348{
349 int error;
350
351 MAC_EXTERNALIZE(socket, label, elements, outbuf, outbuflen);
352
353 return (error);
354}
355
356static int
357mac_externalize_socket_peer_label(struct label *label, char *elements,
348{
349 int error;
350
351 MAC_EXTERNALIZE(socket, label, elements, outbuf, outbuflen);
352
353 return (error);
354}
355
356static int
357mac_externalize_socket_peer_label(struct label *label, char *elements,
358 char *outbuf, size_t outbuflen, int flags)
358 char *outbuf, size_t outbuflen)
359{
360 int error;
361
362 MAC_EXTERNALIZE(socket_peer, label, elements, outbuf, outbuflen);
363
364 return (error);
365}
366

--- 396 unchanged lines hidden (view full) ---

763 error = copyinstr(mac.m_string, elements, mac.m_buflen, NULL);
764 if (error) {
765 free(elements, M_MACTEMP);
766 return (error);
767 }
768
769 buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
770 error = mac_externalize_ifnet_label(&ifnet->if_label, elements,
359{
360 int error;
361
362 MAC_EXTERNALIZE(socket_peer, label, elements, outbuf, outbuflen);
363
364 return (error);
365}
366

--- 396 unchanged lines hidden (view full) ---

763 error = copyinstr(mac.m_string, elements, mac.m_buflen, NULL);
764 if (error) {
765 free(elements, M_MACTEMP);
766 return (error);
767 }
768
769 buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
770 error = mac_externalize_ifnet_label(&ifnet->if_label, elements,
771 buffer, mac.m_buflen, M_WAITOK);
771 buffer, mac.m_buflen);
772 if (error == 0)
773 error = copyout(buffer, mac.m_string, strlen(buffer)+1);
774
775 free(buffer, M_MACTEMP);
776 free(elements, M_MACTEMP);
777
778 return (error);
779}

--- 108 unchanged lines hidden (view full) ---

888 error = copyinstr(mac->m_string, elements, mac->m_buflen, NULL);
889 if (error) {
890 free(elements, M_MACTEMP);
891 return (error);
892 }
893
894 buffer = malloc(mac->m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
895 error = mac_externalize_socket_label(&so->so_label, elements,
772 if (error == 0)
773 error = copyout(buffer, mac.m_string, strlen(buffer)+1);
774
775 free(buffer, M_MACTEMP);
776 free(elements, M_MACTEMP);
777
778 return (error);
779}

--- 108 unchanged lines hidden (view full) ---

888 error = copyinstr(mac->m_string, elements, mac->m_buflen, NULL);
889 if (error) {
890 free(elements, M_MACTEMP);
891 return (error);
892 }
893
894 buffer = malloc(mac->m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
895 error = mac_externalize_socket_label(&so->so_label, elements,
896 buffer, mac->m_buflen, M_WAITOK);
896 buffer, mac->m_buflen);
897 if (error == 0)
898 error = copyout(buffer, mac->m_string, strlen(buffer)+1);
899
900 free(buffer, M_MACTEMP);
901 free(elements, M_MACTEMP);
902
903 return (error);
904}

--- 13 unchanged lines hidden (view full) ---

918 error = copyinstr(mac->m_string, elements, mac->m_buflen, NULL);
919 if (error) {
920 free(elements, M_MACTEMP);
921 return (error);
922 }
923
924 buffer = malloc(mac->m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
925 error = mac_externalize_socket_peer_label(&so->so_peerlabel,
897 if (error == 0)
898 error = copyout(buffer, mac->m_string, strlen(buffer)+1);
899
900 free(buffer, M_MACTEMP);
901 free(elements, M_MACTEMP);
902
903 return (error);
904}

--- 13 unchanged lines hidden (view full) ---

918 error = copyinstr(mac->m_string, elements, mac->m_buflen, NULL);
919 if (error) {
920 free(elements, M_MACTEMP);
921 return (error);
922 }
923
924 buffer = malloc(mac->m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
925 error = mac_externalize_socket_peer_label(&so->so_peerlabel,
926 elements, buffer, mac->m_buflen, M_WAITOK);
926 elements, buffer, mac->m_buflen);
927 if (error == 0)
928 error = copyout(buffer, mac->m_string, strlen(buffer)+1);
929
930 free(buffer, M_MACTEMP);
931 free(elements, M_MACTEMP);
932
933 return (error);
934}
927 if (error == 0)
928 error = copyout(buffer, mac->m_string, strlen(buffer)+1);
929
930 free(buffer, M_MACTEMP);
931 free(elements, M_MACTEMP);
932
933 return (error);
934}