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 6A329A04BB for ; Tue, 6 Oct 2020 14:08:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 623172C16; Tue, 6 Oct 2020 14:08:01 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id E010C2C16 for ; Tue, 6 Oct 2020 14:07:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601986077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O4lL0gPv4jyMCcbm6jbDrtTjTMixsSMVWF6Cx9dKNx0=; b=EX8UrM1Wq5zqunH867S8O+990fsPlWQj26+S3upVD+NCfttjHbuGnl9NDJkY4ocYNk/7cO aeTJrjPgsYvwb3Q6pstJckv/C7i5Pg0Uxs1zfBgc8blI8qV7Iq2WWX4UB/2A9XC5zUmdYy hZEf0rx+DjN+NV2COFkOpf/8vJ8W484= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-129-k67pO6yvMm2FrwkgYKb6xw-1; Tue, 06 Oct 2020 08:07:53 -0400 X-MC-Unique: k67pO6yvMm2FrwkgYKb6xw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7625A87950C; Tue, 6 Oct 2020 12:07:52 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.37.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3919F614F5; Tue, 6 Oct 2020 12:07:50 +0000 (UTC) From: Kevin Traynor To: Viacheslav Ovsiienko Cc: Stephen Hemminger , Matan Azrad , dpdk stable Date: Tue, 6 Oct 2020 13:07:38 +0100 Message-Id: <20201006120738.29125-2-ktraynor@redhat.com> In-Reply-To: <20201006120738.29125-1-ktraynor@redhat.com> References: <20201006120738.29125-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-stable] patch 'net/mlx5: fix netlink buffer allocation from stack' has been queued to LTS release 18.11.11 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, FYI, your patch has been queued to LTS release 18.11.11 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 10/12/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/9c8ee8bda5c8e94095a5e10b0f978c416dea6297 Thanks. Kevin. --- >From 9c8ee8bda5c8e94095a5e10b0f978c416dea6297 Mon Sep 17 00:00:00 2001 From: Viacheslav Ovsiienko Date: Thu, 14 May 2020 07:11:12 +0000 Subject: [PATCH] net/mlx5: fix netlink buffer allocation from stack [ upstream commit 3acf1071958185d2a299b9765e0c5c82e67ff416 ] 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. Fixes: ccdcba53a3f4 ("net/mlx5: use Netlink to add/remove MAC addresses") Reported-by: Stephen Hemminger Signed-off-by: Viacheslav Ovsiienko Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_nl.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c index 7098d31322..2393d75817 100644 --- a/drivers/net/mlx5/mlx5_nl.c +++ b/drivers/net/mlx5/mlx5_nl.c @@ -245,8 +245,8 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), { struct sockaddr_nl sa; - char buf[MLX5_RECV_BUF_SIZE]; + void *buf = malloc(MLX5_RECV_BUF_SIZE); struct iovec iov = { .iov_base = buf, - .iov_len = sizeof(buf), + .iov_len = MLX5_RECV_BUF_SIZE, }; struct msghdr msg = { @@ -260,4 +260,8 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), int ret = 0; + if (!buf) { + rte_errno = ENOMEM; + return -rte_errno; + } do { struct nlmsghdr *nh; @@ -268,5 +272,6 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), if (recv_bytes == -1) { rte_errno = errno; - return -rte_errno; + ret = -rte_errno; + goto exit; } nh = (struct nlmsghdr *)buf; @@ -280,13 +285,17 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), if (err_data->error < 0) { rte_errno = -err_data->error; - return -rte_errno; + ret = -rte_errno; + goto exit; } /* Ack message. */ - return 0; + ret = 0; + goto exit; } /* Multi-part msgs and their trailing DONE message. */ if (nh->nlmsg_flags & NLM_F_MULTI) { - if (nh->nlmsg_type == NLMSG_DONE) - return 0; + if (nh->nlmsg_type == NLMSG_DONE) { + ret = 0; + goto exit; + } multipart = 1; } @@ -294,8 +303,10 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), ret = cb(nh, arg); if (ret < 0) - return ret; + goto exit; } } } while (multipart); +exit: + free(buf); return ret; } -- 2.26.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-10-06 13:03:27.146661447 +0100 +++ 0002-net-mlx5-fix-netlink-buffer-allocation-from-stack.patch 2020-10-06 13:03:26.985072603 +0100 @@ -1 +1 @@ -From 3acf1071958185d2a299b9765e0c5c82e67ff416 Mon Sep 17 00:00:00 2001 +From 9c8ee8bda5c8e94095a5e10b0f978c416dea6297 Mon Sep 17 00:00:00 2001 @@ -4 +4,3 @@ -Subject: [PATCH] common/mlx5: fix netlink buffer allocation from stack +Subject: [PATCH] net/mlx5: fix netlink buffer allocation from stack + +[ upstream commit 3acf1071958185d2a299b9765e0c5c82e67ff416 ] @@ -12 +13,0 @@ -Cc: stable@dpdk.org @@ -18 +19 @@ - drivers/common/mlx5/mlx5_nl.c | 27 +++++++++++++++++++-------- + drivers/net/mlx5/mlx5_nl.c | 27 +++++++++++++++++++-------- @@ -21,5 +22,5 @@ -diff --git a/drivers/common/mlx5/mlx5_nl.c b/drivers/common/mlx5/mlx5_nl.c -index 65efcd3df2..1a1033a40b 100644 ---- a/drivers/common/mlx5/mlx5_nl.c -+++ b/drivers/common/mlx5/mlx5_nl.c -@@ -331,8 +331,8 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), +diff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c +index 7098d31322..2393d75817 100644 +--- a/drivers/net/mlx5/mlx5_nl.c ++++ b/drivers/net/mlx5/mlx5_nl.c +@@ -245,8 +245,8 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), @@ -36 +37 @@ -@@ -346,4 +346,8 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), +@@ -260,4 +260,8 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), @@ -45 +46 @@ -@@ -354,5 +358,6 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), +@@ -268,5 +272,6 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), @@ -53 +54 @@ -@@ -366,13 +371,17 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), +@@ -280,13 +285,17 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), @@ -75 +76 @@ -@@ -380,8 +389,10 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg), +@@ -294,8 +303,10 @@ mlx5_nl_recv(int nlsk_fd, uint32_t sn, int (*cb)(struct nlmsghdr *, void *arg),