Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751794AbdHFUOZ (ORCPT ); Sun, 6 Aug 2017 16:14:25 -0400 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:52792 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399AbdHFUN7 (ORCPT ); Sun, 6 Aug 2017 16:13:59 -0400 x-originating-ip: 107.180.71.197 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: Alex Ng , "K. Y. Srinivasan" Subject: [PATCH 5/5] Drivers: hv: kvp: Use MAX_ADAPTER_ID_SIZE for translating adapter id Date: Sun, 6 Aug 2017 13:12:56 -0700 Message-Id: <1502050376-23662-5-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1502050348-23624-1-git-send-email-kys@exchange.microsoft.com> References: <1502050348-23624-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfGeuFpaOpLzHhL5eg4u39Ufo9P4qgJnI9bZComEstQN52jIS/LiPBLe021kdaDFZSJx9BqEUONqKekDE4DVJJSI5g2+GUvk0d6wywhzB/Rwk4+vS7Vjj DRI68hApZtQJtWXyyidlMFj+KylggavKSY3agxFE1sPlHVj8m39LZUKDtE03qHsWeccux/eI7ZlRN4CucjnRxltfMWXEO2bnWHyV05WuoY68rlhOhGl0NANU 0PilyzIMx6xP1Xqrd4dbOj16SvDDQn+sRvKJxac/si4rMK6LjfeQYZoJcFKZlLrM8BBFSxcXvUFaZ95M86hUmL86CWHhhJdmndbP1uHV+kD7Nes2RVHCwXO+ RrOm9vfSWqt1wa4d8esLPZxEzplpJvtSIqJoVSHhGmkj+k2z/k55HwnPg9b5wX7Kpwf+/n5kLx9ZMiEnVuz/QfSldDKGh3Yl2+lh7X+zAGhZq0As1opW2ljY ofOGCiJUVs35Y3fzL9LwJ0PoBlvlytzCtDowZJMzTmq+T6tc/XDQGRKpYXwDagI45/Hr55chy5gAFc4CMMb+K+QnThL5t9j7WlZNA2AUf/6agFvX0TVM8C1O pmk= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1037 Lines: 31 From: Alex Ng There's a bug which passes the output buffer size as MAX_IP_ADDR_SIZE, when converting the adapter_id field to UTF16. This is much larger than the actual size (MAX_ADAPTER_ID_SIZE). Fix this by passing the proper size. Fortunately, the translation is limited by the length of the input. This explains why we haven't seen output buffer overflow conditions. Signed-off-by: Alex Ng Signed-off-by: K. Y. Srinivasan --- drivers/hv/hv_kvp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c index 9a90b91..5eed1e7 100644 --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -304,7 +304,7 @@ static int process_ob_ipinfo(void *in_msg, void *out_msg, int op) strlen((char *)in->body.kvp_ip_val.adapter_id), UTF16_HOST_ENDIAN, (wchar_t *)out->kvp_ip_val.adapter_id, - MAX_IP_ADDR_SIZE); + MAX_ADAPTER_ID_SIZE); if (len < 0) return len; -- 1.7.1