···128128 * @mode: the enforcement mode of the profile129129 * @flags: flags controlling profile behavior130130 * @path_flags: flags controlling path generation behavior131131+ * @disconnected: what to prepend if attach_disconnected is specified131132 * @size: the memory consumed by this profiles rules132133 * @policy: general match rules governing policy133134 * @file: The set of rules governing basic file access and domain transitions···170169 long mode;171170 long flags;172171 u32 path_flags;172172+ const char *disconnected;173173 int size;174174175175 struct aa_policydb policy;
+22-12
security/apparmor/path.c
···5050 * namespace root.5151 */5252static int disconnect(const struct path *path, char *buf, char **name,5353- int flags)5353+ int flags, const char *disconnected)5454{5555 int error = 0;5656···6363 error = -EACCES;6464 if (**name == '/')6565 *name = *name + 1;6666- } else if (**name != '/')6767- /* CONNECT_PATH with missing root */6868- error = prepend(name, *name - buf, "/", 1);6666+ } else {6767+ if (**name != '/')6868+ /* CONNECT_PATH with missing root */6969+ error = prepend(name, *name - buf, "/", 1);7070+ if (!error && disconnected)7171+ error = prepend(name, *name - buf, disconnected,7272+ strlen(disconnected));7373+ }69747075 return error;7176}···8277 * @buflen: length of @buf8378 * @name: Returns - pointer for start of path name with in @buf (NOT NULL)8479 * @flags: flags controlling path lookup8080+ * @disconnected: string to prefix to disconnected paths8581 *8682 * Handle path name lookup.8783 *···9185 * to a position in @buf9286 */9387static int d_namespace_path(const struct path *path, char *buf, int buflen,9494- char **name, int flags)8888+ char **name, int flags, const char *disconnected)9589{9690 char *res;9791 int error = 0;···112106 */113107 return prepend(name, *name - buf, "/proc", 5);114108 } else115115- return disconnect(path, buf, name, flags);116116- return 0;109109+ return disconnect(path, buf, name, flags,110110+ disconnected);117111 }118112119113 /* resolve paths relative to chroot?*/···159153 }160154161155 if (!connected)162162- error = disconnect(path, buf, name, flags);156156+ error = disconnect(path, buf, name, flags, disconnected);163157164158out:165159 return error;···176170 * Returns: %0 else error on failure177171 */178172static int get_name_to_buffer(const struct path *path, int flags, char *buffer,179179- int size, char **name, const char **info)173173+ int size, char **name, const char **info,174174+ const char *disconnected)180175{181176 int adjust = (flags & PATH_IS_DIR) ? 1 : 0;182182- int error = d_namespace_path(path, buffer, size - adjust, name, flags);177177+ int error = d_namespace_path(path, buffer, size - adjust, name, flags,178178+ disconnected);183179184180 if (!error && (flags & PATH_IS_DIR) && (*name)[1] != '\0')185181 /*···211203 * @buffer: buffer that aa_get_name() allocated (NOT NULL)212204 * @name: Returns - the generated path name if !error (NOT NULL)213205 * @info: Returns - information on why the path lookup failed (MAYBE NULL)206206+ * @disconnected: string to prepend to disconnected paths214207 *215208 * @name is a pointer to the beginning of the pathname (which usually differs216209 * from the beginning of the buffer), or NULL. If there is an error @name···225216 * Returns: %0 else error code if could retrieve name226217 */227218int aa_path_name(const struct path *path, int flags, char **buffer,228228- const char **name, const char **info)219219+ const char **name, const char **info, const char *disconnected)229220{230221 char *buf, *str = NULL;231222 int size = 256;···239230 if (!buf)240231 return -ENOMEM;241232242242- error = get_name_to_buffer(path, flags, buf, size, &str, info);233233+ error = get_name_to_buffer(path, flags, buf, size, &str, info,234234+ disconnected);243235 if (error != -ENAMETOOLONG)244236 break;245237
+3
security/apparmor/policy_unpack.c
···569569 profile->xmatch_len = tmp;570570 }571571572572+ /* disconnected attachment string is optional */573573+ (void) unpack_str(e, &profile->disconnected, "disconnected");574574+572575 /* per profile debug flags (complain, audit) */573576 if (!unpack_nameX(e, AA_STRUCT, "flags"))574577 goto fail;