Skip to content

Commit

Permalink
improve the input validation of parse_readv_writev_bufs()to better pr…
Browse files Browse the repository at this point in the history
…otect from buffer overflows
  • Loading branch information
ldegio authored and gnosek committed Aug 6, 2019
1 parent 92622e3 commit 55b1cc8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions driver/ppm_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ int32_t parse_readv_writev_bufs(struct event_filler_arguments *args, const struc
{
int32_t res;
const struct iovec *iov;
u32 copylen;
u64 copylen;
u32 j;
u64 size = 0;
unsigned long bufsize;
Expand All @@ -1125,6 +1125,9 @@ int32_t parse_readv_writev_bufs(struct event_filler_arguments *args, const struc

copylen = iovcnt * sizeof(struct iovec);

if (unlikely(iovcnt >= 0xffffffff))
return PPM_FAILURE_BUFFER_FULL;

if (unlikely(copylen >= STR_STORAGE_SIZE))
return PPM_FAILURE_BUFFER_FULL;

Expand Down Expand Up @@ -1245,7 +1248,7 @@ int32_t compat_parse_readv_writev_bufs(struct event_filler_arguments *args, cons
{
int32_t res;
const struct compat_iovec *iov;
u32 copylen;
u64 copylen;
u32 j;
u64 size = 0;
unsigned long bufsize;
Expand All @@ -1258,6 +1261,9 @@ int32_t compat_parse_readv_writev_bufs(struct event_filler_arguments *args, cons

copylen = iovcnt * sizeof(struct compat_iovec);

if (unlikely(iovcnt >= 0xffffffff))
return PPM_FAILURE_BUFFER_FULL;

if (unlikely(copylen >= STR_STORAGE_SIZE))
return PPM_FAILURE_BUFFER_FULL;

Expand Down

0 comments on commit 55b1cc8

Please sign in to comment.