From owner-p4-projects@FreeBSD.ORG Mon Feb 6 17:02:07 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A34D516A423; Mon, 6 Feb 2006 17:02:06 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4B89C16A420 for ; Mon, 6 Feb 2006 17:02:06 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A4F5B43D6B for ; Mon, 6 Feb 2006 17:02:04 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k16H24iY069145 for ; Mon, 6 Feb 2006 17:02:04 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k16H24J7069142 for perforce@freebsd.org; Mon, 6 Feb 2006 17:02:04 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 6 Feb 2006 17:02:04 GMT Message-Id: <200602061702.k16H24J7069142@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 91243 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2006 17:02:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=91243 Change 91243 by rwatson@rwatson_zoo on 2006/02/06 17:01:03 If the user process passed a buffer too short for a record, drop it and loop, rather than returning truncated data to user space. This is a "truncated drop". Count truncated record drops in the audit pipe stats. Affected files ... .. //depot/projects/trustedbsd/audit3/sys/security/audit/audit_pipe.c#3 edit Differences ... ==== //depot/projects/trustedbsd/audit3/sys/security/audit/audit_pipe.c#3 (text+ko) ==== @@ -85,6 +85,7 @@ u_int64_t ap_inserts; /* Records added. */ u_int64_t ap_reads; /* Records read. */ u_int64_t ap_drops; /* Records dropped. */ + u_int64_t ap_truncates; /* Records too long. */ TAILQ_HEAD(, audit_pipe_entry) ap_queue; @@ -228,7 +229,7 @@ ape = TAILQ_FIRST(&ap->ap_queue); KASSERT((ape == NULL && ap->ap_qlen == 0) || - (ape != NULL && ap->ap_qlen != 0), ("audit_pipe_read: qlen")); + (ape != NULL && ap->ap_qlen != 0), ("audit_pipe_pop: qlen")); if (ape == NULL) return (NULL); TAILQ_REMOVE(&ap->ap_queue, ape, ape_queue); @@ -404,6 +405,15 @@ mtx_unlock(&audit_pipe_mtx); return (error); } + /* + * Simply drop records that are too long and keep waiting, as + * this helps maintain the discreet record interface. + */ + if (ape->ape_record_len < uio->uio_resid) { + audit_pipe_entry_free(ape); + ap->ap_truncates++; + continue; + } } mtx_unlock(&audit_pipe_mtx);