public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/capability.c get_task_comm compile error (MMOTM)
@ 2007-11-11  1:01 Erez Zadok
  2007-11-11 14:15 ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Erez Zadok @ 2007-11-11  1:01 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Ulrich Drepper, Ingo Molnar, Roland McGrath, Andrew G. Morgan,
	Casey Schaufler, Chris Wright, James Morris, Serge Hallyn,
	Stephen Smalley, linux-kernel


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;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] kernel/capability.c get_task_comm compile error (MMOTM)
  2007-11-11  1:01 [PATCH] kernel/capability.c get_task_comm compile error (MMOTM) Erez Zadok
@ 2007-11-11 14:15 ` Ingo Molnar
  2007-11-11 17:11   ` Erez Zadok
  2007-11-11 19:30   ` Andrew Morton
  0 siblings, 2 replies; 5+ messages in thread
From: Ingo Molnar @ 2007-11-11 14:15 UTC (permalink / raw)
  To: Erez Zadok
  Cc: Andrew Morton, linux-kernel, Ulrich Drepper, Roland McGrath,
	Andrew G. Morgan, Casey Schaufler, Chris Wright, James Morris,
	Serge Hallyn, Stephen Smalley


* Erez Zadok <ezk@cs.sunysb.edu> wrote:

> Small patch below fixes compile error.

> +			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));

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kernel/capability.c get_task_comm compile error (MMOTM)
  2007-11-11 14:15 ` Ingo Molnar
@ 2007-11-11 17:11   ` Erez Zadok
  2007-11-11 20:44     ` Ingo Molnar
  2007-11-11 19:30   ` Andrew Morton
  1 sibling, 1 reply; 5+ messages in thread
From: Erez Zadok @ 2007-11-11 17:11 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Erez Zadok, Andrew Morton, linux-kernel, Ulrich Drepper,
	Roland McGrath, Andrew G. Morgan, Casey Schaufler, Chris Wright,
	James Morris, Serge Hallyn, Stephen Smalley

In message <20071111141510.GA29126@elte.hu>, Ingo Molnar writes:
> 
> * Erez Zadok <ezk@cs.sunysb.edu> wrote:
> 
> > Small patch below fixes compile error.
> 
> > +			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));
> 
> 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

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kernel/capability.c get_task_comm compile error (MMOTM)
  2007-11-11 14:15 ` Ingo Molnar
  2007-11-11 17:11   ` Erez Zadok
@ 2007-11-11 19:30   ` Andrew Morton
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2007-11-11 19:30 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Erez Zadok, linux-kernel, Ulrich Drepper, Roland McGrath,
	Andrew G. Morgan, Casey Schaufler, Chris Wright, James Morris,
	Serge Hallyn, Stephen Smalley

On Sun, 11 Nov 2007 15:15:10 +0100 Ingo Molnar <mingo@elte.hu> wrote:

> 
> * Erez Zadok <ezk@cs.sunysb.edu> wrote:
> 
> > Small patch below fixes compile error.
> 
> > +			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));
> 
> 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.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] kernel/capability.c get_task_comm compile error (MMOTM)
  2007-11-11 17:11   ` Erez Zadok
@ 2007-11-11 20:44     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2007-11-11 20:44 UTC (permalink / raw)
  To: Erez Zadok
  Cc: Andrew Morton, linux-kernel, Ulrich Drepper, Roland McGrath,
	Andrew G. Morgan, Casey Schaufler, Chris Wright, James Morris,
	Serge Hallyn, Stephen Smalley


* Erez Zadok <ezk@cs.sunysb.edu> wrote:

> 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.

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

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

HEAD ecd744eec3a.

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-11-11 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-11  1:01 [PATCH] kernel/capability.c get_task_comm compile error (MMOTM) Erez Zadok
2007-11-11 14:15 ` Ingo Molnar
2007-11-11 17:11   ` Erez Zadok
2007-11-11 20:44     ` Ingo Molnar
2007-11-11 19:30   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox