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 B6D24C32771 for ; Wed, 21 Sep 2022 13:06:18 +0000 (UTC) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE2AB4067C; Wed, 21 Sep 2022 15:06:17 +0200 (CEST) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by mails.dpdk.org (Postfix) with ESMTP id 3A3204014F for ; Wed, 21 Sep 2022 15:06:16 +0200 (CEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 7E5825C017C; Wed, 21 Sep 2022 09:06:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 21 Sep 2022 09:06:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1663765575; x= 1663851975; bh=aUAr17H8LR4xxupZEr9Mom6azm6IJjIbrPYg4J7tmik=; b=V uwRcRrz/OtJZ1288aGEl4B42GAOisl1bG5c0MQ16kPckvMf2qHYIX8cX7ZxxvlAQ oexgDOL03yGDBoAEwSkY71hplp57abuGijzE9vVuCmSU/xrfXPcFtzjosxDRUVys ZQfQtL3u7VfhdYlCcuBC8y7zS/Ktuh83DGfR/CjQ/lvXlKYH6xIQctQ5hR9yvFlg b+Hup6gvRW5TAWrsq3ctitbLJunVeMg45EDGLzT6uw1HmaAeT7+ESTHLpSTfyHOP 1pquoMNYr669NLZo2xPyF0JY38X8Dj/uuAS2cNY3C4OrtoA+mKWQFUy3Ok7zHuzT L3k3x8rw1t2y3V63sVd7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1663765575; x= 1663851975; bh=aUAr17H8LR4xxupZEr9Mom6azm6IJjIbrPYg4J7tmik=; b=p ht0cbc2Mq2apBpFUABqQKEODAeq6TWrs0uD+Jukx2f6ljh1ZoyTSvoBCAxK9gDvV velUF/rrM20KWON/frAiOe/4+d3WyYUjp7MlTLdz79gSP0esbXK+XvEfWu5y5nZa KAiF1lJEYU4TwtkDTuuHDwxrFEr+A2DlFivY653/qQsz4w63CV22JNp3+Fcii/y6 b9Fe3Is5lGNFiyM1IY6VE4cS2PmRUE0OJlzlxLyyh4wX+AitC2d8nmrVAUUX395O 6345GNy6HSz4IXaMgOZrz0rEVujBRQ1eMXavEk9TEZuuDJniWxb3yuYrFK019srE gKROakQUa4rkzuourMjWA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefuddgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedtjeeiieefhedtfffgvdelteeufeefheeujefgueetfedttdei kefgkeduhedtgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Sep 2022 09:06:14 -0400 (EDT) From: Thomas Monjalon To: Henning Schild Cc: Konstantin Ananyev , dev@dpdk.org Subject: Re: [PATCH] lib: do not call memcpy with sz zero and null pointer Date: Wed, 21 Sep 2022 15:06:12 +0200 Message-ID: <6425132.G0QQBjFxQf@thomas> In-Reply-To: <20220907150503.6212-1-henning.schild@siemens.com> References: <20220907150503.6212-1-henning.schild@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 07/09/2022 17:05, Henning Schild: > There is no point in such a call and UBSan complains about a call to > memcpy with a null pointer as second arg. > > When building with -Db_sanitize=undefined, Clang gives the following > warning > ../lib/bpf/bpf_load.c:37:20: runtime error: null pointer passed as > argument 2, which is declared to never be null > > A check of the sz before calling memcpy fixes that. > > Signed-off-by: Henning Schild > --- > --- a/lib/bpf/bpf_load.c > +++ b/lib/bpf/bpf_load.c > @@ -34,7 +34,8 @@ bpf_load(const struct rte_bpf_prm *prm) > > memcpy(&bpf->prm, prm, sizeof(bpf->prm)); > > - memcpy(buf + bsz, prm->xsym, xsz); > + if (xsz) > + memcpy(buf + bsz, prm->xsym, xsz);* I assume I can safely change it to if (xsz > 0) to comply with the code style. Applied, thanks.