Date: Sat, 15 Jul 2017 14:48:31 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r321009 - in stable/10/sys: compat/linux kern sys Message-ID: <201707151448.v6FEmV7I096241@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Sat Jul 15 14:48:31 2017 New Revision: 321009 URL: https://svnweb.freebsd.org/changeset/base/321009 Log: MFC r281829 (by trasz@): 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. Modified: stable/10/sys/compat/linux/linux_getcwd.c stable/10/sys/compat/linux/linux_misc.h stable/10/sys/kern/vfs_cache.c stable/10/sys/sys/syscallsubr.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/compat/linux/linux_getcwd.c ============================================================================== --- stable/10/sys/compat/linux/linux_getcwd.c Sat Jul 15 09:04:23 2017 (r321008) +++ stable/10/sys/compat/linux/linux_getcwd.c Sat Jul 15 14:48:31 2017 (r321009) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include <machine/../linux/linux.h> #include <machine/../linux/linux_proto.h> #endif +#include <compat/linux/linux_misc.h> #include <compat/linux/linux_util.h> #include <security/mac/mac_framework.h> @@ -423,14 +424,14 @@ linux_getcwd(struct thread *td, struct linux_getcwd_ar 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: stable/10/sys/compat/linux/linux_misc.h ============================================================================== --- stable/10/sys/compat/linux/linux_misc.h Sat Jul 15 09:04:23 2017 (r321008) +++ stable/10/sys/compat/linux/linux_misc.h Sat Jul 15 14:48:31 2017 (r321009) @@ -60,6 +60,8 @@ #define LINUX_MREMAP_MAYMOVE 1 #define LINUX_MREMAP_FIXED 2 +#define LINUX_PATH_MAX 4096 + extern const char *linux_kplatform; /* Modified: stable/10/sys/kern/vfs_cache.c ============================================================================== --- stable/10/sys/kern/vfs_cache.c Sat Jul 15 09:04:23 2017 (r321008) +++ stable/10/sys/kern/vfs_cache.c Sat Jul 15 14:48:31 2017 (r321009) @@ -1073,11 +1073,13 @@ int sys___getcwd(struct thread *td, 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; @@ -1088,8 +1090,8 @@ kern___getcwd(struct thread *td, char *buf, enum uio_s 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: stable/10/sys/sys/syscallsubr.h ============================================================================== --- stable/10/sys/sys/syscallsubr.h Sat Jul 15 09:04:23 2017 (r321008) +++ stable/10/sys/sys/syscallsubr.h Sat Jul 15 14:48:31 2017 (r321009) @@ -59,7 +59,7 @@ struct sched_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,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707151448.v6FEmV7I096241>