Skip to contentSkip to conversation

dtprobed: handle a crashed parser child better

PATCH In review Nick Alcock 2 participants 4 messages Jan 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dtprobed: handle a crashed parser child better

When a parser child crashes and is restarted, its file handles might change: we should pick up the new fhes if so.

---
 dtprobed/dtprobed.c | 6 ++++++
 1 file changed, 6 insertions(+)
dtprobed/dtprobed.c +6 -0
index 86865eb467b67..c0597b7329d37 100644
@@ -769,7 +769,13 @@ process_dof(pid_t pid, int out, int in, dev_t dev, ino_t inum, dev_t exec_dev,
 		if (!provider) {
 			if (tries++ > 1)
 				goto err;
+			/*
+			 * Tidying reopens the parser in and out pipes: catch
+			 * up with this.
+			 */
 			dof_parser_tidy(1);
+			out = parser_out_pipe;
+			in = parser_in_pipe;
 			continue;
 		}
 		if (provider->type != DIT_PROVIDER && provider->type != DIT_EOF)
Signature · 1 line
2.47.1.279.g84c5f4e78e
#1 lore raw

PATCH 2/2 libcommon: turn off FORTIFY_SOURCE more aggressively

This is incompatible with dof_parser_t's use of trailing strings of variable length, and buys us nothing anyway since we're running in a seccomped parser child and any buffer overruns are harmless and cannot result in anything other than a dying child. We were already -U'ing FORTIFY_SOURCE in libcommon_CPPFLAGS, but that precedes CFLAGS on the command line, so if the build system passes -D_FORTIFY_SOURCE there, it still takes effect.

Use _NOCFLAGS and _NOCPPFLAGS to explicitly disable every level of fortification that currently exists.

---
 libcommon/Build | 2 ++
 1 file changed, 2 insertions(+)
libcommon/Build +2 -0
index fd54dc044f9af..00c0d46d125e4 100644
@@ -10,4 +10,6 @@ libcommon_TARGET = libcommon
 libcommon_DIR := $(current-dir)
 libcommon_CPPFLAGS := -Ilibcommon -Ilibproc -U_FORTIFY_SOURCE
 libcommon_SOURCES = dof_parser.c dof_parser_host.c dt_list.c
+libcommon_NOCFLAGS := -D_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=3
+libcommon_NOCPPFLAGS := -D_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=3
 libcommon_LIBSOURCES = libcommon
Signature · 1 line
2.47.1.279.g84c5f4e78e
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] libcommon: turn off FORTIFY_SOURCE more aggressively

Quoted 8 lines · Nick Alcock

This is incompatible with dof_parser_t's use of trailing strings of variable length, and buys us nothing anyway since we're running in a seccomped parser child and any buffer overruns are harmless and cannot result in anything other than a dying child. We were already -U'ing FORTIFY_SOURCE in libcommon_CPPFLAGS, but that precedes CFLAGS on the command line, so if the build system passes -D_FORTIFY_SOURCE there, it still takes effect.

Quoted 4 lines

Use _NOCFLAGS and _NOCPPFLAGS to explicitly disable every level of fortification that currently exists.

Quoted 18 lines
---
 libcommon/Build | 2 ++
 1 file changed, 2 insertions(+)
libcommon/Build +2 -0
index fd54dc044f9af..00c0d46d125e4 100644
@@ -10,4 +10,6 @@ libcommon_TARGET = libcommon
 libcommon_DIR := $(current-dir)
 libcommon_CPPFLAGS := -Ilibcommon -Ilibproc -U_FORTIFY_SOURCE
 libcommon_SOURCES = dof_parser.c dof_parser_host.c dt_list.c
+libcommon_NOCFLAGS := -D_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=3
+libcommon_NOCPPFLAGS := -D_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=3
 libcommon_LIBSOURCES = libcommon
Signature · 1 line
2.47.1.279.g84c5f4e78e
Reviewed-by on v1 1/2
#3 lore raw
In reply to Nick Alcock
Quoted 4 lines · Nick Alcock via DTrace-devel

When a parser child crashes and is restarted, its file handles might change: we should pick up the new fhes if so.

Quoted 30 lines
---
 dtprobed/dtprobed.c | 6 ++++++
 1 file changed, 6 insertions(+)
dtprobed/dtprobed.c +6 -0
index 86865eb467b67..c0597b7329d37 100644
@@ -769,7 +769,13 @@ process_dof(pid_t pid, int out, int in, dev_t dev, ino_t inum, dev_t exec_dev,
 		if (!provider) {
 			if (tries++ > 1)
 				goto err;
+			/*
+			 * Tidying reopens the parser in and out pipes: catch
+			 * up with this.
+			 */
 			dof_parser_tidy(1);
+			out = parser_out_pipe;
+			in = parser_in_pipe;
 			continue;
 		}
 		if (provider->type != DIT_PROVIDER && provider->type != DIT_EOF)
Signature · 7 lines
2.47.1.279.g84c5f4e78e


_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel