From owner-svn-src-all@FreeBSD.ORG Tue Apr 21 13:55:25 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D495179F; Tue, 21 Apr 2015 13:55:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C287A1A99; Tue, 21 Apr 2015 13:55:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3LDtPTm059553; Tue, 21 Apr 2015 13:55:25 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3LDtOen059543; Tue, 21 Apr 2015 13:55:24 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201504211355.t3LDtOen059543@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 21 Apr 2015 13:55:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281829 - in head/sys: compat/linux kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Tue, 21 Apr 2015 13:55:26 -0000 Author: trasz Date: Tue Apr 21 13:55:24 2015 New Revision: 281829 URL: https://svnweb.freebsd.org/changeset/base/281829 Log: Modify kern___getcwd() to take max pathlen limit as an additional argument. This will be used for the Linux emulation layer - for Linux, PATH_MAX is 4096 and not 1024. Differential Revision: https://reviews.freebsd.org/D2335 Reviewed by: kib@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Modified: head/sys/compat/linux/linux_getcwd.c head/sys/compat/linux/linux_misc.h head/sys/kern/vfs_cache.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/linux/linux_getcwd.c ============================================================================== --- head/sys/compat/linux/linux_getcwd.c Tue Apr 21 11:50:31 2015 (r281828) +++ head/sys/compat/linux/linux_getcwd.c Tue Apr 21 13:55:24 2015 (r281829) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #endif +#include #include #include @@ -423,14 +424,14 @@ linux_getcwd(struct thread *td, struct l len = args->bufsize; - if (len > MAXPATHLEN*4) - len = MAXPATHLEN*4; + if (len > LINUX_PATH_MAX) + len = LINUX_PATH_MAX; else if (len < 2) return ERANGE; path = malloc(len, M_TEMP, M_WAITOK); - error = kern___getcwd(td, path, UIO_SYSSPACE, len); + error = kern___getcwd(td, path, UIO_SYSSPACE, len, LINUX_PATH_MAX); if (!error) { lenused = strlen(path) + 1; if (lenused <= args->bufsize) { Modified: head/sys/compat/linux/linux_misc.h ============================================================================== --- head/sys/compat/linux/linux_misc.h Tue Apr 21 11:50:31 2015 (r281828) +++ head/sys/compat/linux/linux_misc.h Tue Apr 21 13:55:24 2015 (r281829) @@ -55,6 +55,8 @@ #define LINUX_MREMAP_MAYMOVE 1 #define LINUX_MREMAP_FIXED 2 +#define LINUX_PATH_MAX 4096 + extern const char *linux_platform; /* Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Tue Apr 21 11:50:31 2015 (r281828) +++ head/sys/kern/vfs_cache.c Tue Apr 21 13:55:24 2015 (r281829) @@ -1053,11 +1053,13 @@ sys___getcwd(td, uap) struct __getcwd_args *uap; { - return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen)); + return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen, + MAXPATHLEN)); } int -kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen) +kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen, + u_int path_max) { char *bp, *tmpbuf; struct filedesc *fdp; @@ -1068,8 +1070,8 @@ kern___getcwd(struct thread *td, char *b return (ENODEV); if (buflen < 2) return (EINVAL); - if (buflen > MAXPATHLEN) - buflen = MAXPATHLEN; + if (buflen > path_max) + buflen = path_max; tmpbuf = malloc(buflen, M_TEMP, M_WAITOK); fdp = td->td_proc->p_fd; Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Tue Apr 21 11:50:31 2015 (r281828) +++ head/sys/sys/syscallsubr.h Tue Apr 21 13:55:24 2015 (r281829) @@ -58,7 +58,7 @@ struct thr_param; struct __wrusage; int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, - u_int buflen); + u_int buflen, u_int path_max); int kern_accept(struct thread *td, int s, struct sockaddr **name, socklen_t *namelen, struct file **fp); int kern_accept4(struct thread *td, int s, struct sockaddr **name,