Suppress some "Assertion Failed".

Some ioctl calls result in "Assertion Failed" although everything seems to work
anyway. So we suppress these so that the error messages that do pop up are
actually significant.

Also add support for sending syslog messages from the vgpu_unlock python script.
This simplifies debugging a lot, and allows us to log the operation type values
for each ioctl call that fails.
This commit is contained in:
Jonathan Johansson 2021-04-17 17:37:07 +02:00
parent 10fb78a81d
commit c63cc3bb76

View file

@ -18,6 +18,17 @@ import sys
import time
script_source = r"""
var syslog_func = new NativeFunction(Module.getExportByName(null, "syslog"),
"void",
["int", "pointer", "...", "pointer"]);
var syslog = function(message) {
var format_ptr = Memory.allocUtf8String("%s");
var message_ptr = Memory.allocUtf8String(message);
syslog_func(5, format_ptr, message_ptr);
};
// Value of the "request" argument used by nvidia-vgpud and nvidia-vgpu-mgr
// when calling ioctl to read the PCI device ID and type (and possibly
// other things) from the GPU.
@ -54,6 +65,7 @@ script_source = r"""
// 0.1s then 1s then 10s) then issue the same ioctl call again until the
// status differs from 3. It will attempt this for up to 24h before giving
// up.
var STATUS_OK = 0;
var STATUS_TRY_AGAIN = 3;
Interceptor.attach(Module.getExportByName(null, "ioctl"), {
@ -288,8 +300,22 @@ script_source = r"""
var dev_type_ptr = this.argp.add(0x10).readPointer();
dev_type_ptr.writeU64(DEV_TYPE_VGPU_CAPABLE);
}
if(status != STATUS_OK) {
// Things seems to work fine even if some operations that fail
// result in failed assertions. So here we change the status
// value for these cases to cleanup the logs for nvidia-vgpu-mgr.
if(op_type == 0xA0820104 ||
op_type == 0x90960103) {
this.argp.add(0x1C).writeU32(STATUS_OK);
} else {
syslog("op_type: 0x" + op_type.toString(16) + " failed.");
}
}
}
});
syslog("vgpu_unlock loaded.");
"""
device = frida.get_local_device()