summaryrefslogtreecommitdiff
path: root/fishdescriptor
Commit message (Collapse)AuthorAge
* fishdescriptor: cast __errno_location correctlyIan Jackson2019-04-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The return value from __errno_location() is an int*. My syntax had erroneously specified that it returned an int. Nothing spotted this bug because the expression is evaluated by gdb whose C interpreter is very strange. In particular, gdb lets you dereference an int, even on a platform where ints are 32-bit and pointers are 64-bit. If you are on a 32-bit platform, this does not matter. Likewise if you are on a 64-bit platform and the address of errno happens, by luck, to be within the 32-bit addressable part of the space. If you are mildly lucky the result of this is an error like this: gdb.MemoryError: Cannot access memory at address 0x2f24ef10 buried in stack traces from fishdescriptor. If you are unlucky, fishdescriptor will successfully access some wrong location. This means it does not actually save and restore errno, since it saves and restores somewhere else instead. So fishdescriptor will corrupt the errno value of the thread that it happens to be (ab)using, overwriting it with the errno from fishdescriptor's own calls, possibly causing the target program to become confused about the error(s) from system call(s) it is making. If you are very unlucky, fishdescriptor will successfully access some wrong location which is actively in use by something outside the target process (eg, direct IO, shared memory0. fishdescriptor will save the value (a single int) and then restore it a bit later. This might in principle cause any kind of arbitrary lossage. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: When looking for run_dir, look in target rootIan Jackson2018-11-20
| | | | | | | This is correct, since we are operating in our environment but we are going to use the path in the target's root. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: Calculate target_root earlier and pass to _sock_dirIan Jackson2018-11-20
| | | | | | | | No functional change. We are going to use this in a moment. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: Cope if donor is in a chroot without /procIan Jackson2018-11-19
| | | | | | | | | | | | | | | | `our_sockname' contains something like /proc/DONOR/root/run/user/UID/fishdescriptor/SOCKET When I tested this I did it in a chroot where /proc was mounted. In such a chroot /proc/DONOR/root -> /. So this works. But if there is no /proc, it does not work. Instead, we can can and should assume that the path in the donor is relative to its own root. Ie, we can just use `sockname'. CC: George Dunlap <george.dunlap@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: Actually tidy up actual2intended when closingIan Jackson2018-06-07
| | | | | | | | Otherwise we will probably try to move the new-defunct open-file somewhere when we try to make the descriptor refer to the intended open-file. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Work if child is not running as root, but we areIan Jackson2018-06-07
| | | | | | | | | We make a socket, normally in /var/run/user for the victim process, which is therefore accessible only to the victim uid (and to root). If we are running as root, the socket will typically not be writeable by the user, and this will fail. We need to chmod it. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Fix a tuple bug in fd permutationIan Jackson2018-06-07
| | | | | | | | The fd permutation algorithm would fail in nontrivial cases because it tries to update individual members of the tupes in the fdmap. That is not permitted in Python. Make the tuples into lists. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Fix a typoIan Jackson2018-05-11
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Provide copyright notices and licence statementsIan Jackson2018-04-20
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Fix typo in help messageIan Jackson2018-04-20
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: build system (nugatory)Ian Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: fix error handlingIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: sort out debugging outputIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: bugfixesIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: bugfixesIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: hideous errno workaroundIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* Revert "fishdescriptor: try parse_eval_via_print"Ian Jackson2017-10-24
| | | | This reverts commit 33545a21597767a50443a717b015fc9e3c8dd553.
* fishdescriptor: try parse_eval_via_printIan Jackson2017-10-24
| | | | | | Actually this works for reading errno but not for setting it. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip utility, bugfixesIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip utility, bugfixesIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip utilityIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip utility, before rename various variablesIan Jackson2017-10-24
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip utilityIan Jackson2017-10-23
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Make Donor.pid a public memberIan Jackson2017-10-23
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: before redo option parsingIan Jackson2017-10-19
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: use lookup_type for the field listIan Jackson2017-10-19
| | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: bugfixIan Jackson2017-10-19
| | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: bugfixes, seems to get fds now!Ian Jackson2017-10-19
| | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: bugfixesIan Jackson2017-10-19
| | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: bugfixesIan Jackson2017-10-19
| | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* fishdescriptor: debuggingIan Jackson2017-10-18
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: debuggingIan Jackson2017-10-18
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: new approachIan Jackson2017-10-18
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip reconsider approachIan Jackson2017-10-18
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip, before reconsider approachIan Jackson2017-10-18
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: wip (found)Ian Jackson2017-10-17
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: reorg python libraries againIan Jackson2017-10-13
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: WIP fishing module, before move to own moduleIan Jackson2017-10-13
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Allow "preloaded"Ian Jackson2017-10-06
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Use os or dl for RTLD_nowIan Jackson2017-10-06
| | | | | | Suggestion by Colin Watson. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* Revert "fishdescriptor: Utility for RTLD_NOW"Ian Jackson2017-10-06
| | | | This reverts commit 22677ae542431ce09a8de83fecc3a22163a8d490.
* fishdescriptor: Utility for RTLD_NOWIan Jackson2017-10-06
| | | | | | | Actually we don't want to do this. It is better to use the python dl or os modules, so we will do that in a moment. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: work on python codeIan Jackson2017-10-06
| | | | | | Still very incomplete Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: .so can be loadedIan Jackson2017-10-05
| | | | | | | | | | | | | | (gdb) print (void*)dlopen("/u/iwj/things/chiark-utils.git/fishdescriptor/libfishdescriptor-donate.so.1.0",2) $5 = (void *) 0x8f0d408 (gdb) print (void*)dlsym($5, "fishdescriptor_donate") $6 = (void *) 0xf6953620 <fishdescriptor_donate> (gdb) print (( int (*)(const char *, const int *) )$6)("/dev/enoent", (int[2]){0,-1}) $7 = 2 (gdb) print strerror(2) $8 = 0xf74697e8 "No such file or directory" (gdb) Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: donate: some bugfixesIan Jackson2017-10-05
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: More work, before trying to compile itIan Jackson2017-10-05
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: reorganise to my tasteIan Jackson2017-10-05
| | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Upgrade licence of code from libxlIan Jackson2017-10-05
| | | | | | | See LGPL-2.1 s3. This is necessary to preserve the copyright and licence status of chiark-utils as a whole. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* fishdescriptor: Copy fd passing C sender code from libxlIan Jackson2017-10-05
Copy int libxl__sendmsg_fds from libxl so we can clone and hack it. Source was: xen.git#38ab259f559be5457f6866ba24185e013f27defb tools/libxl/libxl_utils.c libxl is LGPL2.1-only. We will upgrade this licence to be compatible with the rest of chiark utils (GPL3+) in a moment. This is permitted by LGPL-2.1 section 3. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>