From owner-svn-src-all@freebsd.org Mon Apr 16 19:33:05 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66045F9F9F0; Mon, 16 Apr 2018 19:33:05 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 091DD7336B; Mon, 16 Apr 2018 19:33:05 +0000 (UTC) (envelope-from cem@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0084821AB3; Mon, 16 Apr 2018 19:33:05 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3GJX41C001629; Mon, 16 Apr 2018 19:33:04 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3GJX4Yj001628; Mon, 16 Apr 2018 19:33:04 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201804161933.w3GJX4Yj001628@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Mon, 16 Apr 2018 19:33:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332632 - head/usr.bin/quota X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/usr.bin/quota X-SVN-Commit-Revision: 332632 X-SVN-Commit-Repository: base 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.25 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: Mon, 16 Apr 2018 19:33:05 -0000 Author: cem Date: Mon Apr 16 19:33:04 2018 New Revision: 332632 URL: https://svnweb.freebsd.org/changeset/base/332632 Log: quota(1): Fix calculation overflow and underflow For very large quotas, do the multiplication as a 64 bit value to avoid overflow. For very small block sizes (smaller than DEV_BSIZE), multiple first before dividing by block size to avoid underflow. PR: 227496 Submitted by: Per Andersson Sponsored by: Dell EMC Isilon Modified: head/usr.bin/quota/quota.c Modified: head/usr.bin/quota/quota.c ============================================================================== --- head/usr.bin/quota/quota.c Mon Apr 16 18:12:15 2018 (r332631) +++ head/usr.bin/quota/quota.c Mon Apr 16 19:33:04 2018 (r332632) @@ -621,14 +621,14 @@ getnfsquota(struct statfs *fst, struct quotause *qup, gettimeofday(&tv, NULL); /* blocks*/ dqp->dqb_bhardlimit = - gq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit * - (gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE); + ((uint64_t)gq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit * + gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize) / DEV_BSIZE; dqp->dqb_bsoftlimit = - gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit * - (gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE); + ((uint64_t)gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit * + gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize) / DEV_BSIZE; dqp->dqb_curblocks = - gq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks * - (gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE); + ((uint64_t)gq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks * + gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize) / DEV_BSIZE; /* inodes */ dqp->dqb_ihardlimit = gq_rslt.getquota_rslt_u.gqr_rquota.rq_fhardlimit;