uipc_shm.c (2a016de1a5abdf87ae6e00f879a3600d157a8ca2) | uipc_shm.c (15bcf785ba268a1fb2b270233a7ae56d9e0ebc3a) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2006, 2011 Robert N. M. Watson | 2 * Copyright (c) 2006, 2011, 2016-2017 Robert N. M. Watson |
3 * All rights reserved. 4 * | 3 * All rights reserved. 4 * |
5 * Portions of this software were developed by BAE Systems, the University of 6 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL 7 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent 8 * Computing (TC) research program. 9 * |
|
5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. --- 61 unchanged lines hidden (view full) --- 74#include <sys/sysproto.h> 75#include <sys/systm.h> 76#include <sys/sx.h> 77#include <sys/time.h> 78#include <sys/vnode.h> 79#include <sys/unistd.h> 80#include <sys/user.h> 81 | 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. --- 61 unchanged lines hidden (view full) --- 79#include <sys/sysproto.h> 80#include <sys/systm.h> 81#include <sys/sx.h> 82#include <sys/time.h> 83#include <sys/vnode.h> 84#include <sys/unistd.h> 85#include <sys/user.h> 86 |
87#include <security/audit/audit.h> |
|
82#include <security/mac/mac_framework.h> 83 84#include <vm/vm.h> 85#include <vm/vm_param.h> 86#include <vm/pmap.h> 87#include <vm/vm_extern.h> 88#include <vm/vm_map.h> 89#include <vm/vm_kern.h> --- 614 unchanged lines hidden (view full) --- 704#ifdef CAPABILITY_MODE 705 /* 706 * shm_open(2) is only allowed for anonymous objects. 707 */ 708 if (IN_CAPABILITY_MODE(td) && (userpath != SHM_ANON)) 709 return (ECAPMODE); 710#endif 711 | 88#include <security/mac/mac_framework.h> 89 90#include <vm/vm.h> 91#include <vm/vm_param.h> 92#include <vm/pmap.h> 93#include <vm/vm_extern.h> 94#include <vm/vm_map.h> 95#include <vm/vm_kern.h> --- 614 unchanged lines hidden (view full) --- 710#ifdef CAPABILITY_MODE 711 /* 712 * shm_open(2) is only allowed for anonymous objects. 713 */ 714 if (IN_CAPABILITY_MODE(td) && (userpath != SHM_ANON)) 715 return (ECAPMODE); 716#endif 717 |
718 AUDIT_ARG_FFLAGS(flags); 719 AUDIT_ARG_MODE(mode); 720 |
|
712 if ((flags & O_ACCMODE) != O_RDONLY && (flags & O_ACCMODE) != O_RDWR) 713 return (EINVAL); 714 715 if ((flags & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC)) != 0) 716 return (EINVAL); 717 718 fdp = td->td_proc->p_fd; 719 cmode = (mode & ~fdp->fd_cmask) & ACCESSPERMS; --- 29 unchanged lines hidden (view full) --- 749 error = EINVAL; 750 if (error) { 751 fdclose(td, fp, fd); 752 fdrop(fp, td); 753 free(path, M_SHMFD); 754 return (error); 755 } 756 | 721 if ((flags & O_ACCMODE) != O_RDONLY && (flags & O_ACCMODE) != O_RDWR) 722 return (EINVAL); 723 724 if ((flags & ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC)) != 0) 725 return (EINVAL); 726 727 fdp = td->td_proc->p_fd; 728 cmode = (mode & ~fdp->fd_cmask) & ACCESSPERMS; --- 29 unchanged lines hidden (view full) --- 758 error = EINVAL; 759 if (error) { 760 fdclose(td, fp, fd); 761 fdrop(fp, td); 762 free(path, M_SHMFD); 763 return (error); 764 } 765 |
766 AUDIT_ARG_UPATH1_CANON(path); |
|
757 fnv = fnv_32_str(path, FNV1_32_INIT); 758 sx_xlock(&shm_dict_lock); 759 shmfd = shm_lookup(path, fnv); 760 if (shmfd == NULL) { 761 /* Object does not yet exist, create it if requested. */ 762 if (flags & O_CREAT) { 763#ifdef MAC 764 error = mac_posixshm_check_create(td->td_ucred, --- 88 unchanged lines hidden (view full) --- 853 if (error) { 854 free(path, M_TEMP); 855 return (error); 856 } 857#ifdef KTRACE 858 if (KTRPOINT(curthread, KTR_NAMEI)) 859 ktrnamei(path); 860#endif | 767 fnv = fnv_32_str(path, FNV1_32_INIT); 768 sx_xlock(&shm_dict_lock); 769 shmfd = shm_lookup(path, fnv); 770 if (shmfd == NULL) { 771 /* Object does not yet exist, create it if requested. */ 772 if (flags & O_CREAT) { 773#ifdef MAC 774 error = mac_posixshm_check_create(td->td_ucred, --- 88 unchanged lines hidden (view full) --- 863 if (error) { 864 free(path, M_TEMP); 865 return (error); 866 } 867#ifdef KTRACE 868 if (KTRPOINT(curthread, KTR_NAMEI)) 869 ktrnamei(path); 870#endif |
871 AUDIT_ARG_UPATH1_CANON(path); |
|
861 fnv = fnv_32_str(path, FNV1_32_INIT); 862 sx_xlock(&shm_dict_lock); 863 error = shm_remove(path, fnv, td->td_ucred); 864 sx_xunlock(&shm_dict_lock); 865 free(path, M_TEMP); 866 867 return (error); 868} --- 245 unchanged lines hidden --- | 872 fnv = fnv_32_str(path, FNV1_32_INIT); 873 sx_xlock(&shm_dict_lock); 874 error = shm_remove(path, fnv, td->td_ucred); 875 sx_xunlock(&shm_dict_lock); 876 free(path, M_TEMP); 877 878 return (error); 879} --- 245 unchanged lines hidden --- |