Skip to contentSkip to conversation

attempt to access beyond end of device

DISCUSSION Jan Niehusmann 3 participants 3 messages Dec 7, 2000

lore
Share & tools
lore
#0 lore raw

ll_rw_blk.c: generic_make_request() contains the following code:

if (maxsector < count || maxsector - count < sector) {
	bh->b_state &= (1 << BH_Lock) | (1 << BH_Mapped);
	if (blk_size[major][MINOR(bh->b_rdev)]) {

		/* This may well happen - the kernel calls bread()
		   without checking the size of the device, e.g.,
		   when mounting a device. */
		printk(KERN_INFO
		       "attempt to access beyond end of device\n");
		printk(KERN_INFO "%s: rw=%d, want=%d, limit=%d\n",
		       kdevname(bh->b_rdev), rw,
		       (sector + count)>>1,
		       blk_size[major][MINOR(bh->b_rdev)]);
	}
	bh->b_end_io(bh, 0);
	return;
}

That means that if blk_size[major][MINOR(bh->b_rdev)] == 0, the request is canceled but no message is printed. Shouldn't there be a warning message?

Jan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 21 lines · Jan Niehusmann

ll_rw_blk.c: generic_make_request() contains the following code:

if (maxsector < count || maxsector - count < sector) {
	bh->b_state &= (1 << BH_Lock) | (1 << BH_Mapped);
	if (blk_size[major][MINOR(bh->b_rdev)]) {

		/* This may well happen - the kernel calls bread()
		   without checking the size of the device, e.g.,
		   when mounting a device. */
		printk(KERN_INFO
		       "attempt to access beyond end of device\n");
		printk(KERN_INFO "%s: rw=%d, want=%d, limit=%d\n",
		       kdevname(bh->b_rdev), rw,
		       (sector + count)>>1,
		       blk_size[major][MINOR(bh->b_rdev)]);
	}
	bh->b_end_io(bh, 0);
	return;
}
Quoted 2 lines

That means that if blk_size[major][MINOR(bh->b_rdev)] == 0, the request is canceled but no message is printed. Shouldn't there be a warning message?

Maybe that code fragment is mine. If so, then at some point in time I decided that the answer to your question is no.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Jan Niehusmann
Quoted 6 lines · Andries Brouwer
Quoted 2 lines · Jan Niehusmann

That means that if blk_size[major][MINOR(bh->b_rdev)] == 0, the request is canceled but no message is printed. Shouldn't there be a warning message?

Maybe that code fragment is mine. If so, then at some point in time I decided that the answer to your question is no.

As a potential real-world case (but possibly unrelated), I had an
interesting situation crop-up while I was playing with the loopback filesystems.

If you just use the program-tools, you end up with a situation like:

losetup <blah> [close all] dd <blah> [close all] losetup -d [blah]

In my case, I was making a standalone program that did it all in one
program and I messed up in the ordering of the close() and the LOOP_CLR_FD.

I'm pretty sure that (with my small 10K test dataset) the I/O between
the loopback device and the looped file was never hitting the disk. If I LOOP_CLR_FD before I closed, I ended up with bad data in the looped file and kernel errors syslogged:

	kernel: attempt to access beyond end of device
	kernel: 07:00: rw=1, want=1, limit=0
	kernel: dev 07:00 blksize=0 blocknr=0 sector=0 size=1024 count=1

I tended to get 10 of those, one for each of the 10 1K blocks in
my test dataset.

Doing the close() then the LOOP_CLR_FD got rid of the errors.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/