This is a test repository.
修订版 | 1b6b924efeb9e46f0ca2ebe5b9bb6b276defe52d (tree) |
---|---|
时间 | 2020-11-27 19:36:11 |
作者 | Zheng Zengkai <zhengzengkai@huaw...> |
Commiter | Tetsuo Handa |
tomoyo: Fix null pointer check
Since tomoyo_memory_ok() will check for null pointer returned by
kzalloc() in tomoyo_assign_profile(), tomoyo_assign_namespace(),
tomoyo_get_name() and tomoyo_commit_ok(), then emit OOM warnings
if needed. And this is the expected behavior as informed by
Tetsuo Handa.
Let's add GFP_NOWARN to kzalloc() in those related functions.
Besides, to achieve this goal, remove the null check for entry
right after kzalloc() in tomoyo_assign_namespace().
Reported-by: Hulk Robot <hulkci@huawei.com>
Suggested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
@@ -498,7 +498,7 @@ static struct tomoyo_profile *tomoyo_assign_profile | ||
498 | 498 | ptr = ns->profile_ptr[profile]; |
499 | 499 | if (ptr) |
500 | 500 | return ptr; |
501 | - entry = kzalloc(sizeof(*entry), GFP_NOFS); | |
501 | + entry = kzalloc(sizeof(*entry), GFP_NOFS | __GFP_NOWARN); | |
502 | 502 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
503 | 503 | goto out; |
504 | 504 | ptr = ns->profile_ptr[profile]; |
@@ -473,9 +473,7 @@ struct tomoyo_policy_namespace *tomoyo_assign_namespace(const char *domainname) | ||
473 | 473 | return ptr; |
474 | 474 | if (len >= TOMOYO_EXEC_TMPSIZE - 10 || !tomoyo_domain_def(domainname)) |
475 | 475 | return NULL; |
476 | - entry = kzalloc(sizeof(*entry) + len + 1, GFP_NOFS); | |
477 | - if (!entry) | |
478 | - return NULL; | |
476 | + entry = kzalloc(sizeof(*entry) + len + 1, GFP_NOFS | __GFP_NOWARN); | |
479 | 477 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
480 | 478 | goto out; |
481 | 479 | ptr = tomoyo_find_namespace(domainname, len); |
@@ -73,7 +73,7 @@ bool tomoyo_memory_ok(void *ptr) | ||
73 | 73 | */ |
74 | 74 | void *tomoyo_commit_ok(void *data, const unsigned int size) |
75 | 75 | { |
76 | - void *ptr = kzalloc(size, GFP_NOFS); | |
76 | + void *ptr = kzalloc(size, GFP_NOFS | __GFP_NOWARN); | |
77 | 77 | |
78 | 78 | if (tomoyo_memory_ok(ptr)) { |
79 | 79 | memmove(ptr, data, size); |
@@ -170,7 +170,7 @@ const struct tomoyo_path_info *tomoyo_get_name(const char *name) | ||
170 | 170 | atomic_inc(&ptr->head.users); |
171 | 171 | goto out; |
172 | 172 | } |
173 | - ptr = kzalloc(sizeof(*ptr) + len, GFP_NOFS); | |
173 | + ptr = kzalloc(sizeof(*ptr) + len, GFP_NOFS | __GFP_NOWARN); | |
174 | 174 | if (tomoyo_memory_ok(ptr)) { |
175 | 175 | ptr->entry.name = ((char *) ptr) + sizeof(*ptr); |
176 | 176 | memmove((char *) ptr->entry.name, name, len); |