Re: [PATCH] scsi: fix unintended sign extension on left shifts
From: Christoph Hellwig
Date: Tue Oct 15 2019 - 03:44:36 EST
On Mon, Oct 14, 2019 at 08:58:03AM -0700, Bart Van Assche wrote:
> On 10/14/19 5:16 AM, Colin King wrote:
> > 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?
Agreed, that is the only sensible thing to do here.