Re: [PATCH] scsi: fix unintended sign extension on left shifts

From: Bart Van Assche
Date: Mon Oct 14 2019 - 11:58:08 EST


On 10/14/19 5:16 AM, Colin King wrote:
diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c
index 0f17e7dac1b0..1d3a5a2dc229 100644
--- a/drivers/scsi/scsi_trace.c
+++ b/drivers/scsi/scsi_trace.c
@@ -38,7 +38,7 @@ scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)
const char *ret = trace_seq_buffer_ptr(p);
sector_t lba = 0, txlen = 0;
- lba |= (cdb[2] << 24);
+ lba |= ((u64)cdb[2] << 24);
lba |= (cdb[3] << 16);
lba |= (cdb[4] << 8);
lba |= cdb[5];

Have you considered to use get/put_unaligned_be*() instead of making the above change?

Thanks,

Bart.