Re: [PATCH] drivers/scsi/sd.c: fix uninitialized variable in handling medium errors



James Bottomley <James.Bottomley@xxxxxxxxxxxx> wrote:

On Wed, 2006-04-26 at 16:27 -0400, Mark Lord wrote:
From: Mark Lord <lkml@xxxxxx>

I am looking into how SCSI/SATA handle medium (disk) errors,
and the observed behaviour is a little more random than expected,
due to a bug in sd.c.

When scsi_get_sense_info_fld() fails (returns 0), it does NOT update the
value of first_err_block. But sd_rw_intr() merrily continues to use that
variable regardless, possibly making incorrect decisions about retries and the like.

This patch removes the randomness there, by using the first sector of the
request (SCpnt->request->sector) in such cases, instead of first_err_block.

The patch shows more context than usual, to help see what's going on.

Thanks for finding the bug. Your solution is a bit, um, convoluted.
What it should really be doing if we find no valid information field is
a break so we go out with the default good_sectors of zero (rather than
arriving at that value via a circuitous route).

And, of course, I couldn't resist eliminating the superfluous info_valid
variable and tidying the logic to be programmatic instead of a switch
case. How does this work?

It'd be nice to have something simple-and-obvious for the
simple-and-obvious -stable maintainers. That's if we think -stable needs
this fixed.

+ int sector_size_div =
+ 512 / SCpnt->device->sector_size;
+ error_sector /= sector_size_div;

You sure about this bit?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [PATCH] drivers/scsi/sd.c: fix uninitialized variable in handling medium errors
    ... I am looking into how SCSI/SATA handle medium (disk) errors, ... and the observed behaviour is a little more random than expected, ... due to a bug in sd.c. ... The patch shows more context than usual, to help see what's going on. ...
    (Linux-Kernel)
  • Weekly Python Patch/Bug Summary
    ... Patch / Bug Summary ... http://python.org/sf/606098 closed by rhettinger ... http://python.org/sf/1088716 closed by loewis ...
    (comp.lang.python)
  • [Full-Disclosure] RE: [kinda-but-not-really-Full-Disclosure-so-we-feel-warm-and-fuzzy] Re: <to va
    ... Because it must be realised that as soon as a patch and or advisory is ... there are global teams of people working to discover and exploit said bug. ... quiet and MS just released patches for 'undisclosed' problems... ... > engineer a ms patch to find the changed code and produce a working ...
    (Full-Disclosure)
  • RE: Mailslot bug (MS06-035) vs non-Mailslot bug (CVE-2006-3942)
    ... made patch for SRV.SYS. ... vulnerabilities that everyone is so afraid to talk about. ... the mailslot bug, and they didn't have any technical details to turn to, ... So keep on truckin Core Security, Michal Zalewski, and even ...
    (Bugtraq)
  • Re: Cant take skilled talent?
    ... least playing an easier version of the game than everyone else has. ... mind changing or removing the patch if TB emailed me about it. ... -fixing skilled bug is good ... The patch simply stops the monsters from growing too powerful compared to the ...
    (rec.games.roguelike.adom)