Re: [PATCH] rlim in proc//status (2nd rev.)

2008-01-16 Thread Clifford Wolf
Hi,

On Wed, Jan 16, 2008 at 04:33:12PM +0900, KOSAKI Motohiro wrote:
> Hi Clifford,
> 
> > +static inline char *task_rlim(struct task_struct *p, char *buffer)
> > +{
> > +   unsigned long flags;
> > +   struct rlimit rlim[RLIM_NLIMITS];
> > +   int i;
> > +   
> > +   rcu_read_lock();
> > +   if (lock_task_sighand(p, &flags)) {
> > +   for (i=0; i > +   rlim[i] = p->signal->rlim[i];
> > +   unlock_task_sighand(p, &flags);
> > +   }
> 
> lock_task_sighand is possible return NULL?
> if so, rlim is uninitialized when NULL.

hmm.. can p->sighand be NULL here? If so, there also is a problem in the
task_sig() function in the same file.

In fact that code is copy&paste from task_sig(). In fact I'm not even sure
if I actually need to lock anything to access p->signal->rlim.. I've
searched the kernel code a bit and it looks like most acesses to the rlimits
are done unlocked, which is no problem imo given the typical change-pattern
of this values..

anyone a clue on this issues?

yours,
 - clifford

-- 
2B OR (NOT 2B) That is the question. The answer is FF.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] rlim in proc//status (2nd rev.)

2008-01-15 Thread KOSAKI Motohiro
Hi Clifford,

> +static inline char *task_rlim(struct task_struct *p, char *buffer)
> +{
> + unsigned long flags;
> + struct rlimit rlim[RLIM_NLIMITS];
> + int i;
> + 
> + rcu_read_lock();
> + if (lock_task_sighand(p, &flags)) {
> + for (i=0; i + rlim[i] = p->signal->rlim[i];
> + unlock_task_sighand(p, &flags);
> + }

lock_task_sighand is possible return NULL?
if so, rlim is uninitialized when NULL.


- kosaki


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] rlim in proc//status (2nd rev.)

2008-01-15 Thread Clifford Wolf
Hi,

On Tue, Jan 15, 2008 at 02:36:59PM -0600, [EMAIL PROTECTED] wrote:
> > +   rcu_read_lock();
> > +   if (lock_task_sighand(p, &flags)) {
> > +   for (i=0; i > +   rlim[i] = p->signal->rlim[i];
> 
> I'm confused - where do you unlock_task_sighand()?

oh fsck! thanks for that pointer..

Here is a new version of the patch which solves this issue and the issues
adressed earlier in this thread by kosaki.

yours,
 - clifford

Signed-off-by: Clifford Wolf <[EMAIL PROTECTED]>

--- linux/fs/proc/array.c   (revision 750)
+++ linux/fs/proc/array.c   (revision 764)
@@ -239,6 +239,58 @@
}
 }
 
+static char *rlim_names[RLIM_NLIMITS] = {
+   [RLIMIT_CPU]= "CPU",
+   [RLIMIT_FSIZE]  = "FSize",
+   [RLIMIT_DATA]   = "Data",
+   [RLIMIT_STACK]  = "Stack",
+   [RLIMIT_CORE]   = "Core",
+   [RLIMIT_RSS]= "RSS",
+   [RLIMIT_NPROC]  = "NProc",
+   [RLIMIT_NOFILE] = "NoFile",
+   [RLIMIT_MEMLOCK]= "MemLock",
+   [RLIMIT_AS] = "AddrSpace",
+   [RLIMIT_LOCKS]  = "Locks",
+   [RLIMIT_SIGPENDING] = "SigPending",
+   [RLIMIT_MSGQUEUE]   = "MsgQueue",
+   [RLIMIT_NICE]   = "Nice",
+   [RLIMIT_RTPRIO] = "RTPrio"
+};
+
+#if RLIM_NLIMITS != 15
+#  error Value of RLIM_NLIMITS changed. \
+ Please update rlim_names in fs/proc/array.c
+#endif
+
+static inline char *task_rlim(struct task_struct *p, char *buffer)
+{
+   unsigned long flags;
+   struct rlimit rlim[RLIM_NLIMITS];
+   int i;
+   
+   rcu_read_lock();
+   if (lock_task_sighand(p, &flags)) {
+   for (i=0; isignal->rlim[i];
+   unlock_task_sighand(p, &flags);
+   }
+   rcu_read_unlock();
+
+   for (i=0; ihttp://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/