Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932067AbcC1KJK (ORCPT ); Mon, 28 Mar 2016 06:09:10 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:12218 "EHLO cmccmta1.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbcC1KJI (ORCPT ); Mon, 28 Mar 2016 06:09:08 -0400 X-RM-TRANSID: 2ee456f902be572-0f8dc X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee956f902be04c-7742d From: Haishuang Yan To: "David S. Miller" , Pravin Shelar Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dev@openvswitch.org, Haishuang Yan Subject: [PATCH] openvswitch: Use proper buffer size in nla_memcpy Date: Mon, 28 Mar 2016 18:08:59 +0800 Message-Id: <1459159739-51541-1-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 852 Lines: 28 For the input parameter count, it's better to use the size of destination buffer size, as nla_memcpy would take into account the length of the source netlink attribute when a data is copied from an attribute. Signed-off-by: Haishuang Yan --- net/openvswitch/conntrack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index dc5eb29..f8a8d43 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -968,7 +968,8 @@ static int parse_nat(const struct nlattr *attr, break; case OVS_NAT_ATTR_IP_MIN: - nla_memcpy(&info->range.min_addr, a, nla_len(a)); + nla_memcpy(&info->range.min_addr, a, + sizeof(info->range.min_addr)); info->range.flags |= NF_NAT_RANGE_MAP_IPS; break; -- 1.8.3.1