Lines 125-130
static void shm_init(void *arg);
Link Here
|
125 |
static void shm_insert(char *path, Fnv32_t fnv, struct shmfd *shmfd); |
125 |
static void shm_insert(char *path, Fnv32_t fnv, struct shmfd *shmfd); |
126 |
static struct shmfd *shm_lookup(char *path, Fnv32_t fnv); |
126 |
static struct shmfd *shm_lookup(char *path, Fnv32_t fnv); |
127 |
static int shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred); |
127 |
static int shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred); |
|
|
128 |
static void shm_doremove(struct shm_mapping *map); |
128 |
static int shm_dotruncate_cookie(struct shmfd *shmfd, off_t length, |
129 |
static int shm_dotruncate_cookie(struct shmfd *shmfd, off_t length, |
129 |
void *rl_cookie); |
130 |
void *rl_cookie); |
130 |
static int shm_dotruncate_locked(struct shmfd *shmfd, off_t length, |
131 |
static int shm_dotruncate_locked(struct shmfd *shmfd, off_t length, |
Lines 982-987
shm_init(void *arg)
Link Here
|
982 |
} |
983 |
} |
983 |
SYSINIT(shm_init, SI_SUB_SYSV_SHM, SI_ORDER_ANY, shm_init, NULL); |
984 |
SYSINIT(shm_init, SI_SUB_SYSV_SHM, SI_ORDER_ANY, shm_init, NULL); |
984 |
|
985 |
|
|
|
986 |
/* |
987 |
* Remove shared memory objects that belong to a dying prison. |
988 |
*/ |
989 |
void |
990 |
shm_prison_cleanup(struct prison *pr) |
991 |
{ |
992 |
struct shm_mapping *shmm, *tshmm; |
993 |
u_long i; |
994 |
|
995 |
sx_xlock(&shm_dict_lock); |
996 |
for (i = 0; i < shm_hash + 1; i++) { |
997 |
LIST_FOREACH_SAFE(shmm, &shm_dictionary[i], sm_link, tshmm) { |
998 |
if (shmm->sm_shmfd->shm_object->cred && |
999 |
shmm->sm_shmfd->shm_object->cred->cr_prison == pr) |
1000 |
shm_doremove(shmm); |
1001 |
} |
1002 |
} |
1003 |
sx_xunlock(&shm_dict_lock); |
1004 |
} |
1005 |
|
985 |
/* |
1006 |
/* |
986 |
* Dictionary management. We maintain an in-kernel dictionary to map |
1007 |
* Dictionary management. We maintain an in-kernel dictionary to map |
987 |
* paths to shmfd objects. We use the FNV hash on the path to store |
1008 |
* paths to shmfd objects. We use the FNV hash on the path to store |
Lines 1034-1044
shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred)
Link Here
|
1034 |
FREAD | FWRITE); |
1055 |
FREAD | FWRITE); |
1035 |
if (error) |
1056 |
if (error) |
1036 |
return (error); |
1057 |
return (error); |
1037 |
map->sm_shmfd->shm_path = NULL; |
1058 |
shm_doremove(map); |
1038 |
LIST_REMOVE(map, sm_link); |
|
|
1039 |
shm_drop(map->sm_shmfd); |
1040 |
free(map->sm_path, M_SHMFD); |
1041 |
free(map, M_SHMFD); |
1042 |
return (0); |
1059 |
return (0); |
1043 |
} |
1060 |
} |
1044 |
} |
1061 |
} |
Lines 1046-1051
shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred)
Link Here
|
1046 |
return (ENOENT); |
1063 |
return (ENOENT); |
1047 |
} |
1064 |
} |
1048 |
|
1065 |
|
|
|
1066 |
static void |
1067 |
shm_doremove(struct shm_mapping *map) |
1068 |
{ |
1069 |
map->sm_shmfd->shm_path = NULL; |
1070 |
LIST_REMOVE(map, sm_link); |
1071 |
shm_drop(map->sm_shmfd); |
1072 |
free(map->sm_path, M_SHMFD); |
1073 |
free(map, M_SHMFD); |
1074 |
} |
1075 |
|
1049 |
int |
1076 |
int |
1050 |
kern_shm_open2(struct thread *td, const char *userpath, int flags, mode_t mode, |
1077 |
kern_shm_open2(struct thread *td, const char *userpath, int flags, mode_t mode, |
1051 |
int shmflags, struct filecaps *fcaps, const char *name __unused) |
1078 |
int shmflags, struct filecaps *fcaps, const char *name __unused) |