[PATCH] [PR server/18976] fallback to open if multifs_open fails

Gary Benson gbenson@redhat.com
Thu Sep 17 15:33:00 GMT 2015


Josh Gao wrote:
> gdbserver on linux currently tries to open files from within the
> target's mount namespace via setns in a helper process, but this
> only works for users with CAP_SYS_CHROOT and CAP_SYS_ADMIN, which
> regular users generally don't have (particularly on android).
> 
> This patch retries with a regular open if multifs_open reports
> failure.

No.

If GDB/gdbserver got to the point that multifs_open was called then
the inferior is in a different mount namespace and it's not ok to
use regular open if multifs_open fails: you might open *something*,
but it'll be in the wrong filesystem.

If you're trying to debug an inferior in a different mount namespace
then you have to have CAP_SYS_CHROOT and CAP_SYS_ADMIN to access its
files directly.  If you can't get these capabilities then you need to
run gdbserver in the same container as the inferior and debug remotely
via TCP or something.  If you can't do that then you need to arrange
a local copy of the files and use "set sysroot" to make GDB use those
instead.

If your inferior *is* in the same mount namespace as GDB/gdbserver but
GDB/gdbserver is trying to use multifs_open then there is a bug, but
the bug is that linux_ns_same is not working correctly.  If this is
the case then let me know and I'll work with you to fix it.

Thanks,
Gary

-- 
http://gbenson.net/



More information about the Gdb-patches mailing list