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 E8581A0540; Fri, 9 Sep 2022 16:15:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B79141141; Fri, 9 Sep 2022 16:15:57 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80058.outbound.protection.outlook.com [40.107.8.58]) by mails.dpdk.org (Postfix) with ESMTP id 4AF23400D6 for ; Wed, 7 Sep 2022 17:05:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nmakfsgRNejf6DEDs/Hk4M6bpXppXpUmgrsJjng3+n8t0Xmt0AytcyKMm8WYrvF7OcoqFeY98ospjpwPuujAiy4WeFHawJp/oc3ahnLjr607KOPcBzfuiHvvFakXTtAucmCCIAlDD+Hlkqm5IcBf+yTD5AR6KhMmiXjHb7FBl6QINdallc5aQW2F9pr750r+BJV+7xcyTP9WqgPuPwxcRqY/lq8YxqKWOzVwcwi3UesqyQgQxqcTKZsuWgJu2r0ALZCAxyA9OMyNnOo4eI+877yiw2joRUMvd2pE5BSVhMpJsbWgce1350q+mEXevzXHq5mEYThkZZPlF6Z9/SDHEw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qSXOFz2rs0nORdvHgA6C36vC0lWCnxDkJ0nCteIuhzo=; b=SRH2ziTKCBvXI4qIm91eC4sEbLHDYfQXzZ9bSj6hWwcKD/ZKAx4DF/vQ5fXbCKngCjtllEta6xOrTYPkyFNIWvDR6OuJnSG8hYD2gdrzWyzkD6iWJrUM0utFUatiKVBvWqwC6yfhsklm90FP+Rh0qb6gMBkegerOXJ7xMlJnQUtgZWUAyB8MHHg3vU17VO5UdUuSe4cGa0LhXLoqUlhwKJbsd9/ht8hNYYNkXq9on9OkNAxYZffBNd9lVjMSmaB1i2e9RXYGur/ICPI7OJjKmD8vcX18m0g70GgT9hEYIzcuckO2igbnpGSxRiHH+wFKvD6ZHJvPu7AT1pc5h88hAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.76) smtp.rcpttodomain=yandex.ru smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qSXOFz2rs0nORdvHgA6C36vC0lWCnxDkJ0nCteIuhzo=; b=OIURPFFQ6W3b5TeMhMOF11uMEH4jQ9axprquWbRnFgPEgXXBsLJHs86LdU8/oSp31nv7ckvcZfT9O80bHoURntiqNKozJ7LvVnQb8xll3zsgBLBiFHyeCRJxssZpacxRAEaRPIQXNb2GR2XMLX/SeNc6idrNohxOgNUzAiO/FxiXQtpOaxEQQldtA3SSiHvcam/MCw1pX9aK5HlAPwNZetP9kIrrhYqdDzcXetIY3e7DDunBkSwmlpWxYeaRFXJT74QpectEuP5NMe2FqGIkcW7gXdLlasmdxoy2hGfVwH3oBGFm0SLuTr3Y4rkUE6IZ5A5bKtxbBM2XixImuGG+jg== Received: from GV3P280CA0043.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:9::7) by DB4PR10MB6992.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:3f4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Wed, 7 Sep 2022 15:05:17 +0000 Received: from HE1EUR01FT065.eop-EUR01.prod.protection.outlook.com (2603:10a6:150:9:cafe::58) by GV3P280CA0043.outlook.office365.com (2603:10a6:150:9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.14 via Frontend Transport; Wed, 7 Sep 2022 15:05:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.76) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.76 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.76; helo=hybrid.siemens.com; pr=C Received: from hybrid.siemens.com (194.138.21.76) by HE1EUR01FT065.mail.protection.outlook.com (10.152.0.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.13 via Frontend Transport; Wed, 7 Sep 2022 15:05:16 +0000 Received: from DEMCHDC89XA.ad011.siemens.net (139.25.226.103) by DEMCHDC8VSA.ad011.siemens.net (194.138.21.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.12; Wed, 7 Sep 2022 17:05:16 +0200 Received: from md1za8fc.ad001.siemens.net (158.92.8.74) by DEMCHDC89XA.ad011.siemens.net (139.25.226.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.12; Wed, 7 Sep 2022 17:05:15 +0200 From: Henning Schild To: Konstantin Ananyev CC: , Henning Schild Subject: [PATCH] lib: do not call memcpy with sz zero and null pointer Date: Wed, 7 Sep 2022 17:05:03 +0200 Message-ID: <20220907150503.6212-1-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [158.92.8.74] X-ClientProxiedBy: DEMCHDC89XA.ad011.siemens.net (139.25.226.103) To DEMCHDC89XA.ad011.siemens.net (139.25.226.103) X-TM-AS-Product-Ver: SMEX-14.0.0.3080-8.6.1018-26680.007 X-TM-AS-Result: No-10--10.356900-8.000000 X-TMASE-MatchedRID: wpn4rEuVxjD/SBBKLrCFgNGHGiRI8V4X7O9PFKJckb/xWp8B+pjaLNhQ O8CvZj/XE8cL830eUMppRezoWC5XLcEIvelGIEHCBkMpb3gCdH5PYnAPH/ofpj8Ckw9b/GFefS0 Ip2eEHnzmEN83F06F6/oLR4+zsDTtjoczmuoPCq1/w5wobEW22ynjmKgJoD8S/cW9I6hYagb7gG PfpTP31iqThwE83oDq X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--10.356900-8.000000 X-TMASE-Version: SMEX-14.0.0.3080-8.6.1018-26680.007 X-TM-SNTS-SMTP: 1D4986FB88FF37057F9B78FF210FDB4451B520BAD51AE61AA0D70BDDF63D6AC62000:8 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1EUR01FT065:EE_|DB4PR10MB6992:EE_ X-MS-Office365-Filtering-Correlation-Id: d2cd357d-7c9b-4bfb-daf6-08da90e25faa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g9rvmfUZpTpQcCWMJH+xcHo3Q3CC87CAVrDrjXr4hkEM5DziR1PSblVrcQMYurpwcAxonYl6biXPyxPsRn3CctTWoJKvrxuD6OF5r+LI7shkqRYoMqhyfk4ofO90fy5GONxtc5muodCTyO4/7cKU4MVdI/deOWw4AsUu2ja4eAXCvVJD7T5s0yg7c4Q6c4AidDSWG18SznbyZcGZWJODQ6EN1GTq8tHyHCaa6qlFGTCafYgkH9zatkEWNbYaIdJHpLW90wDtBvs0DIkOLQyRpKGONBHV8tD9TvaXuv3YtUGCCaOfyHeOl4gQhG8is+qgSMig4UX01WPAgnvINiIk5h5bAzrAToK1dCfiEvCVSJWVONYYQWtRDx94xVZHTEImgMBihbQc76HAmBY8tAJqjjVxqgQ0oURkBrtUwF+2jk3TkOEAXrRFnpj9XZUAr/5wzi55+bk25bcwWD63Q/NX/O0y/nXzkgqlLsfo3XpIv0QxmkaXmrBAI3dZ2f3ZH+GylPV+JdQJ/XA1dU2IsgCKl6uuKuYce16eCISt6/UQp9x7evTD4dtlHqQjI+EkTcdJxMlt1zVLJiCsgznrUkcEdC1qWEOuNc8HDxrlMLn9dK80EvRehx7cEp+roQYANZVBAXbsakvB5ImjEFRQgPDKRPncpvejJ04Pq/fuvjnfapnxLS6gZlS786Zt3YCML4mMd4zKYau8/Cj5dzfCYmXl6K0ktlkDLlHWnx9Kq3bG9cHlOzbglBZ55/YKStIwUKTHZcBz53VW+i4tpH9A572P4zfpDItha9S1ZE8VXSTrXro= X-Forefront-Antispam-Report: CIP:194.138.21.76; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(136003)(376002)(346002)(396003)(36840700001)(46966006)(40470700004)(70586007)(70206006)(81166007)(4326008)(82740400003)(356005)(82960400001)(86362001)(36860700001)(8676002)(36756003)(47076005)(1076003)(41300700001)(6666004)(186003)(26005)(83380400001)(16526019)(107886003)(6916009)(956004)(5660300002)(54906003)(316002)(82310400005)(40480700001)(2906002)(40460700003)(336012)(478600001)(8936002)(4744005)(2616005)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 15:05:16.7450 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2cd357d-7c9b-4bfb-daf6-08da90e25faa X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.76]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: HE1EUR01FT065.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR10MB6992 X-Mailman-Approved-At: Fri, 09 Sep 2022 16:15:54 +0200 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 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 --- lib/bpf/bpf_load.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bpf/bpf_load.c b/lib/bpf/bpf_load.c index 0c4ac7be6c55..48d3d80ac3e3 100644 --- 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); memcpy(buf + bsz + xsz, prm->ins, insz); bpf->prm.xsym = (void *)(buf + bsz); -- 2.35.1