TOMOYO: Copy directly to userspace buffer.
When userspace program reads policy from /sys/kernel/security/tomoyo/ interface, TOMOYO uses line buffered mode. A line has at least one word. Commit 006dacc "TOMOYO: Support longer pathname." changed a word's max length from 4000 bytes to max kmalloc()able bytes. By that commit, a line's max length changed from 8192 bytes to more than max kmalloc()able bytes. Max number of words in a line remains finite. This patch changes the way of buffering so that all words in a line are firstly directly copied to userspace buffer as much as possible and are secondly queued for next read request. Words queued are guaranteed to be valid until /sys/kernel/security/tomoyo/ interface is close()d. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:

committed by
James Morris

parent
5db5a39b64
commit
f23571e866
@@ -234,7 +234,7 @@ unsigned int tomoyo_quota_for_query;
|
||||
*/
|
||||
void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head)
|
||||
{
|
||||
if (!head->read_eof) {
|
||||
if (!head->r.eof) {
|
||||
const unsigned int policy
|
||||
= atomic_read(&tomoyo_policy_memory_size);
|
||||
const unsigned int query = tomoyo_query_memory_size;
|
||||
@@ -258,7 +258,7 @@ void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head)
|
||||
tomoyo_io_printf(head, "Query lists: %10u%s\n", query,
|
||||
buffer);
|
||||
tomoyo_io_printf(head, "Total: %10u\n", policy + query);
|
||||
head->read_eof = true;
|
||||
head->r.eof = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user