Skip to content

Commit

Permalink
MFC r342787:
Browse files Browse the repository at this point in the history
Add a bounds check to the tws(4) passthrough ioctl handler.

admbug:		825
  • Loading branch information
markjdb committed Jan 12, 2019
1 parent c22e1d4 commit 5a40494
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sys/dev/tws/tws_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ tws_passthru(struct tws_softc *sc, void *buf)
struct tws_request *req;
struct tws_ioctl_no_data_buf *ubuf = (struct tws_ioctl_no_data_buf *)buf;
int error;
u_int32_t buffer_length;
u_int16_t lun4;


buffer_length = roundup2(ubuf->driver_pkt.buffer_length, 512);
if ( buffer_length > TWS_MAX_IO_SIZE ) {
return(EINVAL);
}
if ( tws_get_state(sc) != TWS_ONLINE) {
return(EBUSY);
}
Expand All @@ -116,7 +120,7 @@ tws_passthru(struct tws_softc *sc, void *buf)
}
} while(1);

req->length = (ubuf->driver_pkt.buffer_length + 511) & ~511;
req->length = buffer_length;
TWS_TRACE_DEBUG(sc, "datal,rid", req->length, req->request_id);
if ( req->length ) {
req->data = sc->ioctl_data_mem;
Expand Down

0 comments on commit 5a40494

Please sign in to comment.