PDA

View Full Version : Issues with cloop driver



kuser123
09-14-2004, 11:44 AM
I'm running Knoppix 3.6 on my laptop with Celeron P4 CPU.
I have compiled and installed the vanilla kernel 2.6.7 for this CPU. Then I have downloaded and compiled the cloop driver (source from www.knoppix.net) and loaded the driver with the original compressed KNOPPIX image. Then I tried to mount /dev/cloop which lead into a kernel oops (NULL pointer access). I have debugged the driver and found out that bvec (in function make_clo_request at line 362)

struct bio_vec *bvec=&bio->bi_io_vec[vecnr];

has an illegal value (0x00000001)! The weird thing is that this problem only occurs on my notebook. On my desktop PC (CPU is Athlon XP) the driver works fine. Maybe there is a problem with gcc.
I've added some lines to the driver to avoid a kernel oops. Ok, the driver still doesn't work, but for stability and security issues pointers should be checked for a valid value.
Here is the code (inserted after line 362:

if ((void *)bvec < (void *)0x80000000) {
printk(KERN_ERR "do_clo_request: bio->bi_io_vec[%i] has illegal value %p\n", vecnr, bvec);
break;
}

I don't know if the value 0x80000000 is a good choice. On Intel systems I think it is good. But there may be a better solution.
Wouldn't it be good to implement some pointer checking code?