Skip to content

Commit 2995cce

Browse files
gerald-schaeferVasily Gorbik
authored andcommitted
s390/monwriter: Reject buffer reuse with different data length
When data buffers are reused, e.g. for interval sample records, the first record determines the data length, and the size of the buffer for user copy. Current monwriter code does not check if the data length was changed for subsequent records, which also would never happen for valid user programs. However, a malicious user could change the data length, resulting in out of bounds user copy to the kernel buffer, and memory corruption. By default, the monwriter misc device is created with root-only permissions, so practical impact is typically low. Fix this by checking for changed data length and rejecting such records. Cc: stable@vger.kernel.org Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 754e9e4 commit 2995cce

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/s390/char/monwriter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
122122
kfree(monbuf->data);
123123
kfree(monbuf);
124124
monbuf = NULL;
125+
} else if (monbuf->hdr.datalen != monhdr->datalen) {
126+
/* Data with buffer reuse must not change its length */
127+
return -EINVAL;
125128
}
126129
} else if (monhdr->mon_function != MONWRITE_STOP_INTERVAL) {
127130
if (mon_buf_count >= mon_max_bufs)

0 commit comments

Comments
 (0)