[dm-devel] [RFC PATCH] dm: Check for device sector overflow if CONFIG_LBDAF is not set

Mikulas Patocka mpatocka at redhat.com
Tue Nov 6 21:44:15 UTC 2018



On Mon, 5 Nov 2018, Milan Broz wrote:

> On 05/11/2018 19:35, Mikulas Patocka wrote:
> > But the condition "sizeof(cc->start) < sizeof(tmpll)" could be dropped, 
> > the compiler will optimize out "cc->start != tmpll" if the types have the 
> > same width.
> 
> Yes, the intention here is that in 64bit env. the whole if condition
> is not compiled in. If it happens without "sizeof(cc->start) < sizeof(tmpll)",
> then we can drop it.
> 
> So, does it make sense to add this to all dm targets? Or any better idea?
> 
> Milan

In the targets that I have written, I tried to protect against this:
	if (sscanf(argv[1], "%llu%c", &start, &dummy) != 1 || start != (sector_t)start)

	ic->provided_data_sectors = le64_to_cpu(ic->sb->provided_data_sectors)
	if (ic->provided_data_sectors != le64_to_cpu(ic->sb->provided_data_sectors)) {

	wc->start_sector = start_sector;
	if (wc->start_sector != start_sector

If you find some more unprotected cases, it's OK to convert them.

Mikulas




More information about the dm-devel mailing list