Skip to content

Commit

Permalink
scsi: esas2r: Use flex array destination for memcpy()
Browse files Browse the repository at this point in the history
In preparation for FORTIFY_SOURCE performing run-time destination buffer
bounds checking for memcpy(), specify the destination output buffer
explicitly, instead of asking memcpy() to write past the end of what looked
like a fixed-size object. Silences future run-time warning:

  memcpy: detected field-spanning write (size 80) of single field "trc + 1" (size 64)

There is no binary code output differences from this change.

Link: https://lore.kernel.org/r/20220901205729.2260982-1-keescook@chromium.org
Cc: Bradley Grove <linuxdrivers@attotech.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Kees Cook authored and Martin K. Petersen committed Sep 7, 2022
1 parent 7eff437 commit 1ce871d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions drivers/scsi/esas2r/atioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ struct __packed atto_hba_trace {
u32 total_length;
u32 trace_mask;
u8 reserved2[48];
u8 contents[];
};

#define ATTO_FUNC_SCSI_PASS_THRU 0x04
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/esas2r/esas2r_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,9 @@ static int hba_ioctl_callback(struct esas2r_adapter *a,
break;
}

memcpy(trc + 1,
memcpy(trc->contents,
a->fw_coredump_buff + offset,
len);

hi->data_length = len;
} else if (trc->trace_func == ATTO_TRC_TF_RESET) {
memset(a->fw_coredump_buff, 0,
Expand Down

0 comments on commit 1ce871d

Please sign in to comment.