From d7f811d098d9e656243072720c6f4d1da8cda640 Mon Sep 17 00:00:00 2001 From: jdolecek Date: Fri, 5 Jan 2001 22:25:26 +0000 Subject: [PATCH] utrace(2): limit size of user data to KTR_USER_MAXLEN (currently 2048); return EINVAL if 'len' is bigger --- sys/kern/kern_ktrace.c | 5 ++++- sys/sys/ktrace.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 8615d33b7e9f..6d96f2a9129e 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ktrace.c,v 1.52 2001/01/05 21:42:09 jdolecek Exp $ */ +/* $NetBSD: kern_ktrace.c,v 1.53 2001/01/05 22:25:26 jdolecek Exp $ */ /* * Copyright (c) 1989, 1993 @@ -673,6 +673,9 @@ sys_utrace(p, v, retval) if (!KTRPOINT(p, KTR_USER)) return (0); + if (SCARG(uap, len) > KTR_USER_MAXLEN) + return (EINVAL); + ktruser(p, SCARG(uap, label), SCARG(uap, addr), SCARG(uap, len), 1); return (0); diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 2d3461bb9126..afcc4acfd0dc 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -1,4 +1,4 @@ -/* $NetBSD: ktrace.h,v 1.21 2000/12/28 11:10:17 jdolecek Exp $ */ +/* $NetBSD: ktrace.h,v 1.22 2001/01/05 22:25:27 jdolecek Exp $ */ /* * Copyright (c) 1988, 1993 @@ -145,6 +145,7 @@ struct ktr_csw { */ #define KTR_USER 8 #define KTR_USER_MAXIDLEN 20 +#define KTR_USER_MAXLEN 2048 /* maximum length of passed data */ struct ktr_user { char ktr_id[KTR_USER_MAXIDLEN]; /* string id of caller */ /*