es1370: check total frame count against current frame
PATCH 1/1 es1370: check total frame count against current frame
From: Prasad J Pandit <[email protected]>
A guest user may set channel frame count via es1370_write() such that, in es1370_transfer_audio(), total frame count 'size' is lesser than the number of frames that are processed 'cnt'.
int cnt = d->frame_cnt >> 16;
int size = d->frame_cnt & 0xffff;if (size < cnt), it results in incorrect calculations leading to OOB access issue(s). Add check to avoid it.
Reported-by Ren Ding <[email protected]>
Reported-by Hanqing Zhao <[email protected]>
Signed-off-by Prasad J Pandit <[email protected]>
--- hw/audio/es1370.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/audio/es1370.c +5 -2
@@ -643,6 +643,9 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,int csc_bytes = (csc +1 ) << d->shift;int cnt = d->frame_cnt >>16 ;int size = d->frame_cnt &0xffff ; +if (size < cnt) { +return ; + }int left = ((size - cnt +1 ) <<2 ) + d->leftover;int transferred =0 ;int temp =MIN (max,MIN (left, csc_bytes));
@@ -651,7 +654,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel, addr += (cnt <<2 ) + d->leftover;if (index ==ADC_CHANNEL ) { -while (temp) { +while (temp >0 ) {int acquired, to_copy; to_copy =MIN ((size_t ) temp,sizeof (tmpbuf));
@@ -669,7 +672,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,else {SWVoiceOut *voice = s->dac_voice[index]; -while (temp) { +while (temp >0 ) {int copied, to_copy; to_copy =MIN ((size_t ) temp,sizeof (tmpbuf));
Signature · 1 line
2.25.4
+-- On Fri, 15 May 2020, P J P wrote --+ | From: Prasad J Pandit <[email protected]> | | A guest user may set channel frame count via es1370_write() | such that, in es1370_transfer_audio(), total frame count | 'size' is lesser than the number of frames that are processed | 'cnt'. | | int cnt = d->frame_cnt >> 16; | int size = d->frame_cnt & 0xffff; | | if (size < cnt), it results in incorrect calculations leading | to OOB access issue(s). Add check to avoid it. |
Ping...!
--
Prasad J Pandit / Red Hat Product Security Team
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
Quoted 15 lines · P J P
+-- On Fri, 15 May 2020, P J P wrote --+ | From: Prasad J Pandit <[email protected]> | | A guest user may set channel frame count via es1370_write() | such that, in es1370_transfer_audio(), total frame count | 'size' is lesser than the number of frames that are processed | 'cnt'. | | int cnt = d->frame_cnt >> 16; | int size = d->frame_cnt & 0xffff; | | if (size < cnt), it results in incorrect calculations leading | to OOB access issue(s). Add check to avoid it. |
Quoted 1 line
Ping...!
Added to audio patch queue.
(there isn't much activity in audio, thats why the mail was sitting in my mailbox waiting for me process it ...)
thanks,
Gerd