lkml.org 
[lkml]   [2021]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5] kernel/sched: improve the BUILD_BUG_ON() in get_task_comm()
Date
What we really want to guarantee is that the buf size can't be less than
TASK_COMM_LEN. While the size be greater than TASK_COMM_LEN is
acceptable.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/linux/sched.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index b387b5943db4..959eaef248fc 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1931,7 +1931,7 @@ static inline void set_task_comm(struct task_struct *tsk, const char *from)

extern char *__get_task_comm(char *to, size_t len, struct task_struct *tsk);
#define get_task_comm(buf, tsk) ({ \
- BUILD_BUG_ON(sizeof(buf) != TASK_COMM_LEN); \
+ BUILD_BUG_ON(sizeof(buf) < TASK_COMM_LEN); \
__get_task_comm(buf, sizeof(buf), tsk); \
})

--
2.17.1
\
 
 \ /
  Last update: 2021-09-29 13:53    [W:0.245 / U:0.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site