Curious code in autostart_array

2006-06-22 Thread Pete Zaitcev
Hi, guys:

My copy of 2.6.17-rc5 has the following code in autostart_array():
mdp_disk_t *desc = sb-disks + i;
dev_t dev = MKDEV(desc-major, desc-minor);

if (!dev)
continue;
if (dev == startdev)
continue;
if (MAJOR(dev) != desc-major || MINOR(dev) != desc-minor)
continue;

Under what conditions do you think the last if() statement can fire?
What is its purpose? This looks like an attempt to detect bit clipping.
But what exactly?

Cheers,
-- Pete
-
To unsubscribe from this list: send the line unsubscribe linux-raid in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Curious code in autostart_array

2006-06-22 Thread H. Peter Anvin

Pete Zaitcev wrote:

Hi, guys:

My copy of 2.6.17-rc5 has the following code in autostart_array():
mdp_disk_t *desc = sb-disks + i;
dev_t dev = MKDEV(desc-major, desc-minor);

if (!dev)
continue;
if (dev == startdev)
continue;
if (MAJOR(dev) != desc-major || MINOR(dev) != desc-minor)
continue;

Under what conditions do you think the last if() statement can fire?
What is its purpose? This looks like an attempt to detect bit clipping.
But what exactly?



It can fire if either desc-major or desc-minor overflow the respective 
fields in dev_t.  Unfortunately, it's not guaranteed to do so.


-hpa
-
To unsubscribe from this list: send the line unsubscribe linux-raid in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Curious code in autostart_array

2006-06-22 Thread Pete Zaitcev
On Fri, 23 Jun 2006 14:46:13 +1000, Neil Brown [EMAIL PROTECTED] wrote:

  dev_t dev = MKDEV(desc-major, desc-minor);
  if (MAJOR(dev) != desc-major || MINOR(dev) != desc-minor)
  continue;

 desc-major and desc-minor have been
 read of the disk, so their values cannot be trusted.

Oh, right. Sorry.

-- Pete
-
To unsubscribe from this list: send the line unsubscribe linux-raid in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html