From: Andi Kleen <ak@suse.de>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Andi Kleen <ak@suse.de>,
akpm@osdl.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
bastian@suse.de
Subject: Re: [PATCH] Add prctl to modify current->comm
Date: Tue, 7 Sep 2004 23:16:26 +0200 [thread overview]
Message-ID: <20040907211626.GB15043@wotan.suse.de> (raw)
In-Reply-To: <1094577168.9599.13.camel@localhost.localdomain>
On Tue, Sep 07, 2004 at 06:12:48PM +0100, Alan Cox wrote:
> > + case PR_SET_NAME: {
> > + struct task_struct *me = current;
> > + me->comm[sizeof(me->comm)-1] = 0;
> > + if (strncpy_from_user(me->comm, (char *)arg2, sizeof(me->comm)-1) < 0)
> > + return -EFAULT;
> > + return 0;
> > + }
>
> If the strncpy_from_user faults the state of current->comm is undefined.
I didn't see it as a big issue because the result will be 0 terminated
anyways.
> This strikes me as bad design.
Here's is a new patch with this fixed.
-Andi
--------------------------------------------------------------------
Allow a program to change its current->comm
Useful for KDE & kdeinit.
diff -u linux-2.6.8-5/kernel/sys.c-o linux-2.6.8-5/kernel/sys.c
--- linux-2.6.8-5/kernel/sys.c-o 2004-08-14 07:36:16.000000000 +0200
+++ linux-2.6.8-5/kernel/sys.c 2004-09-07 23:09:56.000000000 +0200
@@ -1660,6 +1660,15 @@
}
current->keep_capabilities = arg2;
break;
+ case PR_SET_NAME: {
+ struct task_struct *me = current;
+ unsigned char ncomm[sizeof(me->comm)];
+ ncomm[sizeof(me->comm)-1] = 0;
+ if (strncpy_from_user(ncomm, (char *)arg2, sizeof(me->comm)-1) < 0)
+ return -EFAULT;
+ memcpy(me->comm, ncomm, sizeof(me->comm));
+ return 0;
+ }
default:
error = -EINVAL;
break;
diff -u linux-2.6.8-5/include/linux/prctl.h-o linux-2.6.8-5/include/linux/prctl.h
--- linux-2.6.8-5/include/linux/prctl.h-o 2004-08-14 07:37:14.000000000 +0200
+++ linux-2.6.8-5/include/linux/prctl.h 2004-09-07 23:09:44.000000000 +0200
@@ -49,5 +49,6 @@
# define PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based
process timing */
+#define PR_SET_NAME 15 /* Set process name. */
#endif /* _LINUX_PRCTL_H */
prev parent reply other threads:[~2004-09-07 21:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-07 14:27 Andi Kleen
2004-09-07 17:12 ` Alan Cox
2004-09-07 21:16 ` Andi Kleen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040907211626.GB15043@wotan.suse.de \
--to=ak@suse.de \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bastian@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®