This commit fixes a sign extension bug affecting l2arc devices. Extremely
large offsets may be passed down to the low level block device driver on
reads, generating errors similar to
attempt to access beyond end of device
sdbi1: rw=14, want=
36028797014862705, limit=
125026959
The unwanted sign extension occurrs because the function arc_read_nolock()
stores the offset as a daddr_t, a 32-bit signed int type in the Linux kernel.
This offset is then passed to zio_read_phys() as a uint64_t argument, causing
sign extension for values of 0x80000000 or greater. To avoid this, we store
the offset in a uint64_t.
This change also changes a few daddr_t struct members to uint64_t in the libspl
headers to avoid similar bugs cropping up in the future. We also add an ASSERT
to __vdev_disk_physio() to check for invalid offsets.
Closes #66
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
*/
#ifdef _SYSCALL32
struct part_info32 {
*/
#ifdef _SYSCALL32
struct part_info32 {
int p_length;
};
#endif /* _SYSCALL32 */
struct part_info {
int p_length;
};
#endif /* _SYSCALL32 */
struct part_info {
* Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I))
*/
struct dk_map {
* Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I))
*/
struct dk_map {
- daddr_t dkl_cylno; /* starting cylinder */
- daddr_t dkl_nblk; /* number of blocks; if == 0, */
+ uint64_t dkl_cylno; /* starting cylinder */
+ uint64_t dkl_nblk; /* number of blocks; if == 0, */
/* partition is undefined */
};
/* partition is undefined */
};
#define VT_EOVERFLOW (-7) /* VTOC op. data struct limited */
struct partition {
#define VT_EOVERFLOW (-7) /* VTOC op. data struct limited */
struct partition {
- ushort_t p_tag; /* ID tag of partition */
- ushort_t p_flag; /* permission flags */
- daddr_t p_start; /* start sector no of partition */
- long p_size; /* # of blocks in partition */
+ ushort_t p_tag; /* ID tag of partition */
+ ushort_t p_flag; /* permission flags */
+ uint64_t p_start; /* start sector no of partition */
+ long p_size; /* # of blocks in partition */
ushort_t p_flag; /* permission flags */
ushort_t p_pad[2];
diskaddr_t p_start; /* start sector no of partition */
ushort_t p_flag; /* permission flags */
ushort_t p_pad[2];
diskaddr_t p_start; /* start sector no of partition */
- diskaddr_t p_size; /* # of blocks in partition */
+ diskaddr_t p_size; /* # of blocks in partition */
for (i = 0; i < V_NUMPAR; i++) { \
v.v_part[i].p_tag = extv.v_part[i].p_tag; \
v.v_part[i].p_flag = extv.v_part[i].p_flag; \
for (i = 0; i < V_NUMPAR; i++) { \
v.v_part[i].p_tag = extv.v_part[i].p_tag; \
v.v_part[i].p_flag = extv.v_part[i].p_flag; \
- v.v_part[i].p_start = (daddr_t)extv.v_part[i].p_start; \
+ v.v_part[i].p_start = (uint64_t)extv.v_part[i].p_start; \
v.v_part[i].p_size = (long)extv.v_part[i].p_size; \
v.timestamp[i] = (time_t)extv.timestamp[i]; \
} \
v.v_part[i].p_size = (long)extv.v_part[i].p_size; \
v.timestamp[i] = (time_t)extv.timestamp[i]; \
} \
uint64_t size = BP_GET_LSIZE(bp);
arc_callback_t *acb;
vdev_t *vd = NULL;
uint64_t size = BP_GET_LSIZE(bp);
arc_callback_t *acb;
vdev_t *vd = NULL;
boolean_t devw = B_FALSE;
if (hdr == NULL) {
boolean_t devw = B_FALSE;
if (hdr == NULL) {
int bio_size, bio_count = 16;
int i = 0, error = 0, block_size;
int bio_size, bio_count = 16;
int i = 0, error = 0, block_size;
+ ASSERT3U(kbuf_offset + kbuf_size, <=, bdev->bd_inode->i_size);
+
retry:
dr = vdev_disk_dio_alloc(bio_count);
if (dr == NULL)
retry:
dr = vdev_disk_dio_alloc(bio_count);
if (dr == NULL)