@@ -966,6 +966,9 @@ static bool tomoyo_manager(void)
966966 return found ;
967967}
968968
969+ static struct tomoyo_domain_info * tomoyo_find_domain_by_qid
970+ (unsigned int serial );
971+
969972/**
970973 * tomoyo_select_domain - Parse select command.
971974 *
@@ -999,6 +1002,8 @@ static bool tomoyo_select_domain(struct tomoyo_io_buffer *head,
9991002 } else if (!strncmp (data , "domain=" , 7 )) {
10001003 if (tomoyo_domain_def (data + 7 ))
10011004 domain = tomoyo_find_domain (data + 7 );
1005+ } else if (sscanf (data , "Q=%u" , & pid ) == 1 ) {
1006+ domain = tomoyo_find_domain_by_qid (pid );
10021007 } else
10031008 return false;
10041009 head -> w .domain = domain ;
@@ -1894,6 +1899,7 @@ static DECLARE_WAIT_QUEUE_HEAD(tomoyo_answer_wait);
18941899/* Structure for query. */
18951900struct tomoyo_query {
18961901 struct list_head list ;
1902+ struct tomoyo_domain_info * domain ;
18971903 char * query ;
18981904 size_t query_len ;
18991905 unsigned int serial ;
@@ -2044,6 +2050,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
20442050 goto out ;
20452051 }
20462052 len = tomoyo_round2 (entry .query_len );
2053+ entry .domain = r -> domain ;
20472054 spin_lock (& tomoyo_query_list_lock );
20482055 if (tomoyo_memory_quota [TOMOYO_MEMORY_QUERY ] &&
20492056 tomoyo_memory_used [TOMOYO_MEMORY_QUERY ] + len
@@ -2090,6 +2097,29 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
20902097 return error ;
20912098}
20922099
2100+ /**
2101+ * tomoyo_find_domain_by_qid - Get domain by query id.
2102+ *
2103+ * @serial: Query ID assigned by tomoyo_supervisor().
2104+ *
2105+ * Returns pointer to "struct tomoyo_domain_info" if found, NULL otherwise.
2106+ */
2107+ static struct tomoyo_domain_info * tomoyo_find_domain_by_qid
2108+ (unsigned int serial )
2109+ {
2110+ struct tomoyo_query * ptr ;
2111+ struct tomoyo_domain_info * domain = NULL ;
2112+ spin_lock (& tomoyo_query_list_lock );
2113+ list_for_each_entry (ptr , & tomoyo_query_list , list ) {
2114+ if (ptr -> serial != serial || ptr -> answer )
2115+ continue ;
2116+ domain = ptr -> domain ;
2117+ break ;
2118+ }
2119+ spin_unlock (& tomoyo_query_list_lock );
2120+ return domain ;
2121+ }
2122+
20932123/**
20942124 * tomoyo_poll_query - poll() for /sys/kernel/security/tomoyo/query.
20952125 *
0 commit comments