I'm not sure, but if you're in userspace, it should be sufficient to switch to an unused virtual console, then put the keyboard into raw mode. This will block the key combinations which would normally switch back into another virtual console. That won't disable the mouse, but X should ignore the mouse if it is not the current VT (just make sure gpm isn't running).
You also have to disable the magic-sysrq key combination if that is enabled, as there is a sysrq key to take the keyboard out of raw mode, which would otherwise get around this.
EDIT: it should be possible to do all of this from kernel space, provided you're in a normal task context. A kernel thread would do, I expect.
You can open files and devices from the kernel, it's just not recommended. A task which has a namespace containing /dev (I'm not sure whether kernel tasks do). You can call filp_open (I think) and get a file *, which you can then call the appropriate methods on its file_operations (f_op). This should include the ioctls required to do the above.
There might be a way of opening a device directly, not via the filp_open.
In short, it should be possible. It's a very dodgy thing to do from kernel space.