libata: clear PIO pad area
PATCH 1/1 libata: clear PIO pad area
ata_sff_data_xfer[32]() use pad area if the transfer size isn't multiple of transfer size; however, this area wasn't cleared and garbage data in pad area could be transferred to the device. Make sure the pad area is cleared.
--- drivers/ata/libata-sff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-sff.c +2 -2
@@ -569,7 +569,7 @@ unsigned int ata_sff_data_xfer(struct ata_device *dev, unsigned char *buf,/* Transfer trailing byte, if any. */ if (unlikely (buflen &0x01 )) { -unsigned char pad[2 ]; +unsigned char pad[2 ] = { };/* Point buf to the tail of buffer */ buf += buflen -1 ;
@@ -628,7 +628,7 @@ unsigned int ata_sff_data_xfer32(struct ata_device *dev, unsigned char *buf,/* Transfer trailing bytes, if any */ if (unlikely (slop)) { -unsigned char pad[4 ]; +unsigned char pad[4 ] = { };/* Point buf to the tail of buffer */ buf += buflen - slop;
Hello.
Quoted 7 lines · Tejun Heo
ata_sff_data_xfer[32]() use pad area if the transfer size isn't multiple of transfer size; however, this area wasn't cleared and garbage data in pad area could be transferred to the device. Make sure the pad area is cleared.
Signed-off-by Tejun Heo<[email protected]>Cc Lei Ming<[email protected]>
And what's the problem with garbage data? Why it's worse than 0s?
WBR, Sergei
Quoted 9 lines · On Tue, 06 Sep 2011 14:06:23 +0400 Sergei Shtylyov <[email protected]> wrote:
Hello.
Quoted 4 lines · Tejun Heo
ata_sff_data_xfer[32]() use pad area if the transfer size isn't multiple of transfer size; however, this area wasn't cleared and garbage data in pad area could be transferred to the device. Make sure the pad area is cleared.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Tejun Heo<[email protected]>Cc Lei Ming<[email protected]>And what's the problem with garbage data? Why it's worse than 0s?
It's potentially externally observable on things like an eSATA port so it probably should be cleared just as we do with network padding.
For the CDB case we clear the rest of the CDB anyway I believe because some old PATA stuff used to freak if the padding wasn't zero.
Hello,
Quoted 11 lines · Sergei Shtylyov
Quoted 7 lines · Tejun Heo
ata_sff_data_xfer[32]() use pad area if the transfer size isn't multiple of transfer size; however, this area wasn't cleared and garbage data in pad area could be transferred to the device. Make sure the pad area is cleared.
Signed-off-by Tejun Heo<[email protected]>Cc Lei Ming<[email protected]>And what's the problem with garbage data? Why it's worse than 0s?
There were devices which puke on random garbage at the end of CDB and in general sending indeterministic garbage to external device is a bad idea. It increases chance of problems which can be difficult to reproduce and track down while gaining nothing. It really is a stupid thing to do.
Thanks.
Signature · 1 line
tejun
Hello.
Quoted 11 lines · Tejun Heo
Quoted 9 lines
Quoted 7 lines
ata_sff_data_xfer[32]() use pad area if the transfer size isn't multiple of transfer size; however, this area wasn't cleared and garbage data in pad area could be transferred to the device. Make sure the pad area is cleared.
Signed-off-by Tejun Heo<[email protected]>Cc Lei Ming<[email protected]>And what's the problem with garbage data? Why it's worse than 0s?
There were devices which puke on random garbage at the end of CDB and
Note that ATAPI CDBs are always aligned to 4 bytes, so this path should
never be hit when sending them.
Quoted 3 lines
in general sending indeterministic garbage to external device is a bad idea. It increases chance of problems which can be difficult to reproduce and track down while gaining nothing.
Problems with "don't care" padding bytes? Dunno...
Quoted 1 line
It really is a stupid thing to do.
Well, at least the old code was equally stupid before I patched it. :-)
Quoted 1 line
Thanks.
WBR, Sergei
Hello.
Quoted 19 lines · Sergei Shtylyov
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
ata_sff_data_xfer[32]() use pad area if the transfer size isn't multiple of transfer size; however, this area wasn't cleared and garbage data in pad area could be transferred to the device. Make sure the pad area is cleared.
Signed-off-by Tejun Heo<[email protected]>Cc Lei Ming<[email protected]>And what's the problem with garbage data? Why it's worse than 0s?
There were devices which puke on random garbage at the end of CDB and
Note that ATAPI CDBs are always aligned to 4 bytes, so this path should never be hit when sending them.
Quoted 3 lines
in general sending indeterministic garbage to external device is a bad idea. It increases chance of problems which can be difficult to reproduce and track down while gaining nothing.
Quoted 5 lines
Problems with "don't care" padding bytes? Dunno...
Quoted 1 line
It really is a stupid thing to do.
Well, at least the old code was equally stupid before I patched it. :-)
Only in ata_sff_data_xfer32(). It was I who removed the padding buffer
initialization in ata_sff_data_xfer()...
Quoted 1 line
Quoted 1 line
Thanks.
WBR, Sergei
Quoted 4 lines · Sergei Shtylyov
Quoted 1 line
There were devices which puke on random garbage at the end of CDB and
Note that ATAPI CDBs are always aligned to 4 bytes, so this path
should never be hit when sending them.
Ah, okay, but still, let's just clear it. There's nothing to be gained by not clearing several bytes there.
Quoted 5 lines
Quoted 3 lines
in general sending indeterministic garbage to external device is a bad idea. It increases chance of problems which can be difficult to reproduce and track down while gaining nothing.
Problems with "don't care" padding bytes? Dunno...
Oh yeah, IIRC there were multiple devices which puked on "don't care" garbage bytes in CDB. Don't underestimate the crappiness of cheap ATAPI devices. :)
Thanks.
Signature · 1 line
tejun