hardware support

2012-09-13 Thread Littlefield, Tyler
hello all:
I had a question. I get an address mmio error when  I try to boot my 
debian box, along with this: INIT_I2C_LONG_IF
I'm curious of something. I have an 8-core AMD zambesi, is there support 
for this yet? I also have channel interleaving turned on (we can't 
really get it off), is this also something Linux would have issues with?

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


RE: kernel stack memory

2012-09-13 Thread 卜弋天

i don't know why you want to corrupt kernel stack by using this method, stack 
usually grow from high address to low address, if you allocate a buff in a 
function then use memset(), it is writing data from low address to high 
address.in your implementation, you allocate an array with 8000*4=32000 bytes ( 
int arr[8000]; ), then you try to corrupt stack by using memset(), which 
operate memory by bytes, rather than by int. so this memset() only corrupt the 
first 8192 bytes of the buffer, which is far away from your current task stack. 
   thread_info locates at the bottom of current task's stack, please 
reference the source code of current_thread_info() function of your platform. i 
think it is true for X86 or ARM.   if you really want to corrupt current 
kernel task's stack, please try below code, i did't test it but i think it 
should work, at least you can find something from the log:  char *sp_addr;
 struct thread_info *thread = current_thread_info(); sp_addr = (char*)thread;
 
 printk("sp_addr==thread:%p, task:%p\n", thread, thread->task);
 
 memset (sp_addr, 0x0, 1024);
 
 printk("after corrupt, task:%p, it is dying...\n", thread->task);

 > Date: Thu, 13 Sep 2012 15:32:05 +0530
> Subject: Re: kernel stack memory
> From: mujeeb.a...@gmail.com
> To: getaru...@gmail.com
> CC: shubham20...@gmail.com; kernelnewbies@kernelnewbies.org
> 
> Hi,
> 
> On Thu, Sep 13, 2012 at 1:59 PM, Arun KS  wrote:
> > Hello Shubham,
> >
> > On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma 
> > wrote:
> >>
> >> Hi,
> >>
> >> As far as i know, the size of stack allocated in the kernel space is
> >> 8Kb for each process. But in case i use more than 8Kb of memory from
> >> the stack then what will happen? I think that in that case the system
> >> would crash because i am accessing an illegal memory area. I wrote
> >> kernel module in which i defined an integer array whose size was 8000.
> >> But still it did not crash my system. Why?
> >>
> >> The module i wrote was as follows:
> >>
> >> #include 
> >> #include 
> >>
> >> int __init init_my_module(void)
> >> {
> >> int arr[8000];
> >> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
> >> arr[1] = 1;
> >> arr[4000] = 1;
> >> arr[7999] = 1;
> >
> > Instead do a memset.
> > memset(arr, 0, 8192);
> >
> > If you do this the current calling process thread_info will be set to zero.
> > This should cause a crash.
> 
> I tried and this is also not causing any crash.
> 
> Thanks,
> Adil
> >
> > Thanks,
> > Arun
> >
> >
> >>
> >> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n", __func__,
> >> __LINE__, arr[1], arr[4000], arr[7999]);
> >> return 0;
> >> }
> >>
> >> void __exit cleanup_my_module(void)
> >> {
> >> printk("exiting\n");
> >> return;
> >> }
> >>
> >> module_init(init_my_module);
> >> module_exit(cleanup_my_module);
> >>
> >> MODULE_LICENSE("GPL");
> >>
> >> ___
> >> Kernelnewbies mailing list
> >> Kernelnewbies@kernelnewbies.org
> >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> >
> >
> > ___
> > Kernelnewbies mailing list
> > Kernelnewbies@kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
  ___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Mult core cpus - SMP

2012-09-13 Thread anish kumar
On Thu, 2012-09-13 at 15:33 +0400, Denis Kirjanov wrote:
Hello Denis,

Don't top post!!
> Yes, for example IBM 970MP CPU:
> 
> • Dual processors on a single chip
> – Each processor has its own dedicated storage subsystem, including a
> 1 MB L2 cache per core.
> – Each processor has its own dedicated resets, external interrupt,
> thermal diode, and voltage plane
> (common logic is powered on).
> – Common logic provides arbitration for bus access between the two cores.
> – A single external interface allows a companion chip with a single
> interface to support two processors.
> 
> On 9/13/12, Kshemendra KP  wrote:
> > Hi,
> >
> > Does  multi core CPU act like SMP system.
Preemption will effectively turn a UniProcessor system into an effective
SMP system.
> >
> > Regards
> >
> > Kshemendra
> >
> 
> 



___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Ashish Sangwan
Enable this CONFIG_CC_STACKPROTECTOR and you will get crash.
Stack overflow does'nt necessarily creates kernel panic ;)

On Thu, Sep 13, 2012 at 5:00 PM, Denis Kirjanov  wrote:
> At the moment of forking a new process do_fork() creates a new stack for the
> task by using alloc_thread_info_node():
>
> struct page *page = alloc_pages_node(node, THREADINFO_GFP,
>  THREAD_SIZE_ORDER);
>
>
> On 9/13/12, Rajat Sharma  wrote:
>> "The kernel stack is part of task_struct of the running process"
>>
>> Please double check that, its not part of task_struct, rather on some
>> architectures, kernel stack is extended by a thread_info structure at
>> the end which keeps a link to task_struct of the process.
>>
>> -Rajat
>>
>> On Thu, Sep 13, 2012 at 1:59 PM, Arun KS  wrote:
>>> Hello Shubham,
>>>
>>> On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma 
>>> wrote:

 Hi,

 As far as i know, the size of stack allocated in the kernel space is
 8Kb for each process. But in case i use more than 8Kb of memory from
 the stack then what will happen? I think that in that case the system
 would crash because i am accessing an illegal memory area. I wrote
 kernel module in which i defined an integer array whose size was 8000.
 But still it did not crash my system. Why?

 The module i wrote was as follows:

 #include 
 #include 

 int __init init_my_module(void)
 {
 int arr[8000];
 printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
 arr[1] = 1;
 arr[4000] = 1;
 arr[7999] = 1;
>>>
>>> Instead do a memset.
>>> memset(arr, 0, 8192);
>>>
>>> If you do this the current calling process thread_info will be set to
>>> zero.
>>> This should cause a crash.
>>>
>>> Thanks,
>>> Arun
>>>
>>>

 printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n",
 __func__,
 __LINE__, arr[1], arr[4000], arr[7999]);
 return 0;
 }

 void __exit cleanup_my_module(void)
 {
 printk("exiting\n");
 return;
 }

 module_init(init_my_module);
 module_exit(cleanup_my_module);

 MODULE_LICENSE("GPL");

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>
>>>
>>>
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
>
> --
> Regards,
> Denis
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Mult core cpus - SMP

2012-09-13 Thread Denis Kirjanov
Yes, for example IBM 970MP CPU:

• Dual processors on a single chip
– Each processor has its own dedicated storage subsystem, including a
1 MB L2 cache per core.
– Each processor has its own dedicated resets, external interrupt,
thermal diode, and voltage plane
(common logic is powered on).
– Common logic provides arbitration for bus access between the two cores.
– A single external interface allows a companion chip with a single
interface to support two processors.

On 9/13/12, Kshemendra KP  wrote:
> Hi,
>
> Does  multi core CPU act like SMP system.
>
> Regards
>
> Kshemendra
>


-- 
Regards,
Denis

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Denis Kirjanov
At the moment of forking a new process do_fork() creates a new stack for the
task by using alloc_thread_info_node():

struct page *page = alloc_pages_node(node, THREADINFO_GFP,
 THREAD_SIZE_ORDER);


On 9/13/12, Rajat Sharma  wrote:
> "The kernel stack is part of task_struct of the running process"
>
> Please double check that, its not part of task_struct, rather on some
> architectures, kernel stack is extended by a thread_info structure at
> the end which keeps a link to task_struct of the process.
>
> -Rajat
>
> On Thu, Sep 13, 2012 at 1:59 PM, Arun KS  wrote:
>> Hello Shubham,
>>
>> On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma 
>> wrote:
>>>
>>> Hi,
>>>
>>> As far as i know, the size of stack allocated in the kernel space is
>>> 8Kb for each process. But in case i use more than 8Kb of memory from
>>> the stack then what will happen? I think that in that case the system
>>> would crash because i am accessing an illegal memory area. I wrote
>>> kernel module in which i defined an integer array whose size was 8000.
>>> But still it did not crash my system. Why?
>>>
>>> The module i wrote was as follows:
>>>
>>> #include 
>>> #include 
>>>
>>> int __init init_my_module(void)
>>> {
>>> int arr[8000];
>>> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
>>> arr[1] = 1;
>>> arr[4000] = 1;
>>> arr[7999] = 1;
>>
>> Instead do a memset.
>> memset(arr, 0, 8192);
>>
>> If you do this the current calling process thread_info will be set to
>> zero.
>> This should cause a crash.
>>
>> Thanks,
>> Arun
>>
>>
>>>
>>> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n",
>>> __func__,
>>> __LINE__, arr[1], arr[4000], arr[7999]);
>>> return 0;
>>> }
>>>
>>> void __exit cleanup_my_module(void)
>>> {
>>> printk("exiting\n");
>>> return;
>>> }
>>>
>>> module_init(init_my_module);
>>> module_exit(cleanup_my_module);
>>>
>>> MODULE_LICENSE("GPL");
>>>
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>


-- 
Regards,
Denis

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Mult core cpus - SMP

2012-09-13 Thread Kshemendra KP
Hi,

Does  multi core CPU act like SMP system.

Regards

Kshemendra
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Adil Mujeeb
Hi,

On Thu, Sep 13, 2012 at 1:59 PM, Arun KS  wrote:
> Hello Shubham,
>
> On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma 
> wrote:
>>
>> Hi,
>>
>> As far as i know, the size of stack allocated in the kernel space is
>> 8Kb for each process. But in case i use more than 8Kb of memory from
>> the stack then what will happen? I think that in that case the system
>> would crash because i am accessing an illegal memory area. I wrote
>> kernel module in which i defined an integer array whose size was 8000.
>> But still it did not crash my system. Why?
>>
>> The module i wrote was as follows:
>>
>> #include 
>> #include 
>>
>> int __init init_my_module(void)
>> {
>> int arr[8000];
>> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
>> arr[1] = 1;
>> arr[4000] = 1;
>> arr[7999] = 1;
>
> Instead do a memset.
> memset(arr, 0, 8192);
>
> If you do this the current calling process thread_info will be set to zero.
> This should cause a crash.

I tried and this is also not causing any crash.

Thanks,
Adil
>
> Thanks,
> Arun
>
>
>>
>> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n", __func__,
>> __LINE__, arr[1], arr[4000], arr[7999]);
>> return 0;
>> }
>>
>> void __exit cleanup_my_module(void)
>> {
>> printk("exiting\n");
>> return;
>> }
>>
>> module_init(init_my_module);
>> module_exit(cleanup_my_module);
>>
>> MODULE_LICENSE("GPL");
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Rajat Sharma
"The kernel stack is part of task_struct of the running process"

Please double check that, its not part of task_struct, rather on some
architectures, kernel stack is extended by a thread_info structure at
the end which keeps a link to task_struct of the process.

-Rajat

On Thu, Sep 13, 2012 at 1:59 PM, Arun KS  wrote:
> Hello Shubham,
>
> On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma 
> wrote:
>>
>> Hi,
>>
>> As far as i know, the size of stack allocated in the kernel space is
>> 8Kb for each process. But in case i use more than 8Kb of memory from
>> the stack then what will happen? I think that in that case the system
>> would crash because i am accessing an illegal memory area. I wrote
>> kernel module in which i defined an integer array whose size was 8000.
>> But still it did not crash my system. Why?
>>
>> The module i wrote was as follows:
>>
>> #include 
>> #include 
>>
>> int __init init_my_module(void)
>> {
>> int arr[8000];
>> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
>> arr[1] = 1;
>> arr[4000] = 1;
>> arr[7999] = 1;
>
> Instead do a memset.
> memset(arr, 0, 8192);
>
> If you do this the current calling process thread_info will be set to zero.
> This should cause a crash.
>
> Thanks,
> Arun
>
>
>>
>> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n", __func__,
>> __LINE__, arr[1], arr[4000], arr[7999]);
>> return 0;
>> }
>>
>> void __exit cleanup_my_module(void)
>> {
>> printk("exiting\n");
>> return;
>> }
>>
>> module_init(init_my_module);
>> module_exit(cleanup_my_module);
>>
>> MODULE_LICENSE("GPL");
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


getxattr field not initialized when trying to execute /init during boot

2012-09-13 Thread stl
Hello all,
I am facing a problem when trying to boot linux 2.6.37 on a new
architecture.

At the end of the boot, it tries to launch /init by executing a sys_execve()

Here is the what it does:

sys_execve()
  |-> do_execve()
 |-> prepare_binprm()
 |->security_bprm_set_creds()
|->cap_bprm_set_creds()
 |->get_file_caps()
   |->get_vfs_caps_from_disk()


In the get_vfs_caps_from_disk(), these is a verification to know if
inode->i_op->getxattr
has been initialized.

In my case, it returns and error value, because this field is not
initialized.

So I am wondering by who and where this field is initialized?
And what is the aim of getxattr?

Thanks in advance!
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Arun KS
Hello Shubham,

On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma wrote:

> Hi,
>
> As far as i know, the size of stack allocated in the kernel space is
> 8Kb for each process. But in case i use more than 8Kb of memory from
> the stack then what will happen? I think that in that case the system
> would crash because i am accessing an illegal memory area. I wrote
> kernel module in which i defined an integer array whose size was 8000.
> But still it did not crash my system. Why?
>
> The module i wrote was as follows:
>
> #include 
> #include 
>
> int __init init_my_module(void)
> {
> int arr[8000];
> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
> arr[1] = 1;
> arr[4000] = 1;
> arr[7999] = 1;
>
Instead do a memset.
memset(arr, 0, 8192);

If you do this the current calling process thread_info will be set to zero.
This should cause a crash.

Thanks,
Arun



> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n", __func__,
> __LINE__, arr[1], arr[4000], arr[7999]);
> return 0;
> }
>
> void __exit cleanup_my_module(void)
> {
> printk("exiting\n");
> return;
> }
>
> module_init(init_my_module);
> module_exit(cleanup_my_module);
>
> MODULE_LICENSE("GPL");
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Kshemendra KP
Not sure for all the tasks slab is created initailly with contiguous
memory. Slab cache
is shrinked when the system is low on memory.

If the memory is contiguous wriring few bytes after the kernel stack may
corrupt a task_struct
of other task and  it may for eg. corrupt the linked list element resuling
in a crash. If it is not
contiguous, then it may corrupt some other data. If the data is crucial
like link or based on
the value some decision is taken then it will crash.  If some statistics
field is overwritten
it may not impact the system stability.





On Thu, Sep 13, 2012 at 12:42 PM, shubham sharma wrote:

> Hi,
>
> On Thu, Sep 13, 2012 at 12:29 PM, Kshemendra KP
>  wrote:
> >
> > In user space when you write beyond your address space (if your write
> > crosses
> > the page boundary alloacted to you), then process is terminated. In the
> > kernel
> > you are still writinng inside the kernel address space. Your write is not
> > beyond
> > kernel address space.
> >
> > Secondly you are corrupting some other data structure. The kernel stack
> is
> > part
> > of task_struct of the running process, a kmalloc or slab allocator might
> > have
> > provided this memory (task_-struct).  When you write beyond this if the
> > write modiefies some crucial data structure that may result in hang or a
> > crash.
>
> I did a quick calculation on this. The number of slab objects
> allocated for task_struct in my system are 280 and each size of each
> object is 3264
>
> ---8<---
> root@shubh-VirtualBox:~# cat /proc/slabinfo  | grep task_struct
> task_struct  262280   3264   108 : tunables00
>   0 : slabdata 28 28  0
> ---8<---
>
> So if my understanding is correct, in case if i define an array of
> more than 280*3264 bytes then it will corrupt the task_struct of at
> least one significantly important process or at least the task_struct
> of the process for my terminal will get corrupted?
>
> >
> >
> >
> >
> > On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma  >
> > wrote:
> >>
> >> Hi,
> >>
> >> As far as i know, the size of stack allocated in the kernel space is
> >> 8Kb for each process. But in case i use more than 8Kb of memory from
> >> the stack then what will happen? I think that in that case the system
> >> would crash because i am accessing an illegal memory area. I wrote
> >> kernel module in which i defined an integer array whose size was 8000.
> >> But still it did not crash my system. Why?
> >>
> >> The module i wrote was as follows:
> >>
> >> #include 
> >> #include 
> >>
> >> int __init init_my_module(void)
> >> {
> >> int arr[8000];
> >> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
> >> arr[1] = 1;
> >> arr[4000] = 1;
> >> arr[7999] = 1;
> >> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n",
> __func__,
> >> __LINE__, arr[1], arr[4000], arr[7999]);
> >> return 0;
> >> }
> >>
> >> void __exit cleanup_my_module(void)
> >> {
> >> printk("exiting\n");
> >> return;
> >> }
> >>
> >> module_init(init_my_module);
> >> module_exit(cleanup_my_module);
> >>
> >> MODULE_LICENSE("GPL");
> >>
> >> ___
> >> Kernelnewbies mailing list
> >> Kernelnewbies@kernelnewbies.org
> >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> >
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread shubham sharma
Hi,

On Thu, Sep 13, 2012 at 12:29 PM, Kshemendra KP
 wrote:
>
> In user space when you write beyond your address space (if your write
> crosses
> the page boundary alloacted to you), then process is terminated. In the
> kernel
> you are still writinng inside the kernel address space. Your write is not
> beyond
> kernel address space.
>
> Secondly you are corrupting some other data structure. The kernel stack is
> part
> of task_struct of the running process, a kmalloc or slab allocator might
> have
> provided this memory (task_-struct).  When you write beyond this if the
> write modiefies some crucial data structure that may result in hang or a
> crash.

I did a quick calculation on this. The number of slab objects
allocated for task_struct in my system are 280 and each size of each
object is 3264

---8<---
root@shubh-VirtualBox:~# cat /proc/slabinfo  | grep task_struct
task_struct  262280   3264   108 : tunables00
  0 : slabdata 28 28  0
---8<---

So if my understanding is correct, in case if i define an array of
more than 280*3264 bytes then it will corrupt the task_struct of at
least one significantly important process or at least the task_struct
of the process for my terminal will get corrupted?

>
>
>
>
> On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma 
> wrote:
>>
>> Hi,
>>
>> As far as i know, the size of stack allocated in the kernel space is
>> 8Kb for each process. But in case i use more than 8Kb of memory from
>> the stack then what will happen? I think that in that case the system
>> would crash because i am accessing an illegal memory area. I wrote
>> kernel module in which i defined an integer array whose size was 8000.
>> But still it did not crash my system. Why?
>>
>> The module i wrote was as follows:
>>
>> #include 
>> #include 
>>
>> int __init init_my_module(void)
>> {
>> int arr[8000];
>> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
>> arr[1] = 1;
>> arr[4000] = 1;
>> arr[7999] = 1;
>> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n", __func__,
>> __LINE__, arr[1], arr[4000], arr[7999]);
>> return 0;
>> }
>>
>> void __exit cleanup_my_module(void)
>> {
>> printk("exiting\n");
>> return;
>> }
>>
>> module_init(init_my_module);
>> module_exit(cleanup_my_module);
>>
>> MODULE_LICENSE("GPL");
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: kernel stack memory

2012-09-13 Thread Kshemendra KP
In user space when you write beyond your address space (if your write
crosses
the page boundary alloacted to you), then process is terminated. In the
kernel
you are still writinng inside the kernel address space. Your write is not
beyond
kernel address space.

Secondly you are corrupting some other data structure. The kernel stack is
part
of task_struct of the running process, a kmalloc or slab allocator might
have
provided this memory (task_-struct).  When you write beyond this if the
write modiefies some crucial data structure that may result in hang or a
crash.




On Thu, Sep 13, 2012 at 12:15 PM, shubham sharma wrote:

> Hi,
>
> As far as i know, the size of stack allocated in the kernel space is
> 8Kb for each process. But in case i use more than 8Kb of memory from
> the stack then what will happen? I think that in that case the system
> would crash because i am accessing an illegal memory area. I wrote
> kernel module in which i defined an integer array whose size was 8000.
> But still it did not crash my system. Why?
>
> The module i wrote was as follows:
>
> #include 
> #include 
>
> int __init init_my_module(void)
> {
> int arr[8000];
> printk("%s:%d\tmodule initilized\n", __func__, __LINE__);
> arr[1] = 1;
> arr[4000] = 1;
> arr[7999] = 1;
> printk("%s:%d\tarr[1]:%d, arr[4000]:%d, arr[7999]:%d\n", __func__,
> __LINE__, arr[1], arr[4000], arr[7999]);
> return 0;
> }
>
> void __exit cleanup_my_module(void)
> {
> printk("exiting\n");
> return;
> }
>
> module_init(init_my_module);
> module_exit(cleanup_my_module);
>
> MODULE_LICENSE("GPL");
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies