Dynamically Modifying the Android Kernel

In order to implement USB Host Identification on a commodity device, one of the common goals is that the final application released will not ask the end-user to make massive modifications to their device just to use USB Host Identification. Of course, to emulate repeated dis/connection requires that we modify the behavior of the kernel we are working with.

The assumption we have made is that a user who is interested in using USB Host Identification will be willing to use a ‘Rooted’ device to do so. With this assumption we can do the following

  1. Statically decide what function(s) to overwrite. (Add printk() calls during all ep0 interrupts, etc…)
  2. Dynamically determine where the function(s) lies. (System.map, /proc/kallsyms)
  3. Hook the function(s), overwriting with modifications that were decided statically (look to Kprobes for implementation details)

One set of issues arose during this process. The functions that we were wishing to overwrite dynamically are actually paired with the keyword “static.” This means that they cannot be seen outside of their files scopes, and in step 2 above, we cannot find where the function lies at runtime. A second issue was seen also; Kprobes modules are not built in with the native Android/Linux kernel. With these two considerations, we had to make the following static modifications to the kernel.

  1. Comment out the keyword “static” on functions we wish to override
  2. Include the Kprobes build option via “make menuconfig”

With these modifications, we compiled and uploaded the new kernel to the phone using the method specified in XXX.

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*