audio effects: filter reserved effect commands Block effect commands reserved for framework use when received on server side IAudioEffect. Applications have no reason to use these commands and they present a unnecessary attack surface. Bug: 62019992 Test: run CTS tests for audio effects Change-Id: Ie680d5d5650f99dbabf93891703e1cde2c2e852d (cherry picked from commit c7ab309ecbb289cd1296430f724166a26bd45afe)
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp index f908d6d..b588685 100644 --- a/services/audioflinger/Effects.cpp +++ b/services/audioflinger/Effects.cpp
@@ -1309,6 +1309,24 @@ ALOGVV("command(), cmdCode: %d, mHasControl: %d, mEffect: %p", cmdCode, mHasControl, mEffect.unsafe_get()); + // reject commands reserved for internal use by audio framework if coming from outside + // of audioserver + switch(cmdCode) { + case EFFECT_CMD_ENABLE: + case EFFECT_CMD_DISABLE: + case EFFECT_CMD_SET_PARAM: + case EFFECT_CMD_SET_PARAM_DEFERRED: + case EFFECT_CMD_SET_PARAM_COMMIT: + case EFFECT_CMD_GET_PARAM: + break; + default: + if (cmdCode >= EFFECT_CMD_FIRST_PROPRIETARY) { + break; + } + android_errorWriteLog(0x534e4554, "62019992"); + return BAD_VALUE; + } + if (cmdCode == EFFECT_CMD_ENABLE) { if (*replySize < sizeof(int)) { android_errorWriteLog(0x534e4554, "32095713");