Re: learning proc read write

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

 



Hi all ,
  First of all , I want to thank Daniel and Manoj. I changed my patch based on theirs comments.

On 8/13/06, Keppler Alecrim < alecrim@xxxxxxxxx> wrote:


On 8/12/06, Keppler Alecrim <alecrim@xxxxxxxxx > wrote:
Hi ,
  First of all , thanks for your comments and answer.
I'm gonne study more and implement your sugestions. I'll will send you news soon.

Thanks.


On 8/12/06, Manoj Awasthi <lkml.manoj@xxxxxxxxx> wrote:
Hi Keppler,
 
problem seems like some memory corruption ! see some comments inline. since I too am new to kernel and this group so CMIIW.
 
I was writing a new comand line when the error happened
 
[42949478.160000] Kernel panic - not syncing: Kernel mode fault at addr 0x61202d68, ip 0x400ab0b8
[42949478.160000 ]  [42949478.160000]
 
addr 0x61202d68 does not seem like a kernel address. right ? ( < 3GB)
-    out=kmalloc(200,GFP_KERNEL);

 

+       //max length item -[(char(1 byte) * TASK_COMM_LEN(16 bytes ))+ int max 65535(5 bytes) + <,>\n (5 bytes) ]  = 1 byte + 16 bytes + 5 bytes + 3 bytes = 25 bytes
+       item=kmalloc(25,GFP_KERNEL);
+       //max length out  - nr_processes() * max length item (27 bytes)
+       //about C  - question : /n = 1 byte or 2 bytes ?

better now?


are you sure about 200 bytes of memory ? is it all that you need ? I don't think so.

Yeah , I was not sure about the correct length.

+    item=kmalloc(20,GFP_KERNEL);
+    strcpy(out,"");
+    for_each_process(p)//pointer p will run for all process
+    {
+         if(c->uid == p->uid)//some uid = user identifier
+         {
+            sprintf(item,"< %d , %s  >\n",p->pid,p->comm);//store on task identifier and name on item
+            strcat(out,item); //acumulate item to out
 
here you will die ! since you did not check for memory so an overflow will take place.

+         }
Thanks

--
 
--
Francisco Keppler Silva Alecrim
Instituto Nokia de Tecnologia (INdT) - OSMRC


--
--
Francisco Keppler Silva Alecrim
Instituto Nokia de Tecnologia (INdT) - OSMRC



--
--
Francisco Keppler Silva Alecrim
Instituto Nokia de Tecnologia (INdT) - OSMRC



--
--
Francisco Keppler Silva Alecrim
Instituto Nokia de Tecnologia (INdT) - OSMRC




--
--
Francisco Keppler Silva Alecrim
Instituto Nokia de Tecnologia (INdT) - OSMRC

[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