From owner-svn-src-stable-10@freebsd.org Wed Dec 4 17:45:36 2019 Return-Path: Delivered-To: svn-src-stable-10@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 27B7E1A9BC0; Wed, 4 Dec 2019 17:45:36 +0000 (UTC) (envelope-from dim@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 47SmTr0HD6z48MN; Wed, 4 Dec 2019 17:45:36 +0000 (UTC) (envelope-from dim@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 DD9B53DA5; Wed, 4 Dec 2019 17:45:35 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB4HjZqx081498; Wed, 4 Dec 2019 17:45:35 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB4HjZ9O081496; Wed, 4 Dec 2019 17:45:35 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201912041745.xB4HjZ9O081496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 4 Dec 2019 17:45:35 +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: r355395 - in stable: 10/lib/msun/src 11/lib/msun/src 12/lib/msun/src X-SVN-Group: stable-10 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/lib/msun/src 11/lib/msun/src 12/lib/msun/src X-SVN-Commit-Revision: 355395 X-SVN-Commit-Repository: base 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.29 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: Wed, 04 Dec 2019 17:45:36 -0000 Author: dim Date: Wed Dec 4 17:45:34 2019 New Revision: 355395 URL: https://svnweb.freebsd.org/changeset/base/355395 Log: r355120 | dim | 2019-11-26 23:01:09 +0100 (Tue, 26 Nov 2019) | 32 lines The fdlibm hypot() implementations shouldn't potentially left-shift negative numbers (invoking undefined behavior) Summary: Various paths through hypot(x, y) will multiply x and y by a power of two, perform the calculation in a range where IEEE-754 provides greater precision, then undo the multiplication to determine the true result. Undoing that multiplication is implemented as t1*w, where t1=2**k. 2**k is often computed by taking the high word of 1.0, then adding k<<20 (for doubles or long doubles) or k<<23 (for floats) to it, then overwriting that high word. But when k is negative this left-shifts a negative value -- and that's undefined behavior in many editions of C and C++. This patch should fix all hypot implementations to compute 2**k without triggering this particular bit of undefined behavior. Test Plan: I've only very lightly tested out the hypot(double, double) change, in SpiderMonkey's JavaScript engine, for consistency with prior behavior. The other functions' changes have more or less only been eyeballed. Careful examination appreciated! Do note, however, that an error in any of these changes would most likely produce a value that is incorrect by a factor of two, so any mistake would most likely be glaring if invoked. Submitted by: Jeff Walden Obtained from: https://github.com/freebsd/freebsd/pull/414 Reviewed by: dim, lwhsu Differential Revision: https://reviews.freebsd.org/D22354 Modified: stable/10/lib/msun/src/e_hypot.c stable/10/lib/msun/src/e_hypotf.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/lib/msun/src/e_hypot.c stable/11/lib/msun/src/e_hypotf.c stable/12/lib/msun/src/e_hypot.c stable/12/lib/msun/src/e_hypotf.c Directory Properties: stable/11/ (props changed) stable/12/ (props changed) Modified: stable/10/lib/msun/src/e_hypot.c ============================================================================== --- stable/10/lib/msun/src/e_hypot.c Wed Dec 4 16:56:11 2019 (r355394) +++ stable/10/lib/msun/src/e_hypot.c Wed Dec 4 17:45:34 2019 (r355395) @@ -118,10 +118,8 @@ __ieee754_hypot(double x, double y) w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); } if(k!=0) { - u_int32_t high; - t1 = 1.0; - GET_HIGH_WORD(high,t1); - SET_HIGH_WORD(t1,high+(k<<20)); + t1 = 0.0; + SET_HIGH_WORD(t1,(1023+k)<<20); return t1*w; } else return w; } Modified: stable/10/lib/msun/src/e_hypotf.c ============================================================================== --- stable/10/lib/msun/src/e_hypotf.c Wed Dec 4 16:56:11 2019 (r355394) +++ stable/10/lib/msun/src/e_hypotf.c Wed Dec 4 17:45:34 2019 (r355395) @@ -77,7 +77,7 @@ __ieee754_hypotf(float x, float y) w = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b))); } if(k!=0) { - SET_FLOAT_WORD(t1,0x3f800000+(k<<23)); + SET_FLOAT_WORD(t1,(127+k)<<23); return t1*w; } else return w; } From owner-svn-src-stable-10@freebsd.org Thu Dec 5 14:53:47 2019 Return-Path: Delivered-To: svn-src-stable-10@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 83AAB1CB6BB; Thu, 5 Dec 2019 14:53:47 +0000 (UTC) (envelope-from hselasky@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 47TJd72vgCz4HTM; Thu, 5 Dec 2019 14:53:47 +0000 (UTC) (envelope-from hselasky@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 2E6D31A943; Thu, 5 Dec 2019 14:53:47 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB5Erlp1032240; Thu, 5 Dec 2019 14:53:47 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB5ErkcH032239; Thu, 5 Dec 2019 14:53:46 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201912051453.xB5ErkcH032239@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 5 Dec 2019 14:53:46 +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: r355419 - stable/10/sys/kern X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/kern X-SVN-Commit-Revision: 355419 X-SVN-Commit-Repository: base 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.29 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: Thu, 05 Dec 2019 14:53:47 -0000 Author: hselasky Date: Thu Dec 5 14:53:46 2019 New Revision: 355419 URL: https://svnweb.freebsd.org/changeset/base/355419 Log: MFC r355108 and r355170: Fix panic when loading kernel modules before root file system is mounted. Make sure the rootvnode is always NULL checked. Differential Revision: https://reviews.freebsd.org/D22545 PR: 241639 Sponsored by: Mellanox Technologies Modified: stable/10/sys/kern/kern_linker.c stable/10/sys/kern/subr_firmware.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_linker.c ============================================================================== --- stable/10/sys/kern/kern_linker.c Thu Dec 5 14:52:06 2019 (r355418) +++ stable/10/sys/kern/kern_linker.c Thu Dec 5 14:53:46 2019 (r355419) @@ -2000,14 +2000,18 @@ linker_load_module(const char *kldname, const char *mo */ KASSERT(verinfo == NULL, ("linker_load_module: verinfo" " is not NULL")); + /* check if root file system is not mounted */ + if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL) + return (ENXIO); pathname = linker_search_kld(kldname); } else { if (modlist_lookup2(modname, verinfo) != NULL) return (EEXIST); + /* check if root file system is not mounted */ + if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL) + return (ENXIO); if (kldname != NULL) pathname = strdup(kldname, M_LINKER); - else if (rootvnode == NULL) - pathname = NULL; else /* * Need to find a KLD with required module Modified: stable/10/sys/kern/subr_firmware.c ============================================================================== --- stable/10/sys/kern/subr_firmware.c Thu Dec 5 14:52:06 2019 (r355418) +++ stable/10/sys/kern/subr_firmware.c Thu Dec 5 14:53:46 2019 (r355419) @@ -255,7 +255,6 @@ firmware_unregister(const char *imagename) static void loadimage(void *arg, int npending) { - struct thread *td = curthread; char *imagename = arg; struct priv_fw *fp; linker_file_t result; @@ -265,11 +264,6 @@ loadimage(void *arg, int npending) mtx_lock(&firmware_mtx); mtx_unlock(&firmware_mtx); - if (td->td_proc->p_fd->fd_rdir == NULL) { - printf("%s: root not mounted yet, no way to load image\n", - imagename); - goto done; - } error = linker_reference_module(imagename, NULL, &result); if (error != 0) { printf("%s: could not load firmware image, error %d\n",