Thanks to Ian Abbott for leading me down the right path.
The solution was to use a level of indirection, since the pointer passed to the kernel function write_proc_alloc
is not the same one the user provides. Instead you write a pointer, copy that by value using get_user(ptr,(uintptr_t*)ubuf)
and then from there map the memory and write as before.