From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3824FA04A2 for ; Sun, 17 May 2020 14:51:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1E0071D5A4; Sun, 17 May 2020 14:51:11 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140047.outbound.protection.outlook.com [40.107.14.47]) by dpdk.org (Postfix) with ESMTP id 16B561D563; Sun, 17 May 2020 14:51:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hO51+54tL+FQY7RwOWWBejQg3PJBRSX7s27fQvbWmKy009mXyfVoYO0pWC6avhEC45tGjVT5Byp95EQ4wxFDWtYHZBui/zyJrlx5J3IKFKgJMd09oklEWuJRG1u9MJ4xkhAfQj6Ml0WW8NLft1AZMma85sVxOMIErt6G6vOQRd9iYhtr/UfZ1nivymAdUguI6q98tqu9zCLBJgx4QXwhdaQCKAlIDrfH6eB8BEw2+lOy1BOfZ8OFhHzlECQ/G1d0K1Ee4ur/Jd875JnI+U9dbTj18OnYHWXq8awGCspNa/HqlffNij5eLruELhz89/QRZwVr/tnPFOiWOV6XcCiRlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cI679gjWSqYpZyVaO5+Sik0iHKAx2XBxjB4TAO3Q84k=; b=dAPhSZEcWc8gj/9Iq4LOCDcTy9AoClbLmXxK78bPdlcMr3QmCRNbf176z9E9slCw52O/FIvdQ5lKBJrAIwBraKJTBx1JH6oz36L6e+i+ExvqZ0YO/LDe5EOaPY8uQ8o+mqNQEDjuSHK1Vb57AGWw+I5mwXoK3I14KucsYFr+D1pISjgvXMOkWS4KAb6x2cJd6Y9IUahCJu8pMYRwueXzAyMkxo9kLLzXY7WKoxHfkZwUsLlo6MH8H38zoKP/y19Rjo8dv7b9ee35MqPShmtaPq35bSk6auHWnhnah86KvsEOH/vtpB+yNg8vhFjPx9cBM5OtwlkNoPpCbB1OcLIyvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=cI679gjWSqYpZyVaO5+Sik0iHKAx2XBxjB4TAO3Q84k=; b=M5nr3jEuOS6WI12gj+DiJ3jtewgNRq+kbKKmzFR4iAjOtbYd9RKlGgcpQDEwgHIQUI557aDukLSNdylhYa/Iju8S39/sFt4uxjyJUZWUMkDV/BmlDG5e0UMtXQ67WgE/rLVAGzC19B6jFwY89U1h0Qo2Dufj43nrdN0IH3gPPoU= Received: from AM0PR05MB6707.eurprd05.prod.outlook.com (2603:10a6:20b:15b::17) by AM0PR05MB6515.eurprd05.prod.outlook.com (2603:10a6:208:143::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26; Sun, 17 May 2020 12:51:06 +0000 Received: from AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e]) by AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e%6]) with mapi id 15.20.3000.022; Sun, 17 May 2020 12:51:06 +0000 From: Raslan Darawsheh To: Slava Ovsiienko , "dev@dpdk.org" CC: Matan Azrad , "stephen@networkplumber.org" , =?iso-8859-1?Q?N=E9lio_Laranjeiro?= , "stable@dpdk.org" Thread-Topic: [PATCH v2] common/mlx5: fix netlink buffer allocation from stack Thread-Index: AQHWKb7sTdstvpGhNUei623VMdUDDKisQBqw Date: Sun, 17 May 2020 12:51:06 +0000 Message-ID: References: <20200422223000.16602-1-stephen@networkplumber.org> <1589440272-8058-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: <1589440272-8058-1-git-send-email-viacheslavo@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [188.161.229.217] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 3377a7d8-5d28-4d41-46d3-08d7fa60f6f4 x-ms-traffictypediagnostic: AM0PR05MB6515: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3173; x-forefront-prvs: 040655413E x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MP6gW/7ip/VYALudXMIzX9wkPwchtT3HykCRkWGXvX12b595hDMgRik5z1JL4geUPe8LStuUZdV3Z1mQAMfl2hnY9WKTc67hV3Wz7JZ0moEmdpBGGD4Xz3T8o8NvyposBcsT9LSBmT11iuMOS9kP136ljf04ad6/2pceMUYirIekEZ+mcz8pXw7yBLD4zr3oMQRDWmP6G8KSokMBHFf+nb/yUD/fghEgYDWNpCeFZBKcI9OeMyOnkCo8YfcRAl76Z2zH7E+/TYUPyQ3YQVAmwSSxIQUOYhyegmjuhyAnOPrUteQv+aIDFyaxqAO8PKumrxtpEsFWT1cyprk7VlMHlI/4fQvCQtGO92jM/gzKbSJWQ2h0IDWXcmo3FsdsVWcaPflqaFr9d1Y0bNFxuwEGgazaiePUbMxXFFwJTRlozYE1VBLNcvp3znP0yUwrWrad4espm0DEez7ManKgvwczOLZVIarYNtYPkKlAd2w+YUKLS3JJR2UMTnisFO72AK9dga4ZT0chmn6EaSjzjlu51w== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6707.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(396003)(366004)(376002)(136003)(346002)(4326008)(66946007)(53546011)(33656002)(71200400001)(54906003)(316002)(110136005)(83080400001)(66556008)(66476007)(8676002)(55016002)(9686003)(7696005)(6506007)(76116006)(8936002)(5660300002)(966005)(66574014)(186003)(86362001)(478600001)(2906002)(45080400002)(64756008)(66446008)(26005)(52536014); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: esBvGXAEqbMClJ5lgZQXSsEoCR9w2PiNObRPCx94w4LkWJhnWi5uV6+RFzaGLeu6Y6ACBEj15+R9iUrsGJVbNLFMVEXsWrmcPzZoseLZCpL+AqDKL4B/rvcDbc8DNGnPqqmlWUnZkSiq5ZcvtMx+Y7GJtTq/vtV6AuIm15A4PCu6XDgMuC5vAjjW0ph9MErRrNXqSTGrUoTI+wTh244VVIncyKYFMIMayY4baZ+BK68c6xF0fb4mVxEsh4l6boHxgqPpjsw/GU+FL6h/N955s0BcQH7STS8bGikJKgnNhDzbS8J0jhAwyKbbtgRs84Y//rSAbhR9D/NRUfYjjzR0oqPGuGRVyOV3DMMjl7MY2RKkICeNFusTD26plJkvlD/c+zia9z9qYGLuVRZiMSoyzA6P6wNJpDfQBQGVVhQvT8IpS7CI8sxAIlfNAY0nVJa/34osjI2FlG/3huXU0mOTpm6Ia0xTjxoe3wNneEtHgcIoRmmK94pIjRBYtN02e5Wd Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3377a7d8-5d28-4d41-46d3-08d7fa60f6f4 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2020 12:51:06.2227 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: otdh6lGKri9RyYUVInfbY+7ndYEHhtXe8opSLmvYF6eL9bXj8+11VaSecXOAc8S5AE+HFiw9lMQiqrDBn+lNJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6515 Subject: Re: [dpdk-stable] [PATCH v2] common/mlx5: fix netlink buffer allocation from stack X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, > -----Original Message----- > From: Viacheslav Ovsiienko > Sent: Thursday, May 14, 2020 10:11 AM > To: dev@dpdk.org > Cc: Matan Azrad ; Raslan Darawsheh > ; stephen@networkplumber.org; N=E9lio Laranjeiro > ; stable@dpdk.org > Subject: [PATCH v2] common/mlx5: fix netlink buffer allocation from stack >=20 > The buffer size to receive netlink reply messages is relatively > large (32K), and it is allocated on the stack and it might > break in application is using smaller per-thread stacks. > This patch allocates temporary buffer from heap. >=20 > Fixes: ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses") > Cc: nelio.laranjeiro@6wind.com > Cc: stable@dpdk.org >=20 > Reported-by: Stephen Hemminger > Signed-off-by: Viacheslav Ovsiienko >=20 > --- > v2: allocation from heap, instead of reducing buffer size > v1: > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatch > es.dpdk.org%2Fpatch%2F69158%2F&data=3D02%7C01%7Crasland%40mell > anox.com%7C1e38e272cede42d2cfc008d7f7d60e00%7Ca652971c7d2e4d9ba6 > a4d149256f461b%7C0%7C0%7C637250371034928200&sdata=3DcZ1hFsnSZz > 5oMj8zOLbB6vmcthY1FnPZWa%2FgoNDibmg%3D&reserved=3D0 > --- > drivers/common/mlx5/mlx5_nl.c | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/common/mlx5/mlx5_nl.c > b/drivers/common/mlx5/mlx5_nl.c > index 65efcd3..1a1033a 100644 > --- a/drivers/common/mlx5/mlx5_nl.c > +++ b/drivers/common/mlx5/mlx5_nl.c > @@ -330,10 +330,10 @@ struct mlx5_nl_ifindex_data { > void *arg) > { > struct sockaddr_nl sa; > - char buf[MLX5_RECV_BUF_SIZE]; > + void *buf =3D malloc(MLX5_RECV_BUF_SIZE); > struct iovec iov =3D { > .iov_base =3D buf, > - .iov_len =3D sizeof(buf), > + .iov_len =3D MLX5_RECV_BUF_SIZE, > }; > struct msghdr msg =3D { > .msg_name =3D &sa, > @@ -345,6 +345,10 @@ struct mlx5_nl_ifindex_data { > int multipart =3D 0; > int ret =3D 0; >=20 > + if (!buf) { > + rte_errno =3D ENOMEM; > + return -rte_errno; > + } > do { > struct nlmsghdr *nh; > int recv_bytes =3D 0; > @@ -353,7 +357,8 @@ struct mlx5_nl_ifindex_data { > recv_bytes =3D recvmsg(nlsk_fd, &msg, 0); > if (recv_bytes =3D=3D -1) { > rte_errno =3D errno; > - return -rte_errno; > + ret =3D -rte_errno; > + goto exit; > } > nh =3D (struct nlmsghdr *)buf; > } while (nh->nlmsg_seq !=3D sn); > @@ -365,24 +370,30 @@ struct mlx5_nl_ifindex_data { >=20 > if (err_data->error < 0) { > rte_errno =3D -err_data->error; > - return -rte_errno; > + ret =3D -rte_errno; > + goto exit; > } > /* Ack message. */ > - return 0; > + ret =3D 0; > + goto exit; > } > /* Multi-part msgs and their trailing DONE message. > */ > if (nh->nlmsg_flags & NLM_F_MULTI) { > - if (nh->nlmsg_type =3D=3D NLMSG_DONE) > - return 0; > + if (nh->nlmsg_type =3D=3D NLMSG_DONE) { > + ret =3D 0; > + goto exit; > + } > multipart =3D 1; > } > if (cb) { > ret =3D cb(nh, arg); > if (ret < 0) > - return ret; > + goto exit; > } > } > } while (multipart); > +exit: > + free(buf); > return ret; > } >=20 > -- > 1.8.3.1 Patch applied to next-net-mlx, Kindest regards, Raslan Darawsheh