From owner-svn-src-all@freebsd.org Fri May 22 09:17:07 2020 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 B9AE732B6A0; Fri, 22 May 2020 09:17:07 +0000 (UTC) (envelope-from whu@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49T18g4Yjgz43L7; Fri, 22 May 2020 09:17:07 +0000 (UTC) (envelope-from whu@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 97C151C68D; Fri, 22 May 2020 09:17:07 +0000 (UTC) (envelope-from whu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04M9H7mx028709; Fri, 22 May 2020 09:17:07 GMT (envelope-from whu@FreeBSD.org) Received: (from whu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04M9H7oE028708; Fri, 22 May 2020 09:17:07 GMT (envelope-from whu@FreeBSD.org) Message-Id: <202005220917.04M9H7oE028708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: whu set sender to whu@FreeBSD.org using -f From: Wei Hu Date: Fri, 22 May 2020 09:17:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361360 - head/sys/dev/hyperv/hvsock X-SVN-Group: head X-SVN-Commit-Author: whu X-SVN-Commit-Paths: head/sys/dev/hyperv/hvsock X-SVN-Commit-Revision: 361360 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.33 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: Fri, 22 May 2020 09:17:07 -0000 Author: whu Date: Fri May 22 09:17:07 2020 New Revision: 361360 URL: https://svnweb.freebsd.org/changeset/base/361360 Log: Socket AF_HYPERV should return failure when it is not running on HyperV Reported by: pho Sponsored by: Microsoft Modified: head/sys/dev/hyperv/hvsock/hv_sock.c Modified: head/sys/dev/hyperv/hvsock/hv_sock.c ============================================================================== --- head/sys/dev/hyperv/hvsock/hv_sock.c Fri May 22 09:02:40 2020 (r361359) +++ head/sys/dev/hyperv/hvsock/hv_sock.c Fri May 22 09:17:07 2020 (r361360) @@ -354,6 +354,9 @@ hvs_trans_attach(struct socket *so, int proto, struct { struct hvs_pcb *pcb = so2hvspcb(so); + if (vm_guest != VM_GUEST_HV) + return (ESOCKTNOSUPPORT); + HVSOCK_DBG(HVSOCK_DBG_VERBOSE, "%s: HyperV Socket hvs_trans_attach called\n", __func__); @@ -380,6 +383,9 @@ hvs_trans_detach(struct socket *so) { struct hvs_pcb *pcb; + if (vm_guest != VM_GUEST_HV) + return; + HVSOCK_DBG(HVSOCK_DBG_VERBOSE, "%s: HyperV Socket hvs_trans_detach called\n", __func__); @@ -589,6 +595,9 @@ hvs_trans_disconnect(struct socket *so) { struct hvs_pcb *pcb; + if (vm_guest != VM_GUEST_HV) + return (ESOCKTNOSUPPORT); + HVSOCK_DBG(HVSOCK_DBG_VERBOSE, "%s: HyperV Socket hvs_trans_disconnect called\n", __func__); @@ -916,6 +925,9 @@ hvs_trans_close(struct socket *so) { struct hvs_pcb *pcb; + if (vm_guest != VM_GUEST_HV) + return; + HVSOCK_DBG(HVSOCK_DBG_VERBOSE, "%s: HyperV Socket hvs_trans_close called\n", __func__); @@ -956,6 +968,9 @@ void hvs_trans_abort(struct socket *so) { struct hvs_pcb *pcb = so2hvspcb(so); + + if (vm_guest != VM_GUEST_HV) + return; HVSOCK_DBG(HVSOCK_DBG_VERBOSE, "%s: HyperV Socket hvs_trans_abort called\n", __func__);