From owner-svn-src-stable-10@freebsd.org Sun Mar 27 06:21:06 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33CE2ADF730; Sun, 27 Mar 2016 06:21:06 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 0DEE41114; Sun, 27 Mar 2016 06:21:05 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2R6L5UX008717; Sun, 27 Mar 2016 06:21:05 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2R6L5gF008716; Sun, 27 Mar 2016 06:21:05 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201603270621.u2R6L5gF008716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 27 Mar 2016 06:21:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r297302 - stable/10/sys/compat/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2016 06:21:06 -0000 Author: dchagin Date: Sun Mar 27 06:21:05 2016 New Revision: 297302 URL: https://svnweb.freebsd.org/changeset/base/297302 Log: MFC r297063: Whitespaces, style(9) fixes. No functional changes. MFC r297070: Return EOVERFLOW in case when actual statfs values are large enough and not fit into 32 bit fileds of a Linux struct statfs. MFC r297072: Check bsd_to_linux_statfs() return value. Modified: stable/10/sys/compat/linux/linux_stats.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/compat/linux/linux_stats.c ============================================================================== --- stable/10/sys/compat/linux/linux_stats.c Sun Mar 27 06:17:19 2016 (r297301) +++ stable/10/sys/compat/linux/linux_stats.c Sun Mar 27 06:21:05 2016 (r297302) @@ -256,7 +256,7 @@ static int stat_copyout(struct stat *buf, void *ubuf) { struct l_stat lbuf; - + bzero(&lbuf, sizeof(lbuf)); lbuf.st_dev = buf->st_dev; lbuf.st_ino = buf->st_ino; @@ -302,7 +302,7 @@ linux_stat(struct thread *td, struct lin return (error); } LFREEPATH(path); - return(stat_copyout(&buf, args->up)); + return (stat_copyout(&buf, args->up)); } int @@ -324,7 +324,7 @@ linux_lstat(struct thread *td, struct li return (error); } LFREEPATH(path); - return(stat_copyout(&buf, args->up)); + return (stat_copyout(&buf, args->up)); } #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ @@ -380,10 +380,22 @@ bsd_to_linux_ftype(const char *fstypenam return (0L); } -static void +static int bsd_to_linux_statfs(struct statfs *bsd_statfs, struct l_statfs *linux_statfs) { +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) + uint64_t tmp; +#define LINUX_HIBITS 0xffffffff00000000ULL + + tmp = bsd_statfs->f_blocks | bsd_statfs->f_bfree | bsd_statfs->f_files | + bsd_statfs->f_bsize; + if ((bsd_statfs->f_bavail != -1 && (bsd_statfs->f_bavail & LINUX_HIBITS)) || + (bsd_statfs->f_ffree != -1 && (bsd_statfs->f_ffree & LINUX_HIBITS)) || + (tmp & LINUX_HIBITS)) + return (EOVERFLOW); +#undef LINUX_HIBITS +#endif linux_statfs->f_type = bsd_to_linux_ftype(bsd_statfs->f_fstypename); linux_statfs->f_bsize = bsd_statfs->f_bsize; linux_statfs->f_blocks = bsd_statfs->f_blocks; @@ -394,6 +406,8 @@ bsd_to_linux_statfs(struct statfs *bsd_s linux_statfs->f_fsid.val[0] = bsd_statfs->f_fsid.val[0]; linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs->f_namelen = MAXNAMLEN; + + return (0); } int @@ -414,8 +428,10 @@ linux_statfs(struct thread *td, struct l LFREEPATH(path); if (error) return (error); - bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); - return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); + error = bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); + if (error) + return (error); + return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); } #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) @@ -457,7 +473,7 @@ linux_statfs64(struct thread *td, struct if (error) return (error); bsd_to_linux_statfs64(&bsd_statfs, &linux_statfs); - return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); + return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); } int @@ -495,9 +511,11 @@ linux_fstatfs(struct thread *td, struct #endif error = kern_fstatfs(td, args->fd, &bsd_statfs); if (error) - return error; - bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); - return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); + return (error); + error = bsd_to_linux_statfs(&bsd_statfs, &linux_statfs); + if (error) + return (error); + return (copyout(&linux_statfs, args->buf, sizeof(linux_statfs))); } struct l_ustat