From owner-cvs-all@FreeBSD.ORG Sun Jul 3 01:06:52 2005 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B8B2316AC74; Sun, 3 Jul 2005 00:57:55 +0000 (GMT) (envelope-from ps@mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5EC8C44263; Sun, 3 Jul 2005 00:40:38 +0000 (GMT) (envelope-from ps@mu.org) Received: by elvis.mu.org (Postfix, from userid 1000) id 0EF556DAE9; Sat, 2 Jul 2005 17:37:52 -0700 (PDT) X-Original-To: ps@mu.org Delivered-To: ps@mu.org Received: from mx2.freebsd.org (mx2.freebsd.org [216.136.204.119]) by elvis.mu.org (Postfix) with ESMTP id 3DAB35C9B8 for ; Fri, 21 Jan 2005 10:09:25 -0800 (PST) Received: from hub.freebsd.org (hub.freebsd.org [216.136.204.18]) by mx2.freebsd.org (Postfix) with ESMTP id 1FF6056D61 for ; Fri, 21 Jan 2005 18:09:25 +0000 (GMT) (envelope-from owner-src-committers@FreeBSD.org) Received: by hub.freebsd.org (Postfix) id 5FF3116A533; Fri, 21 Jan 2005 18:09:20 +0000 (GMT) Delivered-To: ps@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 538) id 4A2EB16A4D0; Fri, 21 Jan 2005 18:09:18 +0000 (GMT) Delivered-To: src-committers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 76D1616A4CE; Fri, 21 Jan 2005 18:09:17 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A61243D39; Fri, 21 Jan 2005 18:09:17 +0000 (GMT) (envelope-from bmilekic@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j0LI9H1F092620; Fri, 21 Jan 2005 18:09:17 GMT (envelope-from bmilekic@repoman.freebsd.org) Received: (from bmilekic@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j0LI9Hh3092619; Fri, 21 Jan 2005 18:09:17 GMT (envelope-from bmilekic) Message-Id: <200501211809.j0LI9Hh3092619@repoman.freebsd.org> From: Bosko Milekic To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Sender: owner-src-committers@FreeBSD.org Precedence: bulk X-Loop: FreeBSD.ORG X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on elvis.mu.org X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.1 X-Spam-Level: Cc: Subject: cvs commit: src/sys/conf NOTES files options src/sys/kern kern_malloc.c src/sys/vm memguard.c memguard.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 03 Jul 2005 01:06:53 -0000 X-Original-Date: Fri, 21 Jan 2005 18:09:17 +0000 (UTC) X-List-Received-Date: Sun, 03 Jul 2005 01:06:53 -0000 bmilekic 2005-01-21 18:09:17 UTC FreeBSD src repository Modified files: sys/conf NOTES files options sys/kern kern_malloc.c Added files: sys/vm memguard.c memguard.h Log: Bring in MemGuard, a very simple and small replacement allocator designed to help detect tamper-after-free scenarios, a problem more and more common and likely with multithreaded kernels where race conditions are more prevalent. Currently MemGuard can only take over malloc()/realloc()/free() for particular (a) malloc type(s) and the code brought in with this change manually instruments it to take over M_SUBPROC allocations as an example. If you are planning to use it, for now you must: 1) Put "options DEBUG_MEMGUARD" in your kernel config. 2) Edit src/sys/kern/kern_malloc.c manually, look for "XXX CHANGEME" and replace the M_SUBPROC comparison with the appropriate malloc type (this might require additional but small/simple code modification if, say, the malloc type is declared out of scope). 3) Build and install your kernel. Tune vm.memguard_divisor boot-time tunable which is used to scale how much of kmem_map you want to allott for MemGuard's use. The default is 10, so kmem_size/10. ToDo: 1) Bring in a memguard(9) man page. 2) Better instrumentation (e.g., boot-time) of MemGuard taking over malloc types. 3) Teach UMA about MemGuard to allow MemGuard to override zone allocations too. 4) Improve MemGuard if necessary. This work is partly based on some old patches from Ian Dowse. Revision Changes Path 1.1296 +7 -0 src/sys/conf/NOTES 1.985 +1 -0 src/sys/conf/files 1.490 +3 -0 src/sys/conf/options 1.138 +53 -0 src/sys/kern/kern_malloc.c 1.1 +222 -0 src/sys/vm/memguard.c (new) 1.1 +31 -0 src/sys/vm/memguard.h (new)