Re: [PATCH] kernel/capability.c get_task_comm compile error (MMOTM)

Previous thread: [PATCH] mm/memory.c follow_hugetlb_page compiler error (MMOTM) by Erez Zadok on Saturday, November 10, 2007 - 8:54 pm. (2 messages)

Next thread: patch conflicts (MMOTM "10-Nov-2007 22:46") by Erez Zadok on Saturday, November 10, 2007 - 9:04 pm. (2 messages)
To: Andrew Morton <akpm@...>, <linux-kernel@...>
Cc: Ulrich Drepper <drepper@...>, Ingo Molnar <mingo@...>, Roland McGrath <roland@...>, Andrew G. Morgan <morgan@...>, Casey Schaufler <casey@...>, Chris Wright <chrisw@...>, James Morris <jmorris@...>, Serge Hallyn <serue@...>, Stephen Smalley <sds@...>, <linux-kernel@...>
Date: Saturday, November 10, 2007 - 9:01 pm

Using http://userweb.kernel.org/~akpm/mmotm/ timestamped "10-Nov-2007
22:46".

$ make
CC kernel/capability.o
kernel/capability.c: In function 'sys_capset':
kernel/capability.c:231: warning: passing argument 1 of 'get_task_comm' from incompatible pointer type
kernel/capability.c:231: error: too few arguments to function 'get_task_comm'
make[1]: *** [kernel/capability.o] Error 1
make[1]: Target `__build' not remade because of errors.
make: *** [kernel] Error 2

Small patch below fixes compile error.

Erez.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>

diff --git a/kernel/capability.c b/kernel/capability.c
index ea21bbe..8cba9b2 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -225,10 +225,11 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data)
switch (version) {
case _LINUX_CAPABILITY_VERSION_1:
if (warned < 5) {
+ char name[sizeof(current->comm)];
warned++;
printk(KERN_INFO
"warning: process `%s' sets w/ old libcap\n",
- get_task_comm(current));
+ get_task_comm(name, current));
}
tocopy = _LINUX_CAPABILITY_U32S_1;
break;
-

To: Erez Zadok <ezk@...>
Cc: Andrew Morton <akpm@...>, <linux-kernel@...>, Ulrich Drepper <drepper@...>, Roland McGrath <roland@...>, Andrew G. Morgan <morgan@...>, Casey Schaufler <casey@...>, Chris Wright <chrisw@...>, James Morris <jmorris@...>, Serge Hallyn <serue@...>, Stephen Smalley <sds@...>
Date: Sunday, November 11, 2007 - 10:15 am

that's buggy - get_task_comm() returns void.

the proper fix would be to first do a get_task_comm() then pass in
'name' as an argument to printk.

Ingo
-

To: Ingo Molnar <mingo@...>
Cc: Erez Zadok <ezk@...>, <linux-kernel@...>, Ulrich Drepper <drepper@...>, Roland McGrath <roland@...>, Andrew G. Morgan <morgan@...>, Casey Schaufler <casey@...>, Chris Wright <chrisw@...>, James Morris <jmorris@...>, Serge Hallyn <serue@...>, Stephen Smalley <sds@...>
Date: Sunday, November 11, 2007 - 3:30 pm

yup, it is all dependent upon http://lkml.org/lkml/2007/11/8/231
-

To: Ingo Molnar <mingo@...>
Cc: Erez Zadok <ezk@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, Ulrich Drepper <drepper@...>, Roland McGrath <roland@...>, Andrew G. Morgan <morgan@...>, Casey Schaufler <casey@...>, Chris Wright <chrisw@...>, James Morris <jmorris@...>, Serge Hallyn <serue@...>, Stephen Smalley <sds@...>
Date: Sunday, November 11, 2007 - 1:11 pm

Ingo, I don't see how it can return NULL. This is what get_task_comm looks
like in MMOTM-2007-11-10-19-05:

char *get_task_comm(char *buf, struct task_struct *tsk)
{
/* buf must be at least sizeof(tsk->comm) in size */
task_lock(tsk);
strncpy(buf, tsk->comm, sizeof(tsk->comm));
task_unlock(tsk);
return buf;
}

The only way it'd return NULL is if a null buf was passed, in which case the
strncpy will oops first.

Erez.
-

To: Erez Zadok <ezk@...>
Cc: Andrew Morton <akpm@...>, <linux-kernel@...>, Ulrich Drepper <drepper@...>, Roland McGrath <roland@...>, Andrew G. Morgan <morgan@...>, Casey Schaufler <casey@...>, Chris Wright <chrisw@...>, James Morris <jmorris@...>, Serge Hallyn <serue@...>, Stephen Smalley <sds@...>
Date: Sunday, November 11, 2007 - 4:44 pm

hm, here it says in include/linux/sched.h:

extern void get_task_comm(char *to, struct task_struct *tsk);

HEAD ecd744eec3a.

Ingo
-

Previous thread: [PATCH] mm/memory.c follow_hugetlb_page compiler error (MMOTM) by Erez Zadok on Saturday, November 10, 2007 - 8:54 pm. (2 messages)

Next thread: patch conflicts (MMOTM "10-Nov-2007 22:46") by Erez Zadok on Saturday, November 10, 2007 - 9:04 pm. (2 messages)