Slab corruption after unloading a module
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 3 lines
There was no problem if I just load and unload the module. But if I write to the device using "ls >
/dev/temp" and then unload the module, I would get slab corruption.
you return different value as what has really been consumed:
Quoted 10 lines
if (*f_pos + count > MAX_DSIZE)
count1 = MAX_DSIZE - *f_pos;
if (copy_from_user (temp_dev->data+*f_pos, buf, count1)) {
rv = -EFAULT;
goto wrap_up;
}
up (&temp_dev->sem);
*f_pos += count1;
return count;may be it confuses the rest of kernel a bit?
- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQFEQh/JR6LMutpd94wRAgn/AKCapb6QcSSeHn1X7qD1TxLBs2OCSACgnGg7 o7fTn3l6DTnLEr5EwqL7hjk=
=bHLf
-----END PGP SIGNATURE-----
Quoted 18 lines
Quoted 4 lines
There was no problem if I just load and unload the module. But if I write to the device using "ls >
/dev/temp" and then unload the module, I would get slab corruption.you return different value as what has really been consumed:
Quoted 10 lines
if (*f_pos + count > MAX_DSIZE) count1 = MAX_DSIZE - *f_pos; if (copy_from_user (temp_dev->data+*f_pos, buf, count1)) { rv = -EFAULT; goto wrap_up; } up (&temp_dev->sem); *f_pos += count1; return count;
Quoted 1 line
may be it confuses the rest of kernel a bit?
I did this intentionally. Since my baby device buffer is fixed size, I can't overflow the buffer. What I do is to cheat the application (by pretending the bytes requested are copied to the device) so that the application will be happy and do not hang on to send to the device again and again. After all it is a test module for char device. Nevertheless, I don't think this cheating has something to do with the slab corruption.
Quoted 11 lines · zhiyi huang
Quoted 11 lines
Quoted 4 lines
There was no problem if I just load and unload the module. But if I write to the device using "ls >
/dev/temp" and then unload the module, I would get slab corruption.you return different value as what has really been consumed:
Quoted 4 lines
if (*f_pos + count > MAX_DSIZE) count1 = MAX_DSIZE - *f_pos; if (copy_from_user (temp_dev->data+*f_pos, buf, count1)) {
this is still buggy.. what if f_pos is huge???
Quoted 6 lines · zhiyi huang
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
There was no problem if I just load and unload the module. But if I write to the device using "ls >
/dev/temp" and then unload the module, I would get slab corruption.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
you return different value as what has really been consumed:
Quoted 4 lines
if (*f_pos + count > MAX_DSIZE) count1 = MAX_DSIZE - *f_pos; if (copy_from_user (temp_dev->data+*f_pos, buf, count1)) {this is still buggy.. what if
f_posis huge???
Well, if you look at my program, the complete code is like this:
if (*f_pos > MAX_DSIZE)
goto wrap_up;
if (*f_pos + count > MAX_DSIZE)
count1 = MAX_DSIZE - *f_pos;
if (copy_from_user (temp_dev->data+*f_pos, buf, count1)) {