Skip to contentSkip to conversation

dtprobed: reject oversized DOF consistently

PATCH In review Kris Van Hees 2 participants 2 messages Aug 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 dtprobed: reject oversized DOF consistently

The dtprobed ioctl handler warned when helper DOF exceeded the parser limit, but still attempted to allocate and copy it. Share DOF_MAXSZ with the parser and fail the ioctl when dofh_loadsz is too large, so both paths enforce the same 256MB limit.

Orabug: 39351859

---
 dtprobed/dtprobed.c     | 8 ++++----
 libcommon/usdt_parser.c | 7 +++----
 libcommon/usdt_parser.h | 2 ++
 3 files changed, 9 insertions(+), 8 deletions(-)
dtprobed/dtprobed.c +4 -4
index 37d615bb..81b28e6d 100644
@@ -69,7 +69,6 @@
 
 #include "seccomp-assistance.h"
 
-#define DOF_MAXSZ 512 * 1024 * 1024
 #define DOF_CHUNKSZ 64 * 1024
 
 static struct fuse_session *cuse_session;
@@ -769,11 +768,12 @@ helper_ioctl(fuse_req_t req, int cmd, void *arg,
 		}
 		memcpy(&userdata->dof_hdr, in_buf, sizeof(dof_hdr_t));
 
-		if (userdata->dof_hdr.dofh_loadsz > DOF_MAXSZ)
-			fuse_log(FUSE_LOG_WARNING, "%i: dtprobed: DOF size of %zi longer than is sane\n",
+		if (userdata->dof_hdr.dofh_loadsz > DOF_MAXSZ) {
+			fuse_log(FUSE_LOG_ERR, "%i: dtprobed: DOF size of %zi longer than is sane\n",
 				 pid, userdata->dof_hdr.dofh_loadsz);
 
-		/* Fall through. */
+			goto fuse_err;
+		}
 	}
 
 	/*
libcommon/usdt_parser.c +3 -4
index 86419809..1dc2fffb 100644
@@ -19,7 +19,6 @@
 #include "usdt_parser.h"
 
 size_t			usdt_maxcount = 2;
-size_t			usdt_maxsize = 256 * 1024 * 1024;
 
 _dt_printflike_(3, 4)
 void
@@ -131,9 +130,9 @@ usdt_copyin_block(int in, int out, int *ok)
 		abort();
 
 	/* Validate the data size. */
-	if (data->size >= usdt_maxsize) {
-		usdt_error(out, E2BIG, "data size %zi exceeds maximum %zi",
-			   data->size, usdt_maxsize);
+	if (data->size > DOF_MAXSZ) {
+		usdt_error(out, E2BIG, "data size %zi exceeds maximum %i",
+			   data->size, DOF_MAXSZ);
 		return NULL;
 	}
 
libcommon/usdt_parser.h +2 -0
index d33370e4..b11207d1 100644
@@ -15,6 +15,8 @@
 #include <dtrace/dof.h>
 #include <dtrace/helpers.h>
 
+#define DOF_MAXSZ	(256 * 1024 * 1024)
+
 /*
  * Data transfer unit for the DOF parser.
  */
Signature · 1 line
2.52.0
Reviewed-by on v1 1/6
#1 lore raw
Quoted 88 lines · Kris Van Hees via DTrace-devel

The dtprobed ioctl handler warned when helper DOF exceeded the parser limit, but still attempted to allocate and copy it. Share DOF_MAXSZ with the parser and fail the ioctl when dofh_loadsz is too large, so both paths enforce the same 256MB limit.

Orabug: 39351859

---
 dtprobed/dtprobed.c     | 8 ++++----
 libcommon/usdt_parser.c | 7 +++----
 libcommon/usdt_parser.h | 2 ++
 3 files changed, 9 insertions(+), 8 deletions(-)
dtprobed/dtprobed.c +4 -4
index 37d615bb..81b28e6d 100644
@@ -69,7 +69,6 @@
 
 #include "seccomp-assistance.h"
 
-#define DOF_MAXSZ 512 * 1024 * 1024
 #define DOF_CHUNKSZ 64 * 1024
 
 static struct fuse_session *cuse_session;
@@ -769,11 +768,12 @@ helper_ioctl(fuse_req_t req, int cmd, void *arg,
 		}
 		memcpy(&userdata->dof_hdr, in_buf, sizeof(dof_hdr_t));
 
-		if (userdata->dof_hdr.dofh_loadsz > DOF_MAXSZ)
-			fuse_log(FUSE_LOG_WARNING, "%i: dtprobed: DOF size of %zi longer than is sane\n",
+		if (userdata->dof_hdr.dofh_loadsz > DOF_MAXSZ) {
+			fuse_log(FUSE_LOG_ERR, "%i: dtprobed: DOF size of %zi longer than is sane\n",
 				 pid, userdata->dof_hdr.dofh_loadsz);
 
-		/* Fall through. */
+			goto fuse_err;
+		}
 	}
 
 	/*
libcommon/usdt_parser.c +3 -4
index 86419809..1dc2fffb 100644
@@ -19,7 +19,6 @@
 #include "usdt_parser.h"
 
 size_t			usdt_maxcount = 2;
-size_t			usdt_maxsize = 256 * 1024 * 1024;
 
 _dt_printflike_(3, 4)
 void
@@ -131,9 +130,9 @@ usdt_copyin_block(int in, int out, int *ok)
 		abort();
 
 	/* Validate the data size. */
-	if (data->size >= usdt_maxsize) {
-		usdt_error(out, E2BIG, "data size %zi exceeds maximum %zi",
-			   data->size, usdt_maxsize);
+	if (data->size > DOF_MAXSZ) {
+		usdt_error(out, E2BIG, "data size %zi exceeds maximum %i",
+			   data->size, DOF_MAXSZ);
 		return NULL;
 	}
 
libcommon/usdt_parser.h +2 -0
index d33370e4..b11207d1 100644
@@ -15,6 +15,8 @@
 #include <dtrace/dof.h>
 #include <dtrace/helpers.h>
 
+#define DOF_MAXSZ	(256 * 1024 * 1024)
+
 /*
  * Data transfer unit for the DOF parser.
  */
Signature · 7 lines
2.52.0


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