From: Andrew Morton <akpm@osdl.org>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Cc: manfred@colorfullife.com, linux-kernel@vger.kernel.org,
jakub@redhat.com, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] per-user signal pending and message queue limits
Date: Wed, 28 Apr 2004 14:03:16 -0700 [thread overview]
Message-ID: <20040428140316.4146b3bd.akpm@osdl.org> (raw)
In-Reply-To: <20040428170932.GA14993@logos.cnet>
Marcelo Tosatti <marcelo.tosatti@cyclades.com> wrote:
>
> static void mqueue_delete_inode(struct inode *inode)
> {
> struct mqueue_inode_info *info;
> + struct user_struct *user;
> int i;
>
> if (S_ISDIR(inode->i_mode)) {
> clear_inode(inode);
> return;
> }
> +
> info = MQUEUE_I(inode);
> +
> + user = find_user(info->creator_id);
> + if (!user)
> + BUG();
> spin_lock(&info->lock);
hmm, look at that. find_user() forgot to take any locks. Maybe it's
relying on tasklist_lock? I think we need the below patch. Ingo, can you
please confirm?
Also, you'll need to do a free_uid() in here - find_user() takes a ref.
Also, I'm not sure that it's legit to go BUG if the user wasn't found. Is
it not possible that the user has gone away and it is root who is cleaning
up the inode?
Finally, my head is gently rotating wrt this patch. Could you please
maintain a description of what it does? We've made several significant
design decisions in here and that info really should be captured. The
relationship between the global and per-user limits, the sizing choices for
the per-user limits, etc. If it can be captured in brief code comments,
that's best. Otherwise for the changelog.
Thanks.
---
25-akpm/kernel/sys.c | 4 ++++
25-akpm/kernel/user.c | 13 ++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff -puN kernel/user.c~find_user-locking kernel/user.c
--- 25/kernel/user.c~find_user-locking Wed Apr 28 13:56:52 2004
+++ 25-akpm/kernel/user.c Wed Apr 28 13:58:28 2004
@@ -64,9 +64,20 @@ static inline struct user_struct *uid_ha
return NULL;
}
+/*
+ * Locate the user_struct for the passed UID. If found, take a ref on it. The
+ * caller must undo that ref with free_uid().
+ *
+ * If the user_struct could not be found, return NULL.
+ */
struct user_struct *find_user(uid_t uid)
{
- return uid_hash_find(uid, uidhashentry(uid));
+ struct user_struct *ret;
+
+ spin_lock(&uidhash_lock);
+ ret = uid_hash_find(uid, uidhashentry(uid));
+ spin_unlock(&uidhash_lock);
+ return ret;
}
void free_uid(struct user_struct *up)
diff -puN kernel/sys.c~find_user-locking kernel/sys.c
--- 25/kernel/sys.c~find_user-locking Wed Apr 28 13:58:42 2004
+++ 25-akpm/kernel/sys.c Wed Apr 28 13:59:54 2004
@@ -348,6 +348,8 @@ asmlinkage long sys_setpriority(int whic
if (p->uid == who)
error = set_one_prio(p, niceval, error);
while_each_thread(g, p);
+ if (who)
+ free_uid(user); /* For find_user() */
break;
}
out_unlock:
@@ -410,6 +412,8 @@ asmlinkage long sys_getpriority(int whic
retval = niceval;
}
while_each_thread(g, p);
+ if (who)
+ free_uid(user); /* for find_user() */
break;
}
out_unlock:
_
next prev parent reply other threads:[~2004-04-28 21:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-19 21:28 Marcelo Tosatti
2004-04-19 22:49 ` Jakub Jelinek
2004-04-20 14:13 ` Marcelo Tosatti
2004-04-20 18:05 ` Manfred Spraul
2004-04-20 20:04 ` Andrew Morton
2004-04-20 23:13 ` Marcelo Tosatti
2004-04-20 23:34 ` Andrew Morton
2004-04-21 20:34 ` Marcelo Tosatti
2004-04-22 5:33 ` Manfred Spraul
2004-04-27 14:54 ` Marcelo Tosatti
2004-04-27 18:09 ` Manfred Spraul
2004-04-28 17:09 ` Marcelo Tosatti
2004-04-28 21:03 ` Andrew Morton [this message]
2004-04-29 1:33 ` Chris Wright
2004-04-29 12:17 ` Marcelo Tosatti
2004-04-29 19:58 ` Chris Wright
2004-05-06 0:08 ` Chris Wright
2004-05-06 12:09 ` Marcelo Tosatti
2004-05-06 12:32 ` Marcelo Tosatti
2004-05-07 0:56 ` Chris Wright
2004-04-19 22:59 ` Andrew Morton
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=20040428140316.4146b3bd.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=jakub@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=marcelo.tosatti@cyclades.com \
--cc=mingo@elte.hu \
/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®