diff options
| author | Michael Kerrisk <mtk.manpages@gmail.com> | 2020-10-29 10:46:10 +0100 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2021-06-10 10:40:17 +1200 |
| commit | 8a7703864cfb4c90e30d9ca9823b40dd838e218c (patch) | |
| tree | bd42a0539ef87a38f48d4b55e7a9f58bec692281 /man2 | |
| parent | dbcc2ad691191ea5be887a8e43073a4201c56c57 (diff) | |
| download | man-pages-8a7703864cfb4c90e30d9ca9823b40dd838e218c.tar.gz | |
seccomp_unotify.2: EXAMPLES: make getTargetPathname() a bit more generically useful
Allow the caller to specify which system call argument should
be looked up as a pathname.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Diffstat (limited to 'man2')
| -rw-r--r-- | man2/seccomp_unotify.2 | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/man2/seccomp_unotify.2 b/man2/seccomp_unotify.2 index 183f9f5d90..f9053b8281 100644 --- a/man2/seccomp_unotify.2 +++ b/man2/seccomp_unotify.2 @@ -1329,12 +1329,17 @@ checkNotificationIdIsValid(int notifyFd, uint64_t id) "target has terminated!!!\en"); } -/* Access the memory of the target process in order to discover the - pathname that was given to mkdir() */ +/* Access the memory of the target process in order to fetch the + pathname referred to by the system call argument \(aqargNum\(aq in + \(aqreq\->data.args[]\(aq. The pathname is returned in \(aqpath\(aq, + a buffer of \(aqlen\(aq bytes allocated by the caller. + + Returns true if the fetched pathname is correctly formed + (i.e., has a terminating null byte), and false otherwise. */ static bool getTargetPathname(struct seccomp_notif *req, int notifyFd, - char *path, size_t len) + int argNum, char *path, size_t len) { char procMemPath[PATH_MAX]; @@ -1354,10 +1359,9 @@ getTargetPathname(struct seccomp_notif *req, int notifyFd, checkNotificationIdIsValid(notifyFd, req\->id); - /* Read bytes at the location containing the pathname argument - (i.e., the first argument) of the mkdir(2) call */ + /* Read bytes at the location containing the pathname argument */ - ssize_t nread = pread(procMemFd, path, len, req\->data.args[0]); + ssize_t nread = pread(procMemFd, path, len, req\->data.args[argNum]); if (nread == \-1) errExit("pread"); @@ -1445,7 +1449,7 @@ handleNotifications(int notifyFd) exit(EXIT_FAILURE); } - bool pathOK = getTargetPathname(req, notifyFd, path, + bool pathOK = getTargetPathname(req, notifyFd, 0, path, sizeof(path)); /* Prepopulate some fields of the response */ |
