Skip to content

Commit 9ff0c94

Browse files
Dan Stozaandi34
authored andcommitted
libgui: Check slot received from IGBP in Surface
Checks that the slot number received from mGraphicBufferProducer in Surface::dequeueBuffer is on the interval [0, NUM_BUFFER_SLOTS) to protect against a malicious BnGraphicBufferProducer. Bug: 36991414 Change-Id: I1a76fd1bcce1c558f1c0c30f03638278288ed4fa (cherry picked from commit 90ce2a9)
1 parent 3a7ede0 commit 9ff0c94

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libs/gui/Surface.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
191191
result);
192192
return result;
193193
}
194+
195+
if (buf < 0 || buf >= NUM_BUFFER_SLOTS) {
196+
ALOGE("dequeueBuffer: IGraphicBufferProducer returned invalid slot number %d", buf);
197+
android_errorWriteLog(0x534e4554, "36991414"); // SafetyNet logging
198+
return FAILED_TRANSACTION;
199+
}
200+
194201
sp<GraphicBuffer>& gbuf(mSlots[buf].buffer);
195202

196203
// this should never happen

0 commit comments

Comments
 (0)