Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102835979
D44702.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D44702.diff
View Options
diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -1173,18 +1173,6 @@
if ((shmflags & SHM_ALLOW_SEALING) != 0)
initial_seals &= ~F_SEAL_SEAL;
-#ifdef CAPABILITY_MODE
- /*
- * shm_open(2) is only allowed for anonymous objects.
- */
- if (userpath != SHM_ANON) {
- if (CAP_TRACING(td))
- ktrcapfail(CAPFAIL_NAMEI, userpath);
- if (IN_CAPABILITY_MODE(td))
- return (ECAPMODE);
- }
-#endif
-
AUDIT_ARG_FFLAGS(flags);
AUDIT_ARG_MODE(mode);
@@ -1209,6 +1197,26 @@
if ((initial_seals & ~F_SEAL_SEAL) != 0)
return (EINVAL);
+ if (userpath != SHM_ANON) {
+ error = shm_copyin_path(td, userpath, &path);
+ if (error != 0)
+ return (error);
+
+#ifdef CAPABILITY_MODE
+ /*
+ * shm_open(2) is only allowed for anonymous objects.
+ */
+ if (CAP_TRACING(td))
+ ktrcapfail(CAPFAIL_NAMEI, path);
+ if (IN_CAPABILITY_MODE(td)) {
+ free(path, M_SHMFD);
+ return (ECAPMODE);
+ }
+#endif
+
+ AUDIT_ARG_UPATH1_CANON(path);
+ }
+
pdp = td->td_proc->p_pd;
cmode = (mode & ~pdp->pd_cmask) & ACCESSPERMS;
@@ -1220,8 +1228,10 @@
* in sys_shm_open() to keep this implementation compliant.
*/
error = falloc_caps(td, &fp, &fd, flags & O_CLOEXEC, fcaps);
- if (error)
+ if (error) {
+ free(path, M_SHMFD);
return (error);
+ }
/* A SHM_ANON path pointer creates an anonymous object. */
if (userpath == SHM_ANON) {
@@ -1235,14 +1245,6 @@
shmfd->shm_seals = initial_seals;
shmfd->shm_flags = shmflags;
} else {
- error = shm_copyin_path(td, userpath, &path);
- if (error != 0) {
- fdclose(td, fp, fd);
- fdrop(fp, td);
- return (error);
- }
-
- AUDIT_ARG_UPATH1_CANON(path);
fnv = fnv_32_str(path, FNV1_32_INIT);
sx_xlock(&shm_dict_lock);
shmfd = shm_lookup(path, fnv);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 7:26 PM (21 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14703500
Default Alt Text
D44702.diff (1 KB)
Attached To
Mode
D44702: uipc_shm: Copyin userpath for ktrace(2)
Attached
Detach File
Event Timeline
Log In to Comment