From owner-svn-src-all@FreeBSD.ORG Sat Jan 21 00:06:22 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F7781065670; Sat, 21 Jan 2012 00:06:22 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8E8958FC1E; Sat, 21 Jan 2012 00:06:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0L06MS2065076; Sat, 21 Jan 2012 00:06:22 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0L06MB3065074; Sat, 21 Jan 2012 00:06:22 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201201210006.q0L06MB3065074@svn.freebsd.org> From: Martin Matuska Date: Sat, 21 Jan 2012 00:06:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230407 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jan 2012 00:06:22 -0000 Author: mm Date: Sat Jan 21 00:06:21 2012 New Revision: 230407 URL: http://svn.freebsd.org/changeset/base/230407 Log: Use separate buffer for global path to avoid overflow of path buffer. Reviewed by: jamie@ MFC after: 3 weeks Modified: head/sys/kern/kern_jail.c Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Fri Jan 20 23:48:14 2012 (r230406) +++ head/sys/kern/kern_jail.c Sat Jan 21 00:06:21 2012 (r230407) @@ -521,6 +521,7 @@ kern_jail_set(struct thread *td, struct struct prison *pr, *deadpr, *mypr, *ppr, *tpr; struct vnode *root; char *domain, *errmsg, *host, *name, *namelc, *p, *path, *uuid; + char *g_path; #if defined(INET) || defined(INET6) struct prison *tppr; void *op; @@ -575,6 +576,7 @@ kern_jail_set(struct thread *td, struct #ifdef INET6 ip6 = NULL; #endif + g_path = NULL; error = vfs_copyopt(opts, "jid", &jid, sizeof(jid)); if (error == ENOENT) @@ -907,13 +909,17 @@ kern_jail_set(struct thread *td, struct vfslocked = NDHASGIANT(&nd); root = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); - error = vn_path_to_global_path(td, root, path, MAXPATHLEN); - if (error == ENODEV) { + g_path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); + strlcpy(g_path, path, MAXPATHLEN); + error = vn_path_to_global_path(td, root, g_path, MAXPATHLEN); + if (error == 0) + path = g_path; + else if (error == ENODEV) { /* proceed if sysctl debug.disablefullpath == 1 */ fullpath_disabled = 1; if (len < 2 || (len == 2 && path[0] == '/')) path = NULL; - } else if (error != 0) { + } else { /* exit on other errors */ VFS_UNLOCK_GIANT(vfslocked); goto done_free; @@ -1819,6 +1825,8 @@ kern_jail_set(struct thread *td, struct #ifdef INET6 free(ip6, M_PRISON); #endif + if (g_path != NULL) + free(g_path, M_TEMP); vfs_freeopts(opts); return (error); }