From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00085.outbound.protection.outlook.com [40.107.0.85]) by dpdk.org (Postfix) with ESMTP id 1812D3257 for ; Sun, 11 Nov 2018 12:39:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TXt3rERBbFzXW6gRZHIgO9Ag4KH7uY19PB2e39JHEXI=; b=XRm6Yal2Yus0gvOXhK/MHOILAj6HDz8aIPuhm+V3jh4PH4ClE6hb6swvPE4aCI62qur+1sUzSHDqvyp/ILkzGJE+/deJTCCAGnOY2iQfxpERJA7i3FqjOcfgfGMokogkBvkNZi0CVfoOXFJW4yTK3RofpF266QgpLPSuN5sliSQ= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4041.eurprd05.prod.outlook.com (52.134.66.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.29; Sun, 11 Nov 2018 11:39:30 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::58e7:97d8:f9c1:4323]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::58e7:97d8:f9c1:4323%3]) with mapi id 15.20.1294.044; Sun, 11 Nov 2018 11:39:30 +0000 From: Yongseok Koh To: Slava Ovsiienko CC: Shahaf Shuler , "dev@dpdk.org" Thread-Topic: [PATCH 2/3] net/mlx5: add Netlink message size check in rule cleanup Thread-Index: AQHUeNwQ5OfUe0D+wUCtIKtPJRxEn6VKdLGA Date: Sun, 11 Nov 2018 11:39:30 +0000 Message-ID: <7697EB15-EEED-4049-BD32-4FD40F9DF3C1@mellanox.com> References: <1541843951-31708-1-git-send-email-viacheslavo@mellanox.com> <1541843951-31708-3-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1541843951-31708-3-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-originating-ip: [69.181.245.183] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB4041; 6:q7yI8LT986jy4YrQlkBFTrx4McL/d9g5Xskqvi3FiJxtxB0ORTLj5uNVcz9LWqSV7rWzrNkoq/UaDUbry+hcfyqx74HC6E4BwurNZIJHmFaUxMtSjduULJ995f/jOOq0SZ2ZK3zmPvyWxPLpC11SVMV89MRsKegwYjS/6sIXLvwwA4YvrOE5M/v5GXM6JQXyStxUassFtqvJQxJdKHyScbzC5WimCqxcCDWHYLd9joT+0gH1tXG4DUyq6jhXYAIkkJmsAw/r4BPOs5/MJM4YP1D2lOhS1RlrY/jMAOrBpce3TKJqnK1h9afE2qf1s3tPivMif+19mDDqg33KjWvnemj3udx4jny6HgO2lFCG4RwPQ+1qvAaJPbvXDLkTQM1afNrfGchq/T06DR+btgez7c8lvAQM0MeOInlEu2D1Y8iAMkS616aZEmBtYN0yfNSyYJXwIr6nUnWNdYSNr9vXwg==; 5:lxLxq672moDgXrlU7SuHN6wS+owO5jX8eJcb6LznW2o/vPnsyOVhwhaIX0OKXHIKeDnHxsTjlJnIldtWbyboukVACHyrbRvqR99Y0w7jt/hSsRmUf6QnmmvpdZ1YgUhzKzJSlEzwA7emHGZm0Lij1Z+fiReLHjonKYw+44U6ak8=; 7:mCvZ5mIZU7D1AY4dn6GAyoCH5v0xSCDr+TFt/VEWodVqyn6zydgjR6y9bBL6pnWCm8tyNqmLOdIwjDj8l2drjUZWpuWWEWXtImMBvGT4ot83KQTEN29Z7rIE/NYw2a9NDb25FKhAKy5tW2VoyIP/NA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 9b3d5337-0a78-4bff-a872-08d647ca582f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390040)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB4041; x-ms-traffictypediagnostic: DB3PR0502MB4041: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231382)(944501410)(52105112)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB4041; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4041; x-forefront-prvs: 08534B37A7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(396003)(376002)(346002)(136003)(189003)(199004)(26005)(6506007)(486006)(54906003)(82746002)(68736007)(8936002)(53546011)(6862004)(83716004)(15650500001)(36756003)(6636002)(37006003)(86362001)(71190400001)(53936002)(229853002)(478600001)(446003)(66066001)(186003)(71200400001)(5660300001)(33656002)(97736004)(2900100001)(2906002)(76176011)(476003)(305945005)(6116002)(14444005)(5024004)(2616005)(3846002)(6512007)(316002)(14454004)(81156014)(81166006)(102836004)(6246003)(105586002)(4326008)(25786009)(8676002)(6486002)(99286004)(256004)(6436002)(11346002)(7736002)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4041; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: x+yNwy42awjrWNnwSdtMSd9HL5iOkQPi8mJ+SBV6bAl35ClwQ/2ywT9KnzkVEeUB0toSVHlPp52vdapriX4Hrc41C/iPsJFB/iEPnkzTyaOzr23PPNEGeBWrpoykFSu4OS0DUwRsKtGr8Ipt1ALxAvqKDSBmaPy8LlvRfBm/HquPgm63TY7qDCAIHwWbCUh2nlqOMeE/Qp5L9QhF5IH1kMUqwTnmfJHGQvZ5XPrf87yvOwA8giP6WsR59cWH0BVBmo7+hEAl1xNXHauA37z5Eh8FkXE5vEAiWrHfLjHJjBk8VbGKm6K5X3S3fMcbXXp0zHjbXtwATzRTMcNV3dGmvnTc2gwPQwz5mxbixZAgu9k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <7F33919F1AFBCE4AB408A168E9C0C62E@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b3d5337-0a78-4bff-a872-08d647ca582f X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Nov 2018 11:39:30.7363 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4041 Subject: Re: [dpdk-dev] [PATCH 2/3] net/mlx5: add Netlink message size check in rule cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Nov 2018 11:39:32 -0000 > On Nov 10, 2018, at 1:59 AM, Slava Ovsiienko w= rote: >=20 > This patch is preparation for the following fix, we are going to send > Netlink message from buffer in one-by-one fashion. It is highly > desirable to check multimessage buffer consistency for debug purposes. >=20 > Signed-off-by: Viacheslav Ovsiienko > --- Acked-by: Yongseok Koh =20 Thanks > drivers/net/mlx5/mlx5_flow_tcf.c | 33 ++++++++++++++++++++------------- > 1 file changed, 20 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flo= w_tcf.c > index ba0674a..bba8aed 100644 > --- a/drivers/net/mlx5/mlx5_flow_tcf.c > +++ b/drivers/net/mlx5/mlx5_flow_tcf.c > @@ -3935,6 +3935,7 @@ struct tcf_nlcb_context { > struct nlattr *na_local =3D NULL; > struct nlattr *na_peer =3D NULL; > unsigned char family; > + uint32_t size; >=20 > if (nlh->nlmsg_type !=3D RTM_NEWADDR) { > rte_errno =3D EINVAL; > @@ -3962,11 +3963,11 @@ struct tcf_nlcb_context { > if (!na_local || !na_peer) > return 1; > /* Local rule found with scope link, permanent and assigned peer. */ > - cmd =3D flow_tcf_alloc_nlcmd(ctx, MNL_ALIGN(sizeof(struct nlmsghdr)) + > - MNL_ALIGN(sizeof(struct ifaddrmsg)) + > - (family =3D=3D AF_INET6 > - ? 2 * SZ_NLATTR_DATA_OF(IPV6_ADDR_LEN) > - : 2 * SZ_NLATTR_TYPE_OF(uint32_t))); > + size =3D MNL_ALIGN(sizeof(struct nlmsghdr)) + > + MNL_ALIGN(sizeof(struct ifaddrmsg)) + > + (family =3D=3D AF_INET6 ? 2 * SZ_NLATTR_DATA_OF(IPV6_ADDR_LEN) > + : 2 * SZ_NLATTR_TYPE_OF(uint32_t)); > + cmd =3D flow_tcf_alloc_nlcmd(ctx, size); > if (!cmd) { > rte_errno =3D ENOMEM; > return -rte_errno; > @@ -3991,6 +3992,7 @@ struct tcf_nlcb_context { > mnl_attr_put(cmd, IFA_ADDRESS, IPV6_ADDR_LEN, > mnl_attr_get_payload(na_peer)); > } > + assert(size =3D=3D cmd->nlmsg_len); > return 1; > } >=20 > @@ -4059,6 +4061,7 @@ struct tcf_nlcb_context { > struct nlattr *na_ip =3D NULL; > struct nlattr *na_mac =3D NULL; > unsigned char family; > + uint32_t size; >=20 > if (nlh->nlmsg_type !=3D RTM_NEWNEIGH) { > rte_errno =3D EINVAL; > @@ -4085,12 +4088,12 @@ struct tcf_nlcb_context { > if (!na_mac || !na_ip) > return 1; > /* Neigh rule with permenent attribute found. */ > - cmd =3D flow_tcf_alloc_nlcmd(ctx, MNL_ALIGN(sizeof(struct nlmsghdr)) + > - MNL_ALIGN(sizeof(struct ndmsg)) + > - SZ_NLATTR_DATA_OF(ETHER_ADDR_LEN) + > - (family =3D=3D AF_INET6 > - ? SZ_NLATTR_DATA_OF(IPV6_ADDR_LEN) > - : SZ_NLATTR_TYPE_OF(uint32_t))); > + size =3D MNL_ALIGN(sizeof(struct nlmsghdr)) + > + MNL_ALIGN(sizeof(struct ndmsg)) + > + SZ_NLATTR_DATA_OF(ETHER_ADDR_LEN) + > + (family =3D=3D AF_INET6 ? SZ_NLATTR_DATA_OF(IPV6_ADDR_LEN) > + : SZ_NLATTR_TYPE_OF(uint32_t)); > + cmd =3D flow_tcf_alloc_nlcmd(ctx, size); > if (!cmd) { > rte_errno =3D ENOMEM; > return -rte_errno; > @@ -4113,6 +4116,7 @@ struct tcf_nlcb_context { > } > mnl_attr_put(cmd, NDA_LLADDR, ETHER_ADDR_LEN, > mnl_attr_get_payload(na_mac)); > + assert(size =3D=3D cmd->nlmsg_len); > return 1; > } >=20 > @@ -4179,6 +4183,7 @@ struct tcf_nlcb_context { > struct nlattr *na_vxlan =3D NULL; > bool found =3D false; > unsigned int vxindex; > + uint32_t size; >=20 > if (nlh->nlmsg_type !=3D RTM_NEWLINK) { > rte_errno =3D EINVAL; > @@ -4224,8 +4229,9 @@ struct tcf_nlcb_context { > return 1; > /* Attached VXLAN device found, store the command to delete. */ > vxindex =3D ifm->ifi_index; > - cmd =3D flow_tcf_alloc_nlcmd(ctx, MNL_ALIGN(sizeof(struct nlmsghdr)) + > - MNL_ALIGN(sizeof(struct ifinfomsg))); > + size =3D MNL_ALIGN(sizeof(struct nlmsghdr)) + > + MNL_ALIGN(sizeof(struct ifinfomsg)); > + cmd =3D flow_tcf_alloc_nlcmd(ctx, size); > if (!cmd) { > rte_errno =3D ENOMEM; > return -rte_errno; > @@ -4236,6 +4242,7 @@ struct tcf_nlcb_context { > ifm =3D mnl_nlmsg_put_extra_header(cmd, sizeof(*ifm)); > ifm->ifi_family =3D AF_UNSPEC; > ifm->ifi_index =3D vxindex; > + assert(size =3D=3D cmd->nlmsg_len); > return 1; > } >=20 > --=20 > 1.8.3.1 >=20