提交 f4b3a000 编写于 作者: J Jingxian He 提交者: Yang Yingliang

pid: fix pid recover method kabi change

hulk inclusion
category: feature
bugzilla: 48159
CVE: N/A

------------------------------

Pid recover method add new member to task_truct,
which generates kabi change problem.
We use KABI_RESERVE of task_truct, instead of
adding new member to task_truct.
Signed-off-by: NJingxian He <hejingxian@huawei.com>
Reviewed-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 b5758284
...@@ -164,7 +164,7 @@ static int set_fork_pid(unsigned long arg) ...@@ -164,7 +164,7 @@ static int set_fork_pid(unsigned long arg)
goto fault; goto fault;
if (copy_from_user(&pid, buf, sizeof(int))) if (copy_from_user(&pid, buf, sizeof(int)))
goto fault; goto fault;
current->fork_pid = pid; current->fork_pid_union.fork_pid = pid;
return 0; return 0;
fault: fault:
return -EFAULT; return -EFAULT;
......
...@@ -596,6 +596,13 @@ struct wake_q_node { ...@@ -596,6 +596,13 @@ struct wake_q_node {
struct wake_q_node *next; struct wake_q_node *next;
}; };
#ifdef CONFIG_PID_RESERVE
typedef union {
pid_t fork_pid;
unsigned long pid_reserve;
} fork_pid_t;
#endif
struct task_struct { struct task_struct {
#ifdef CONFIG_THREAD_INFO_IN_TASK #ifdef CONFIG_THREAD_INFO_IN_TASK
/* /*
...@@ -1206,9 +1213,6 @@ struct task_struct { ...@@ -1206,9 +1213,6 @@ struct task_struct {
/* Used by LSM modules for access restriction: */ /* Used by LSM modules for access restriction: */
void *security; void *security;
#endif #endif
#ifdef CONFIG_PID_RESERVE
int fork_pid;
#endif
/* /*
* New fields for task_struct should be added above here, so that * New fields for task_struct should be added above here, so that
...@@ -1227,7 +1231,15 @@ struct task_struct { ...@@ -1227,7 +1231,15 @@ struct task_struct {
KABI_RESERVE(3) KABI_RESERVE(3)
KABI_RESERVE(4) KABI_RESERVE(4)
#endif #endif
#ifdef CONFIG_PID_RESERVE
#ifndef __GENKSYMS__
fork_pid_t fork_pid_union;
#else
KABI_RESERVE(5)
#endif
#else
KABI_RESERVE(5) KABI_RESERVE(5)
#endif
KABI_RESERVE(6) KABI_RESERVE(6)
KABI_RESERVE(7) KABI_RESERVE(7)
KABI_RESERVE(8) KABI_RESERVE(8)
......
...@@ -181,7 +181,9 @@ struct task_struct init_task ...@@ -181,7 +181,9 @@ struct task_struct init_task
.security = NULL, .security = NULL,
#endif #endif
#ifdef CONFIG_PID_RESERVE #ifdef CONFIG_PID_RESERVE
.fork_pid = 0, .fork_pid_union = {
.fork_pid = 0,
},
#endif #endif
}; };
EXPORT_SYMBOL(init_task); EXPORT_SYMBOL(init_task);
......
...@@ -189,7 +189,7 @@ struct pid *alloc_pid(struct pid_namespace *ns) ...@@ -189,7 +189,7 @@ struct pid *alloc_pid(struct pid_namespace *ns)
pid_min = RESERVED_PIDS; pid_min = RESERVED_PIDS;
#ifdef CONFIG_PID_RESERVE #ifdef CONFIG_PID_RESERVE
if (!current->fork_pid) { if (!current->fork_pid_union.fork_pid) {
/* /*
* Store a null pointer so find_pid_ns does not find * Store a null pointer so find_pid_ns does not find
* a partially initialized PID (see below). * a partially initialized PID (see below).
...@@ -199,9 +199,9 @@ struct pid *alloc_pid(struct pid_namespace *ns) ...@@ -199,9 +199,9 @@ struct pid *alloc_pid(struct pid_namespace *ns)
GFP_ATOMIC); GFP_ATOMIC);
} else { } else {
/* Try to free the reserved fork_pid, and then use it to alloc pid. */ /* Try to free the reserved fork_pid, and then use it to alloc pid. */
free_reserved_pid(&tmp->idr, current->fork_pid); free_reserved_pid(&tmp->idr, current->fork_pid_union.fork_pid);
pid_min = current->fork_pid; pid_min = current->fork_pid_union.fork_pid;
current->fork_pid = 0; current->fork_pid_union.fork_pid = 0;
nr = idr_alloc(&tmp->idr, NULL, pid_min, nr = idr_alloc(&tmp->idr, NULL, pid_min,
pid_min + 1, pid_min + 1,
GFP_ATOMIC); GFP_ATOMIC);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册