From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D56AC48BF6 for ; Sun, 3 Mar 2024 06:46:31 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C0BB42E2F; Sun, 3 Mar 2024 07:46:30 +0100 (CET) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id AF7CA4028C for ; Sun, 3 Mar 2024 07:46:28 +0100 (CET) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 341A140BA for ; Sun, 3 Mar 2024 07:46:28 +0100 (CET) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 0C9BB41A9; Sun, 3 Mar 2024 07:46:28 +0100 (CET) Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id E436340B8; Sun, 3 Mar 2024 07:46:25 +0100 (CET) Message-ID: Date: Sun, 3 Mar 2024 07:46:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] rte_memcpy: fix off by one for size 16 and 32 Content-Language: en-US To: Stephen Hemminger , dev@dpdk.org Cc: =?UTF-8?Q?Morten_Br=C3=B8rup?= , Bruce Richardson , Konstantin Ananyev , Zhihong Wang , Yuanhan Liu , Xiaoyun Li References: <20240302204923.227105-1-stephen@networkplumber.org> <20240302125647.63ef6aec@hermes.local> From: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= In-Reply-To: <20240302125647.63ef6aec@hermes.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2024-03-02 21:56, Stephen Hemminger wrote: > On Sat, 2 Mar 2024 12:49:23 -0800 > Stephen Hemminger wrote: > >> The rte_memcpy code would do extra instructions for size 16 >> and 32 which potentially could reference past end of data. >> >> For size of 16, only single mov16 is needed. >> same for size of 32, only single mov32. >> >> Fixes: f5472703c0bd ("eal: optimize aligned memcpy on x86") >> Fixes: d35cc1fe6a7a ("eal/x86: revert select optimized memcpy at run-time") >> >> Suggested-by: Morten Brørup >> Signed-off-by: Stephen Hemminger > > Self-NAK, more is needed here. > > The code has lots of pre-existing bugs where it will reference past the end > of the data in some cases. Memory beyond the buffer is not accessed in this case. The rte_mov16() copies just overlap. A colleague pointed out the same "bug" to me a couple of years ago. We didn't realize what code would be generated in the n == 16 case though. That seems very much worth fixing. Maybe it's worth adding a comment regarding the overlap.