ANE_ProgramCreate() multiple kernel memory corruption [CVE-2022-32898]

We discussed this vulnerability during Episode 172 on 29 November 2022

An out-of-bounds write in the ZinComputeProgramGetNamesFromMultiPlaneLinear() and ZinComputeProgramGetNamesFromMultiPlaneTitledCompressed() functions of the Apple Neural Engine (ANE). These functions are responsible for parsing procedure I/O, and will take some arguments including an output planes array of kernel pointers to user-controlled data, as well as a planeCount for how many planes to copy into that array. The problem is, there’s no validation on how many planes a model can supply. This leads to an out of bounds write of kernel pointers to user-controlled data on the stack. This can be taken advantage of in multiple ways, including getting a heap overflow later on, or causing a type confusion by switching out some other kernel pointer on the stack for one with data you control.