kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Some question about "security context of a task"
@ 2012-02-01  7:12 loody
  2012-02-01 15:12 ` Mulyadi Santosa
  0 siblings, 1 reply; 3+ messages in thread
From: loody @ 2012-02-01  7:12 UTC (permalink / raw)
  To: kernelnewbies

hi all:
I found there is a user_struct, user, located at struct cred.
is it possible be null?
My platform sometimes panic when using kernel_thread to creating a
thread for running.

below is the place it happen

if (atomic_read(&p->real_cred->user->processes) >=
             p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
after checking the parameter, I found p->real_cred->user is NULL.

When and how we allocate/destroy this parameter?
Does that mean we should some basic check before calling kernel_thread?

-- 
Regards,

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

* Some question about "security context of a task"
  2012-02-01  7:12 Some question about "security context of a task" loody
@ 2012-02-01 15:12 ` Mulyadi Santosa
  2012-02-01 16:24   ` loody
  0 siblings, 1 reply; 3+ messages in thread
From: Mulyadi Santosa @ 2012-02-01 15:12 UTC (permalink / raw)
  To: kernelnewbies

Hi....

On Wed, Feb 1, 2012 at 14:12, loody <miloody@gmail.com> wrote:
> below is the place it happen
>
> if (atomic_read(&p->real_cred->user->processes) >=
> ? ? ? ? ? ? p->signal->rlim[RLIMIT_NPROC].rlim_cur) {

Seems like a normal user limit checking...the one we usually set via
"ulimit" command. Checking number of processes to be precise...

> after checking the parameter, I found p->real_cred->user is NULL.

hm, IMHO if it exceeds ulimit, the process creation should just stop.
Not sure why read_cred->user becomes NULL. Maybe that's for clean up,
since later process will be terminated?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

* Some question about "security context of a task"
  2012-02-01 15:12 ` Mulyadi Santosa
@ 2012-02-01 16:24   ` loody
  0 siblings, 0 replies; 3+ messages in thread
From: loody @ 2012-02-01 16:24 UTC (permalink / raw)
  To: kernelnewbies

hi Mulyadi:

2012/2/1 Mulyadi Santosa <mulyadi.santosa@gmail.com>:
> Hi....
>
> On Wed, Feb 1, 2012 at 14:12, loody <miloody@gmail.com> wrote:
>> below is the place it happen
>>
>> if (atomic_read(&p->real_cred->user->processes) >=
>> ? ? ? ? ? ? p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
>
> Seems like a normal user limit checking...the one we usually set via
> "ulimit" command. Checking number of processes to be precise...
>
>> after checking the parameter, I found p->real_cred->user is NULL.
>
> hm, IMHO if it exceeds ulimit, the process creation should just stop.
Yes, I think you are right.

> Not sure why read_cred->user becomes NULL. Maybe that's for clean up,
> since later process will be terminated?

The "later process" you mean is the caller?
please let me describe my environment more detail.
1. when outside event happen
2. calling driver's probe.
3. I use kernel_thread to create a thread in probe function.
Then the sequence seems like:
kernel_thread
  -> do_fork
  -> copy_process
  ..........
  p = dup_task_struct(current);
  /*The user_struct user is inherited from current.*/
  ...........
if (atomic_read(&p->real_cred->user->processes) >=
 ? ? ? ? ? ? p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
.......

Then it panic.
1. why kernel thread need user_struct
2. is it use for kernel thread to record how may user mode program it created?

Thanks for your help,

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

end of thread, other threads:[~2012-02-01 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01  7:12 Some question about "security context of a task" loody
2012-02-01 15:12 ` Mulyadi Santosa
2012-02-01 16:24   ` loody

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).