* get_task_comm() not exported? @ 2009-01-16 19:32 Christoph Bartelmus 2009-01-18 22:36 ` KOSAKI Motohiro 0 siblings, 1 reply; 20+ messages in thread From: Christoph Bartelmus @ 2009-01-16 19:32 UTC (permalink / raw) To: linux-kernel Hi, is there any reason why get_task_comm() is not exported in fs/exec.c? I'd like to use get_task_comm() from a kernel module and get unresolved symbol errors. Adding EXPORT_SYMBOL(get_task_comm); to fs/exec.c fixes the problem. Cheers, Christoph Please Cc. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: get_task_comm() not exported? 2009-01-16 19:32 get_task_comm() not exported? Christoph Bartelmus @ 2009-01-18 22:36 ` KOSAKI Motohiro 2009-01-20 21:24 ` Christoph Bartelmus 0 siblings, 1 reply; 20+ messages in thread From: KOSAKI Motohiro @ 2009-01-18 22:36 UTC (permalink / raw) To: Christoph Bartelmus; +Cc: kosaki.motohiro, linux-kernel Hi > Hi, > > is there any reason why get_task_comm() is not exported in fs/exec.c? In general, the only function of anybody necessarity explained is exported. if you want to export get_task_comm(), you need to explain reasonable reason. > > I'd like to use get_task_comm() from a kernel module and get unresolved > symbol errors. > > Adding EXPORT_SYMBOL(get_task_comm); to fs/exec.c fixes the problem. > > Cheers, > Christoph > > Please Cc. > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: get_task_comm() not exported? 2009-01-18 22:36 ` KOSAKI Motohiro @ 2009-01-20 21:24 ` Christoph Bartelmus 2009-01-27 5:09 ` [PATCH] export get_task_comm() KOSAKI Motohiro 0 siblings, 1 reply; 20+ messages in thread From: Christoph Bartelmus @ 2009-01-20 21:24 UTC (permalink / raw) To: kosaki.motohiro; +Cc: linux-kernel Hi, on 19 Jan 09 at 07:36, KOSAKI Motohiro wrote: >> is there any reason why get_task_comm() is not exported in fs/exec.c? > In general, the only function of anybody necessarity explained is exported. > if you want to export get_task_comm(), you need to explain reasonable > reason. It's nothing that important: just want to print the executable name to the logs during error handling. get_task_comm() is the required accessor function. http://lirc.cvs.sourceforge.net/viewvc/lirc/lirc/drivers/lirc_dev/lirc_dev.c?revision=1.70&view=markup Cheers, Christoph ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH] export get_task_comm() 2009-01-20 21:24 ` Christoph Bartelmus @ 2009-01-27 5:09 ` KOSAKI Motohiro 2009-01-27 5:16 ` Andrew Morton 0 siblings, 1 reply; 20+ messages in thread From: KOSAKI Motohiro @ 2009-01-27 5:09 UTC (permalink / raw) To: Christoph Bartelmus Cc: kosaki.motohiro, linux-kernel, Andrew Morton, Linus Torvalds > Hi, > > on 19 Jan 09 at 07:36, KOSAKI Motohiro wrote: > >> is there any reason why get_task_comm() is not exported in fs/exec.c? > > > In general, the only function of anybody necessarity explained is exported. > > if you want to export get_task_comm(), you need to explain reasonable > > reason. > > It's nothing that important: just want to print the executable name to the > logs during error handling. get_task_comm() is the required accessor > function. > > http://lirc.cvs.sourceforge.net/viewvc/lirc/lirc/drivers/lirc_dev/lirc_dev.c?revision=1.70&view=markup To be honest, I don't use get_task_comm(). but I don't oppose your request. == Subject: [PATCH] export get_task_comm() task::comm is good debugging information and driver developer want to use this information easily. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> --- fs/exec.c | 1 + 1 file changed, 1 insertion(+) Index: b/fs/exec.c =================================================================== --- a/fs/exec.c +++ b/fs/exec.c @@ -936,6 +936,7 @@ char *get_task_comm(char *buf, struct ta task_unlock(tsk); return buf; } +EXPORT_SYMBOL_GPL(get_task_comm); void set_task_comm(struct task_struct *tsk, char *buf) { ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 5:09 ` [PATCH] export get_task_comm() KOSAKI Motohiro @ 2009-01-27 5:16 ` Andrew Morton 2009-01-27 5:19 ` Kyle McMartin 2009-01-27 15:41 ` Linus Torvalds 0 siblings, 2 replies; 20+ messages in thread From: Andrew Morton @ 2009-01-27 5:16 UTC (permalink / raw) To: KOSAKI Motohiro; +Cc: Christoph Bartelmus, linux-kernel, Linus Torvalds On Tue, 27 Jan 2009 14:09:05 +0900 (JST) KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote: > > Hi, > > > > on 19 Jan 09 at 07:36, KOSAKI Motohiro wrote: > > >> is there any reason why get_task_comm() is not exported in fs/exec.c? > > > > > In general, the only function of anybody necessarity explained is exported. > > > if you want to export get_task_comm(), you need to explain reasonable > > > reason. > > > > It's nothing that important: just want to print the executable name to the > > logs during error handling. get_task_comm() is the required accessor > > function. > > > > http://lirc.cvs.sourceforge.net/viewvc/lirc/lirc/drivers/lirc_dev/lirc_dev.c?revision=1.70&view=markup > > To be honest, I don't use get_task_comm(). but I don't oppose your request. > > == > Subject: [PATCH] export get_task_comm() > > task::comm is good debugging information and driver developer want to > use this information easily. > > Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> > --- > fs/exec.c | 1 + > 1 file changed, 1 insertion(+) > > Index: b/fs/exec.c > =================================================================== > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -936,6 +936,7 @@ char *get_task_comm(char *buf, struct ta > task_unlock(tsk); > return buf; > } > +EXPORT_SYMBOL_GPL(get_task_comm); > > void set_task_comm(struct task_struct *tsk, char *buf) > { Ho hum, I suppose so. I redid the changelog a bit: task_struct.comm[] is useful for debugging and driver developers want to use this information easily. Direct access to task_struct.comm[] is a bit racy, so export the official accessor. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 5:16 ` Andrew Morton @ 2009-01-27 5:19 ` Kyle McMartin 2009-01-27 5:26 ` Andrew Morton 2009-01-27 15:41 ` Linus Torvalds 1 sibling, 1 reply; 20+ messages in thread From: Kyle McMartin @ 2009-01-27 5:19 UTC (permalink / raw) To: Andrew Morton Cc: KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Linus Torvalds On Mon, Jan 26, 2009 at 09:16:55PM -0800, Andrew Morton wrote: > Ho hum, I suppose so. I redid the changelog a bit: > > task_struct.comm[] is useful for debugging and driver developers > want to use this information easily. Direct access to > task_struct.comm[] is a bit racy, so export the official accessor. > Maybe lirc should be submitted to staging/ before we go exporting symbols for out of tree things... ;-) ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 5:19 ` Kyle McMartin @ 2009-01-27 5:26 ` Andrew Morton 2009-01-27 5:29 ` Andrew Morton 0 siblings, 1 reply; 20+ messages in thread From: Andrew Morton @ 2009-01-27 5:26 UTC (permalink / raw) To: Kyle McMartin Cc: KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Linus Torvalds On Tue, 27 Jan 2009 00:19:19 -0500 Kyle McMartin <kyle@infradead.org> wrote: > On Mon, Jan 26, 2009 at 09:16:55PM -0800, Andrew Morton wrote: > > Ho hum, I suppose so. I redid the changelog a bit: > > > > task_struct.comm[] is useful for debugging and driver developers > > want to use this information easily. Direct access to > > task_struct.comm[] is a bit racy, so export the official accessor. > > > > Maybe lirc should be submitted to staging/ before we go exporting > symbols for out of tree things... ;-) y:/usr/src/linux-2.6.29-rc2> grep -r 'current->comm' drivers | wc -l 77 :( ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 5:26 ` Andrew Morton @ 2009-01-27 5:29 ` Andrew Morton 2009-01-27 5:39 ` [PATCH] make checkpatch warn about access to current->comm Kyle McMartin 2009-01-27 8:49 ` [PATCH] export get_task_comm() Alexey Dobriyan 0 siblings, 2 replies; 20+ messages in thread From: Andrew Morton @ 2009-01-27 5:29 UTC (permalink / raw) To: Kyle McMartin, KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft On Mon, 26 Jan 2009 21:26:15 -0800 Andrew Morton <akpm@linux-foundation.org> wrote: > On Tue, 27 Jan 2009 00:19:19 -0500 Kyle McMartin <kyle@infradead.org> wrote: > > > On Mon, Jan 26, 2009 at 09:16:55PM -0800, Andrew Morton wrote: > > > Ho hum, I suppose so. I redid the changelog a bit: > > > > > > task_struct.comm[] is useful for debugging and driver developers > > > want to use this information easily. Direct access to > > > task_struct.comm[] is a bit racy, so export the official accessor. > > > > > > > Maybe lirc should be submitted to staging/ before we go exporting > > symbols for out of tree things... ;-) > > y:/usr/src/linux-2.6.29-rc2> grep -r 'current->comm' drivers | wc -l > 77 > > :( It's worth a checkpatch rule, I guess: "direct access to task_struct.comm is racy - use get_task_comm()". ^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH] make checkpatch warn about access to current->comm 2009-01-27 5:29 ` Andrew Morton @ 2009-01-27 5:39 ` Kyle McMartin 2009-01-27 5:50 ` KOSAKI Motohiro 2009-01-27 15:45 ` Linus Torvalds 2009-01-27 8:49 ` [PATCH] export get_task_comm() Alexey Dobriyan 1 sibling, 2 replies; 20+ messages in thread From: Kyle McMartin @ 2009-01-27 5:39 UTC (permalink / raw) To: Andrew Morton Cc: Kyle McMartin, KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft From: Kyle McMartin <kyle@redhat.com> Suggest using the get_task_comm accessor versus direct access to current->comm. Signed-off-by: Kyle McMartin <kyle@redhat.com> --- I just mashed it in the middle of existing checks to minimize risk of collisions. diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 45eb0ae..4f2da5d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2533,6 +2533,11 @@ sub process { $herecurr); } +# direct access to current task name is racy, suggest accessor instead. + if ($line =~ /current\-\>comm/) { + WARN("direct access to current->comm is racy, use get_task_comm() instead.\n" . $herecurr); + } + # use of NR_CPUS is usually wrong # ignore definitions of NR_CPUS and usage to define arrays as likely right if ($line =~ /\bNR_CPUS\b/ && ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 5:39 ` [PATCH] make checkpatch warn about access to current->comm Kyle McMartin @ 2009-01-27 5:50 ` KOSAKI Motohiro 2009-01-27 5:52 ` Kyle McMartin 2009-01-27 15:45 ` Linus Torvalds 1 sibling, 1 reply; 20+ messages in thread From: KOSAKI Motohiro @ 2009-01-27 5:50 UTC (permalink / raw) To: Kyle McMartin Cc: kosaki.motohiro, Andrew Morton, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft > +# direct access to current task name is racy, suggest accessor instead. > + if ($line =~ /current\-\>comm/) { > + WARN("direct access to current->comm is racy, use get_task_comm() instead.\n" . $herecurr); > + } > + > # use of NR_CPUS is usually wrong > # ignore definitions of NR_CPUS and usage to define arrays as likely right > if ($line =~ /\bNR_CPUS\b/ && ./scripts/checkpatch --file fs/exec.c ------------------------------------------------------ WARNING: direct access to current->comm is racy, use get_task_comm() instead. #952: FILE: exec.c:952: + char tcomm[sizeof(current->comm)]; (snip) WARNING: direct access to current->comm is racy, use get_task_comm() instead. #1459: FILE: exec.c:1459: + "%s", current->comm); (snip) WARNING: direct access to current->comm is racy, use get_task_comm() instead. #1788: FILE: exec.c:1788: + if (!strcmp(delimit, current->comm)) { --------------------------- I think "char tcomm[sizeof(current->comm)];" is valid code. if checkpatch.pl don't warn "sizeof(current->comm)", I'm glad. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 5:50 ` KOSAKI Motohiro @ 2009-01-27 5:52 ` Kyle McMartin 2009-01-27 5:58 ` KOSAKI Motohiro 0 siblings, 1 reply; 20+ messages in thread From: Kyle McMartin @ 2009-01-27 5:52 UTC (permalink / raw) To: KOSAKI Motohiro Cc: Kyle McMartin, Andrew Morton, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft On Tue, Jan 27, 2009 at 02:50:18PM +0900, KOSAKI Motohiro wrote: > I think "char tcomm[sizeof(current->comm)];" is valid code. > if checkpatch.pl don't warn "sizeof(current->comm)", I'm glad. > Awfully interesting way of writing TASK_COMM_LEN :) cheers, Kyle ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 5:52 ` Kyle McMartin @ 2009-01-27 5:58 ` KOSAKI Motohiro 2009-01-27 6:09 ` Kyle McMartin 0 siblings, 1 reply; 20+ messages in thread From: KOSAKI Motohiro @ 2009-01-27 5:58 UTC (permalink / raw) To: Kyle McMartin Cc: kosaki.motohiro, Andrew Morton, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft > On Tue, Jan 27, 2009 at 02:50:18PM +0900, KOSAKI Motohiro wrote: > > I think "char tcomm[sizeof(current->comm)];" is valid code. > > if checkpatch.pl don't warn "sizeof(current->comm)", I'm glad. > > Awfully interesting way of writing TASK_COMM_LEN :) I don't think so awfully. I think "sizeof(array_val)" is typical code in kernel. I agree that we can rewrite s/tcomm[sizeof(current->comm)]/char tcomm[TASK_COMM_LEN]/. but it's annoyed. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 5:58 ` KOSAKI Motohiro @ 2009-01-27 6:09 ` Kyle McMartin 0 siblings, 0 replies; 20+ messages in thread From: Kyle McMartin @ 2009-01-27 6:09 UTC (permalink / raw) To: KOSAKI Motohiro Cc: Kyle McMartin, Andrew Morton, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft On Tue, Jan 27, 2009 at 02:58:51PM +0900, KOSAKI Motohiro wrote: > > On Tue, Jan 27, 2009 at 02:50:18PM +0900, KOSAKI Motohiro wrote: > > > I think "char tcomm[sizeof(current->comm)];" is valid code. > > > if checkpatch.pl don't warn "sizeof(current->comm)", I'm glad. > > > > Awfully interesting way of writing TASK_COMM_LEN :) > > I don't think so awfully. > I think "sizeof(array_val)" is typical code in kernel. > > I agree that we can rewrite s/tcomm[sizeof(current->comm)]/char tcomm[TASK_COMM_LEN]/. > but it's annoyed. > If current->comm was changed to be kmalloc'd this would need to be changed anyway, so why not just do it now? regards, Kyle ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 5:39 ` [PATCH] make checkpatch warn about access to current->comm Kyle McMartin 2009-01-27 5:50 ` KOSAKI Motohiro @ 2009-01-27 15:45 ` Linus Torvalds 2009-01-27 15:57 ` Kyle McMartin 2009-01-27 18:15 ` Christoph Bartelmus 1 sibling, 2 replies; 20+ messages in thread From: Linus Torvalds @ 2009-01-27 15:45 UTC (permalink / raw) To: Kyle McMartin Cc: Andrew Morton, KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Andy Whitcroft On Tue, 27 Jan 2009, Kyle McMartin wrote: > > Suggest using the get_task_comm accessor versus direct access to > current->comm. I think "current->comm" is fine, and not racy. It only gets racy when you ask for the name of _another_ task. And quite frankly, I don't think anybody but /proc does that anyway. I think this whole "get_task_comm()" thing is overrated. Most people are better off doing just "current->comm". Linus ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 15:45 ` Linus Torvalds @ 2009-01-27 15:57 ` Kyle McMartin 2009-01-27 18:15 ` Christoph Bartelmus 1 sibling, 0 replies; 20+ messages in thread From: Kyle McMartin @ 2009-01-27 15:57 UTC (permalink / raw) To: Linus Torvalds Cc: Kyle McMartin, Andrew Morton, KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Andy Whitcroft On Tue, Jan 27, 2009 at 07:45:41AM -0800, Linus Torvalds wrote: > > > On Tue, 27 Jan 2009, Kyle McMartin wrote: > > > > Suggest using the get_task_comm accessor versus direct access to > > current->comm. > > I think "current->comm" is fine, and not racy. > > It only gets racy when you ask for the name of _another_ task. > > And quite frankly, I don't think anybody but /proc does that anyway. I > think this whole "get_task_comm()" thing is overrated. Most people are > better off doing just "current->comm". > Sure, fine by me. I'd forgotten that prctl doesn't have a `pid' argument to change another tasks comm. regards, Kyle ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] make checkpatch warn about access to current->comm 2009-01-27 15:45 ` Linus Torvalds 2009-01-27 15:57 ` Kyle McMartin @ 2009-01-27 18:15 ` Christoph Bartelmus 1 sibling, 0 replies; 20+ messages in thread From: Christoph Bartelmus @ 2009-01-27 18:15 UTC (permalink / raw) To: torvalds; +Cc: akpm, apw, kosaki.motohiro, kyle, linux-kernel On 27 Jan 09 at 07:45, Linus Torvalds wrote: > On Tue, 27 Jan 2009, Kyle McMartin wrote: >> >> Suggest using the get_task_comm accessor versus direct access to >> current->comm. > I think "current->comm" is fine, and not racy. > > It only gets racy when you ask for the name of _another_ task. > > And quite frankly, I don't think anybody but /proc does that anyway. I > think this whole "get_task_comm()" thing is overrated. Most people are > better off doing just "current->comm". This issue only came up because for someone like me it's not obvious at all that using "current->comm" is safe and the comment in sched.h explicitly points out that task_struct.comm should be accessed with [gs]et_task_comm. Christoph ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 5:29 ` Andrew Morton 2009-01-27 5:39 ` [PATCH] make checkpatch warn about access to current->comm Kyle McMartin @ 2009-01-27 8:49 ` Alexey Dobriyan 2009-01-27 9:00 ` Andrew Morton 1 sibling, 1 reply; 20+ messages in thread From: Alexey Dobriyan @ 2009-01-27 8:49 UTC (permalink / raw) To: Andrew Morton Cc: Kyle McMartin, KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft On Mon, Jan 26, 2009 at 09:29:18PM -0800, Andrew Morton wrote: > On Mon, 26 Jan 2009 21:26:15 -0800 Andrew Morton <akpm@linux-foundation.org> wrote: > > > On Tue, 27 Jan 2009 00:19:19 -0500 Kyle McMartin <kyle@infradead.org> wrote: > > > > > On Mon, Jan 26, 2009 at 09:16:55PM -0800, Andrew Morton wrote: > > > > Ho hum, I suppose so. I redid the changelog a bit: > > > > > > > > task_struct.comm[] is useful for debugging and driver developers > > > > want to use this information easily. Direct access to > > > > task_struct.comm[] is a bit racy, so export the official accessor. > > > > > > > > > > Maybe lirc should be submitted to staging/ before we go exporting > > > symbols for out of tree things... ;-) > > > > y:/usr/src/linux-2.6.29-rc2> grep -r 'current->comm' drivers | wc -l > > 77 > > > > :( > > It's worth a checkpatch rule, I guess: "direct access to > task_struct.comm is racy - use get_task_comm()". And majority of usages is some debugging printk where nobody cares if ->comm corrupted. Changelog says is useful for debugging. That's right, tsk->comm is useful for debugging, not allocating temporary buffer + get_task_comm(). Some ->comm usages are for kernel threads which never change it, for starters. current->comm is always safe, because, current is not executing prctl(2)! I'd say nothing should be done and, heavens forbid, adding this to checkpatch.pl. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 8:49 ` [PATCH] export get_task_comm() Alexey Dobriyan @ 2009-01-27 9:00 ` Andrew Morton 2009-01-27 10:15 ` KOSAKI Motohiro 0 siblings, 1 reply; 20+ messages in thread From: Andrew Morton @ 2009-01-27 9:00 UTC (permalink / raw) To: Alexey Dobriyan Cc: Kyle McMartin, KOSAKI Motohiro, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft On Tue, 27 Jan 2009 11:49:56 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote: > On Mon, Jan 26, 2009 at 09:29:18PM -0800, Andrew Morton wrote: > > On Mon, 26 Jan 2009 21:26:15 -0800 Andrew Morton <akpm@linux-foundation.org> wrote: > > > > > On Tue, 27 Jan 2009 00:19:19 -0500 Kyle McMartin <kyle@infradead.org> wrote: > > > > > > > On Mon, Jan 26, 2009 at 09:16:55PM -0800, Andrew Morton wrote: > > > > > Ho hum, I suppose so. I redid the changelog a bit: > > > > > > > > > > task_struct.comm[] is useful for debugging and driver developers > > > > > want to use this information easily. Direct access to > > > > > task_struct.comm[] is a bit racy, so export the official accessor. > > > > > > > > > > > > > Maybe lirc should be submitted to staging/ before we go exporting > > > > symbols for out of tree things... ;-) > > > > > > y:/usr/src/linux-2.6.29-rc2> grep -r 'current->comm' drivers | wc -l > > > 77 > > > > > > :( > > > > It's worth a checkpatch rule, I guess: "direct access to > > task_struct.comm is racy - use get_task_comm()". > > And majority of usages is some debugging printk where nobody cares if ->comm > corrupted. > > Changelog says is useful for debugging. That's right, tsk->comm is useful > for debugging, not allocating temporary buffer + get_task_comm(). > > Some ->comm usages are for kernel threads which never change it, for starters. > > current->comm is always safe, because, current is not executing prctl(2)! That's a good point. > I'd say nothing should be done and, heavens forbid, adding this to checkpatch.pl. hm, yeah, OK, I'll drop it. ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 9:00 ` Andrew Morton @ 2009-01-27 10:15 ` KOSAKI Motohiro 0 siblings, 0 replies; 20+ messages in thread From: KOSAKI Motohiro @ 2009-01-27 10:15 UTC (permalink / raw) To: Andrew Morton Cc: kosaki.motohiro, Alexey Dobriyan, Kyle McMartin, Christoph Bartelmus, linux-kernel, Linus Torvalds, Andy Whitcroft > > > It's worth a checkpatch rule, I guess: "direct access to > > > task_struct.comm is racy - use get_task_comm()". > > > > And majority of usages is some debugging printk where nobody cares if ->comm > > corrupted. > > > > Changelog says is useful for debugging. That's right, tsk->comm is useful > > for debugging, not allocating temporary buffer + get_task_comm(). > > > > Some ->comm usages are for kernel threads which never change it, for starters. > > > > current->comm is always safe, because, current is not executing prctl(2)! > > That's a good point. > > > I'd say nothing should be done and, heavens forbid, adding this to checkpatch.pl. > > hm, yeah, OK, I'll drop it. Oh, I have to agree Alexey because he is always right ;) ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH] export get_task_comm() 2009-01-27 5:16 ` Andrew Morton 2009-01-27 5:19 ` Kyle McMartin @ 2009-01-27 15:41 ` Linus Torvalds 1 sibling, 0 replies; 20+ messages in thread From: Linus Torvalds @ 2009-01-27 15:41 UTC (permalink / raw) To: Andrew Morton; +Cc: KOSAKI Motohiro, Christoph Bartelmus, linux-kernel On Mon, 26 Jan 2009, Andrew Morton wrote: > > > > task::comm is good debugging information and driver developer want to > > use this information easily. > > Ho hum, I suppose so. I redid the changelog a bit: > > task_struct.comm[] is useful for debugging and driver developers > want to use this information easily. Direct access to > task_struct.comm[] is a bit racy, so export the official accessor. The biggest issue I have with this is that the whole "get_task_comm()" interface is not very good for random users - it inherently depends on the result buffer being at least sizeof(tsk->comm). If we export it to random routines, I get the feeling that we should pass in the size of the result buffer, so that they don't have to know about this requirement. Linus ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2009-01-27 18:17 UTC | newest] Thread overview: 20+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-01-16 19:32 get_task_comm() not exported? Christoph Bartelmus 2009-01-18 22:36 ` KOSAKI Motohiro 2009-01-20 21:24 ` Christoph Bartelmus 2009-01-27 5:09 ` [PATCH] export get_task_comm() KOSAKI Motohiro 2009-01-27 5:16 ` Andrew Morton 2009-01-27 5:19 ` Kyle McMartin 2009-01-27 5:26 ` Andrew Morton 2009-01-27 5:29 ` Andrew Morton 2009-01-27 5:39 ` [PATCH] make checkpatch warn about access to current->comm Kyle McMartin 2009-01-27 5:50 ` KOSAKI Motohiro 2009-01-27 5:52 ` Kyle McMartin 2009-01-27 5:58 ` KOSAKI Motohiro 2009-01-27 6:09 ` Kyle McMartin 2009-01-27 15:45 ` Linus Torvalds 2009-01-27 15:57 ` Kyle McMartin 2009-01-27 18:15 ` Christoph Bartelmus 2009-01-27 8:49 ` [PATCH] export get_task_comm() Alexey Dobriyan 2009-01-27 9:00 ` Andrew Morton 2009-01-27 10:15 ` KOSAKI Motohiro 2009-01-27 15:41 ` Linus Torvalds
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox