From owner-svn-src-all@freebsd.org Wed Oct 23 16:06:48 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3ADC7156EF6; Wed, 23 Oct 2019 16:06:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46ywHD0fqKz4JKx; Wed, 23 Oct 2019 16:06:48 +0000 (UTC) (envelope-from kib@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 EF5AE26F27; Wed, 23 Oct 2019 16:06:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NG6lrn009337; Wed, 23 Oct 2019 16:06:47 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NG6lBH009336; Wed, 23 Oct 2019 16:06:47 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201910231606.x9NG6lBH009336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 23 Oct 2019 16:06:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353930 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 353930 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.29 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: Wed, 23 Oct 2019 16:06:48 -0000 Author: kib Date: Wed Oct 23 16:06:47 2019 New Revision: 353930 URL: https://svnweb.freebsd.org/changeset/base/353930 Log: Fix undefined behavior. Create a sequence point by ending a full expression for call to vspace() and use of the globals which are modified by vspace(). Reported and reviewed by: imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D22126 Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Wed Oct 23 16:05:52 2019 (r353929) +++ head/sys/kern/vfs_subr.c Wed Oct 23 16:06:47 2019 (r353930) @@ -1273,7 +1273,7 @@ vnlru_proc(void) { struct mount *mp, *nmp; unsigned long onumvnodes; - int done, force, trigger, usevnodes; + int done, force, trigger, usevnodes, vsp; bool reclaim_nc_src; EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, vnlruproc, @@ -1301,7 +1301,8 @@ vnlru_proc(void) force = 1; vstir = 0; } - if (vspace() >= vlowat && force == 0) { + vsp = vspace(); + if (vsp >= vlowat && force == 0) { vnlruproc_sig = 0; wakeup(&vnlruproc_sig); msleep(vnlruproc, &vnode_free_list_mtx, @@ -1368,7 +1369,8 @@ vnlru_proc(void) * After becoming active to expand above low water, keep * active until above high water. */ - force = vspace() < vhiwat; + vsp = vspace(); + force = vsp < vhiwat; } } @@ -1447,8 +1449,10 @@ vtryrecycle(struct vnode *vp) static void vcheckspace(void) { + int vsp; - if (vspace() < vlowat && vnlruproc_sig == 0) { + vsp = vspace(); + if (vsp < vlowat && vnlruproc_sig == 0) { vnlruproc_sig = 1; wakeup(vnlruproc); }