How to determine the value of 'current' is valid or not?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

I'm developing a small patch in fs/*.c that needs to refer
'(struct task_struct *) current'. And I want to know whether
the value of 'current' is valid or not.

According to 'Unreliable Guide To Hacking The Linux Kernel',
there are 4 players.

(1) not associated with any process, serving a hardware interrupt;
(2) not associated with any process, serving a softirq, tasklet or bh;
(3) running in kernel space, associated with a process;
(4) running a process in user space.

And also says, "value of 'current' is not NULL in interrupt context".
I think it means in the state (1) or (2), I must not refer to 'current',
but I can't determine the state by checking 'current' == NULL.

I don't know whether functions defined in fs/*.c is called
by the players (1) and (2).
But if these functions could be called by (1) and (2),
I need to confirm whether I can refer to 'current' or not.

How can I determine the value of 'current' is valid or not
(if these functions could be called by (1) and (2)) ?

I want to know 'current' is valid or not
even when interrupts or bottom halves are disabled
outside of my patch functions,
so it is not enough just checking "in_interrupt() returns 0".

Regards.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux