Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp783199ybe; Fri, 13 Sep 2019 06:19:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwXecevFQFt+L12oh7gNkJ8trbSw22vzPHwHKTLQOWWNNt/ORnhIy4CbUgr4Pft/TAYZ/A X-Received: by 2002:aa7:c1d4:: with SMTP id d20mr1682411edp.223.1568380782627; Fri, 13 Sep 2019 06:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568380782; cv=none; d=google.com; s=arc-20160816; b=eC/V3LcrEgfQoIRitASUB6q0A8xHiEDJdZ6nHU+jPTxcBDKhdsPRCA6UH5S3b2+c87 yyXaAvSNzsF49dGWDAVKHKTizPBVqQfhB7b1exuWLcdxDst1J9SDYMbkMkMz9dGiWnWf XGb/EFhm19FLt6YULjQvS4YAfMFweIp5EAn81m7j7QAOrMXhshGx/EKROMnB8VfTCQaT VAJ6MeSuyb8fsNCpTx2VdGFPn2HxQDo3TgfLr2PiS7FduNrnKnjxpEjnm4XDfVn1fMHc n1K7Ryawwi8YoZSIPi2q7DgiXJiV/HRhKQobBTWvmeCIrvINy43NZs+rQ+t7awoEhZ+l z2Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+KqygcthlAEX5U+MW25NG2D6DoPccjx7L3qZbRvgyKE=; b=W4h/WDTdv7KHNQoLORQosHOL6agguVfDi/Qz2fXCHlXHvFgk0FS1H3Yiocl/9W0zu+ imo987wy1NTYcNfIR0DLJSxtGz7MqX4pQkuMN+Dnu3hwLO8lY+SFevV7QCfltvB36i0i 3z+wpY4vMoQTen7KGokDFFQa9NRByYEQLCIqdHQaSPt8AYlkV9m9rWvqLNDJaQbDIOwf m+siVByZTY/aRDSekscs1Tl63Zaw4vAOZQXwcK56oxdmWBH92sG0qH5+QGP+cfwsommA bLF8XIwu4ePNP+tPBc22KGcOcRF286tEXwadBMdZP8CN09RUGX//TYgPGZUXUqvBVKFB 0hQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mxDP5eUh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si8108655ejn.20.2019.09.13.06.19.19; Fri, 13 Sep 2019 06:19:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mxDP5eUh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389523AbfIMNO2 (ORCPT + 99 others); Fri, 13 Sep 2019 09:14:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:40362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389520AbfIMNO0 (ORCPT ); Fri, 13 Sep 2019 09:14:26 -0400 Received: from localhost (unknown [104.132.45.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2E4F214AE; Fri, 13 Sep 2019 13:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380465; bh=3mAQ9lNo8/G4qstAGCcxNn9wlempJnmli19RkMJo0Qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxDP5eUh/YdGM9uum1qe2mB2svR1SdoaxarlmIDzoT6zF+D5AMhdW0oGmYVZowcwX liZaNF89iKeO+ahGJFvgq/dxS7tkGne+8+04AGtWWrRT911pZ0tWznsC4rRETzI743 6C/rIWDJO6rkqgiE15e7EGLJEtrAem8CkS/9ciFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dexuan Cui , "K. Y. Srinivasan" , Stephen Hemminger , Haiyang Zhang , Stable@vger.kernel.org, Sasha Levin Subject: [PATCH 4.19 050/190] Drivers: hv: kvp: Fix the recent regression caused by incorrect clean-up Date: Fri, 13 Sep 2019 14:05:05 +0100 Message-Id: <20190913130603.776628737@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130559.669563815@linuxfoundation.org> References: <20190913130559.669563815@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e670de54c813b5bc3672dd1c67871dc60e9206f4 ] In kvp_send_key(), we do need call process_ib_ipinfo() if message->kvp_hdr.operation is KVP_OP_GET_IP_INFO, because it turns out the userland hv_kvp_daemon needs the info of operation, adapter_id and addr_family. With the incorrect fc62c3b1977d, the host can't get the VM's IP via KVP. And, fc62c3b1977d added a "break;", but actually forgot to initialize the key_size/value in the case of KVP_OP_SET, so the default key_size of 0 is passed to the kvp daemon, and the pool files /var/lib/hyperv/.kvp_pool_* can't be updated. This patch effectively rolls back the previous fc62c3b1977d, and correctly fixes the "this statement may fall through" warnings. This patch is tested on WS 2012 R2 and 2016. Fixes: fc62c3b1977d ("Drivers: hv: kvp: Fix two "this statement may fall through" warnings") Signed-off-by: Dexuan Cui Cc: K. Y. Srinivasan Cc: Stephen Hemminger Signed-off-by: Haiyang Zhang Cc: Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/hv/hv_kvp.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c index a7513a8a8e372..d6106e1a0d4af 100644 --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -353,6 +353,9 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, int op) out->body.kvp_ip_val.dhcp_enabled = in->kvp_ip_val.dhcp_enabled; + /* fallthrough */ + + case KVP_OP_GET_IP_INFO: utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.adapter_id, MAX_ADAPTER_ID_SIZE, UTF16_LITTLE_ENDIAN, @@ -405,7 +408,11 @@ kvp_send_key(struct work_struct *dummy) process_ib_ipinfo(in_msg, message, KVP_OP_SET_IP_INFO); break; case KVP_OP_GET_IP_INFO: - /* We only need to pass on message->kvp_hdr.operation. */ + /* + * We only need to pass on the info of operation, adapter_id + * and addr_family to the userland kvp daemon. + */ + process_ib_ipinfo(in_msg, message, KVP_OP_GET_IP_INFO); break; case KVP_OP_SET: switch (in_msg->body.kvp_set.data.value_type) { @@ -446,9 +453,9 @@ kvp_send_key(struct work_struct *dummy) } - break; - - case KVP_OP_GET: + /* + * The key is always a string - utf16 encoding. + */ message->body.kvp_set.data.key_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_set.data.key, @@ -456,6 +463,17 @@ kvp_send_key(struct work_struct *dummy) UTF16_LITTLE_ENDIAN, message->body.kvp_set.data.key, HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1; + + break; + + case KVP_OP_GET: + message->body.kvp_get.data.key_size = + utf16s_to_utf8s( + (wchar_t *)in_msg->body.kvp_get.data.key, + in_msg->body.kvp_get.data.key_size, + UTF16_LITTLE_ENDIAN, + message->body.kvp_get.data.key, + HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1; break; case KVP_OP_DELETE: -- 2.20.1