From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D6242A034C for ; Tue, 14 Dec 2021 04:30:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3E8240042; Tue, 14 Dec 2021 04:30:23 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id 91CB440042 for ; Tue, 14 Dec 2021 04:30:22 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id np6-20020a17090b4c4600b001a90b011e06so14977777pjb.5 for ; Mon, 13 Dec 2021 19:30:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JkMkaWItrlWwJh03faN7J8FmFgxH4iCw8zl5yiPvPJ8=; b=C+akNtDiun+DFZRdd5XRDWErwGN/HX+4kz23AL4l1MYG6kXQNJd1317XNDtqDkqZrr mtUlS/lVEsWcTpoeXiVKVp5GBhtayPBxrQadZZ2hLNSnJODCzqLpk0lOd0TtQEFK1xoL RtcG2Aq1FIf+d7NfBESseMcGjoZ4NiOCDfbKtscZx5gTmiWRH0n/gNYZeSss/Dj9ErOk WNXuNhYcVM8zcewFK8pV8ME/LiOQhvHMl+qBpKGTT3+m50S/RbZL9pqXkvACpHPfvfsm MK+ieU3QvG07g2xnlKbvod8pvW10mCuqv6gvq8i2c+0+eWPfhIQhRfMXQO+FJ5YRnbBa txSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JkMkaWItrlWwJh03faN7J8FmFgxH4iCw8zl5yiPvPJ8=; b=EDu6wzG23PfX0lDtLw9Yu1Zc/V8YPVrK/1ZndqdsvL5nXQLnAhklBOyDGmgxJpmZMt +c9mIrlFhJSLdQkuPVDPapnzmW07NS5gT978iSCsDTvgYpJDNMsUeTNRY/D5iQPF/i8U dIft8P0z8wXHtSlg72R5yUTYB0zo+dVzCgIrn/YU4lDa/CcpavT90TRZ+Ux8QTWyEfty Nkt+5mC6pZ6gT8Wh/piia8Y1XpJPm3vhVx9ey9BolXLfnfzgfiOwuxdTWbYn4UGSZTDS tQyqPICGRlmG3TcGpeDi2FQKCOtLidNow+Or49kFEaPYApGm502rBIxNnrfNIrtqMX+c rOyg== X-Gm-Message-State: AOAM533i973RV6gGXgSNKl7jzdhBsrhBxjlB+Nh9SlK1Ku8hILFJPS8H JoMDvYDclerhtwTUdSVkWgg8lg== X-Google-Smtp-Source: ABdhPJxTqDIs0JODS9q2poTPPDxds1WDTIDxtQPRDadfSyrJHpKDVtsLnT5QPZif2+f1r+TYQ84zZg== X-Received: by 2002:a17:902:c7c2:b0:143:bdf7:1670 with SMTP id r2-20020a170902c7c200b00143bdf71670mr3200738pla.61.1639452621680; Mon, 13 Dec 2021 19:30:21 -0800 (PST) Received: from C02D70YZMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id l1sm501691pjh.28.2021.12.13.19.30.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Dec 2021 19:30:21 -0800 (PST) From: Zhihong Wang To: konstantin.ananyev@intel.com, honnappa.nagarahalli@arm.com, dev@dpdk.org Cc: Zhihong Wang , stable@dpdk.org Subject: [PATCH] ring: fix overflow in memory size calcuation Date: Tue, 14 Dec 2021 11:30:16 +0800 Message-Id: <20211214033016.29927-1-wangzhihong.wzh@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 Parameters count and esize are both unsigned int, and their product can legally exceed unsigned int and lead to runtime access violation. Fixes: cc4b218790f6 ("ring: support configurable element size") Cc: stable@dpdk.org Signed-off-by: Zhihong Wang --- lib/ring/rte_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index f17bd966be..d1b80597af 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -75,7 +75,7 @@ rte_ring_get_memsize_elem(unsigned int esize, unsigned int count) return -EINVAL; } - sz = sizeof(struct rte_ring) + count * esize; + sz = sizeof(struct rte_ring) + (ssize_t)count * esize; sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE); return sz; } -- 2.11.0