From patchwork Mon Nov 16 20:16:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11910751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92512C55ABD for ; Mon, 16 Nov 2020 20:16:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B9EB21D7E for ; Mon, 16 Nov 2020 20:16:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="D61dao9w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727204AbgKPUQU (ORCPT ); Mon, 16 Nov 2020 15:16:20 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:2706 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729595AbgKPUQT (ORCPT ); Mon, 16 Nov 2020 15:16:19 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 16 Nov 2020 12:16:23 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 16 Nov 2020 20:16:19 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 16 Nov 2020 20:16:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIJoOTqLuvQEPRgB6u9TLnnz8Kn8Eb1+Ooyh9SANei639H1ITmxEHv8fZujwdD/bX0ypUlte4kpM4ZRTVbVHpLfcE3crEto0qyPfhJwUrN3Te7uAiAoaJexdGzz1b5orKux3fUyHR+gNDYs6b3fp+TpMGHxW/r6VqZkQYhFE5atfepwF7ORR/UsI88fGQFjVW5WwVqi4vXxUOf95rPGeOoSDqfbd6pL6yxDQM5NcFFPeEKFGryOAyOV7Q9nqYePZT5n8USyrRPOfahmjwVF3gSjFdQZmPJBZ4ox6OQJNuRV9kwqXInSfCl85a64Yk9Yt604WLlYGyMviwcG0dq3lEg== 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-SenderADCheck; bh=qlbAdzOllc55KkeYRZN8ZzMzbXRYS4Vqs8NBNaH3xMU=; b=QFW935k7qYJM7wZNEkq9EvaI00YjNF7SH4eU2RGebTcQQVrF+lwGGZ2OxvnIcbgndDLkic+NOAEYj/DPFbYtG5wq6Fk4vgPvs9rBYJlQOeq8u319vbt1Xip8+vsneQHTFgN3FrHkSNPL0SCrMzvbSOrBAPHScnFOKTUzKSWj5hzlUi3UYNLw+i5FfXr4KieEiQBxLElGm8lS1n4Dsd2fzQYBEFjiWX2uoKOIafJoP1NL4w3gi4kZnBQSOWlBAqmvnnUAXxDZCQrPEyoQEkderTB2XwqAvYnZRMwURcJEFqxLxP8u8qOdQ8h/q0GBMjzO70mL14YwQoJvERrv1RFefg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4810.namprd12.prod.outlook.com (2603:10b6:5:1f7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25; Mon, 16 Nov 2020 20:16:18 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9%7]) with mapi id 15.20.3564.028; Mon, 16 Nov 2020 20:16:18 +0000 From: Jason Gunthorpe To: Subject: [PATCH 1/4] libibumad: Check for error returns in get_port() Date: Mon, 16 Nov 2020 16:16:13 -0400 Message-ID: <1-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> In-Reply-To: <0-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR01CA0052.prod.exchangelabs.com (2603:10b6:208:23f::21) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (156.34.48.30) by MN2PR01CA0052.prod.exchangelabs.com (2603:10b6:208:23f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.28 via Frontend Transport; Mon, 16 Nov 2020 20:16:17 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kekvA-006km7-LT for linux-rdma@vger.kernel.org; Mon, 16 Nov 2020 16:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1605557783; bh=Smo/E0Cg0JND1ms18JnvvPBN7uwHi/FjgYDnIVEL1p4=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: Subject:Date:Message-ID:In-Reply-To:References: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy: MIME-Version:X-MS-Exchange-MessageSentRepresentingType; b=D61dao9w7X2Mk+YGL7nzw2HRS30p+QE7y9QPIPuhaHtE7+LIvbzwkEvj6/wM/PMA+ 3e+iF2ZAAcrcu4IN0yi4ul6x8U9sJsvdNW1R/jWa97QpCfDe2UiuVax4O+4yG7IOen niQlnVn/vqOLoyUd0gRWgadomnexGOhvwjf6zN9VKMKaAeKi3YyBO9rsKj6xaxfU0d sVq8uDqUWG0CdDwV6izbMdAQpDZ5vEXKPAieaIOwIewazV8lvIYfmFNrV639u6x/Lx 5S/DXTfAXCbup5XeA6JHDXD/r6zSRICDBRV00yVeDXVwQd/HGNU0dpMWt+z/GeaNuq +xNWIuyuWzsBg== Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Stronger control flow analysis on GCC 10 with LTO detects: ../libibumad/umad.c: In function 'get_port': ../libibumad/umad.c:208:20: error: 'val' may be used uninitialized in this function [-Werror=maybe-uninitialized] 208 | port->pkeys[idx] = val; Caused by ignoring the return code from sys_read_uint() Reorganize the goto unwind so it makes sense and check all the calls to sys_read_uint(). Signed-off-by: Jason Gunthorpe --- libibumad/umad.c | 49 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/libibumad/umad.c b/libibumad/umad.c index 90b8c0ce409c2e..b23b345a4ca299 100644 --- a/libibumad/umad.c +++ b/libibumad/umad.c @@ -148,7 +148,7 @@ static int get_port(const char *ca_name, const char *dir, int portnum, umad_port { char port_dir[256]; union umad_gid gid; - struct dirent **namelist = NULL; + struct dirent **namelist; int i, len, num_pkeys = 0; uint32_t capmask; @@ -158,23 +158,24 @@ static int get_port(const char *ca_name, const char *dir, int portnum, umad_port len = snprintf(port_dir, sizeof(port_dir), "%s/%d", dir, portnum); if (len < 0 || len > sizeof(port_dir)) - goto clean; + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_LMC, &port->lmc) < 0) - goto clean; + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_SMLID, &port->sm_lid) < 0) - goto clean; + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_SMSL, &port->sm_sl) < 0) - goto clean; + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_LID, &port->base_lid) < 0) - goto clean; + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_STATE, &port->state) < 0) - goto clean; + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_PHY_STATE, &port->phys_state) < 0) - goto clean; - sys_read_uint(port_dir, SYS_PORT_RATE, &port->rate); + return -EIO; + if (sys_read_uint(port_dir, SYS_PORT_RATE, &port->rate) < 0) + return -EIO; if (sys_read_uint(port_dir, SYS_PORT_CAPMASK, &capmask) < 0) - goto clean; + return -EIO; if (sys_read_string(port_dir, SYS_PORT_LINK_LAYER, port->link_layer, UMAD_CA_NAME_LEN) < 0) @@ -184,7 +185,7 @@ static int get_port(const char *ca_name, const char *dir, int portnum, umad_port port->capmask = htobe32(capmask); if (sys_read_gid(port_dir, SYS_PORT_GID, &gid) < 0) - goto clean; + return -EIO; port->gid_prefix = gid.global.subnet_prefix; port->port_guid = gid.global.interface_id; @@ -194,37 +195,37 @@ static int get_port(const char *ca_name, const char *dir, int portnum, umad_port if (num_pkeys <= 0) { IBWARN("no pkeys found for %s:%u (at dir %s)...", port->ca_name, port->portnum, port_dir); - goto clean; + return -EIO; } port->pkeys = calloc(num_pkeys, sizeof(port->pkeys[0])); if (!port->pkeys) { IBWARN("get_port: calloc failed: %s", strerror(errno)); - goto clean; + goto clean_names; } for (i = 0; i < num_pkeys; i++) { unsigned idx, val; + idx = strtoul(namelist[i]->d_name, NULL, 0); - sys_read_uint(port_dir, namelist[i]->d_name, &val); + if (sys_read_uint(port_dir, namelist[i]->d_name, &val) < 0) + goto clean_pkeys; port->pkeys[idx] = val; - free(namelist[i]); } port->pkeys_size = num_pkeys; + for (i = 0; i < num_pkeys; i++) + free(namelist[i]); free(namelist); - namelist = NULL; port_dir[len] = '\0'; /* FIXME: handle gids */ return 0; -clean: - if (namelist) { - for (i = 0; i < num_pkeys; i++) - free(namelist[i]); - free(namelist); - } - if (port->pkeys) - free(port->pkeys); +clean_pkeys: + free(port->pkeys); +clean_names: + for (i = 0; i < num_pkeys; i++) + free(namelist[i]); + free(namelist); return -EIO; } From patchwork Mon Nov 16 20:16:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11910747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D06C4742C for ; Mon, 16 Nov 2020 20:16:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7066921D93 for ; Mon, 16 Nov 2020 20:16:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="X0GPQ7Nt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729595AbgKPUQU (ORCPT ); Mon, 16 Nov 2020 15:16:20 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:14442 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729707AbgKPUQU (ORCPT ); Mon, 16 Nov 2020 15:16:20 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 16 Nov 2020 12:16:11 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 16 Nov 2020 20:16:19 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 16 Nov 2020 20:16:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ct3ywEdvkLYbOuCaiwnIHU/jhQrAU7dFSEjoM0BIdbf/JJWCyCfVPyZL390aaWGYngvWld6zgqCgDwm3hm/tqSvExSaY7gpe6iFbw56rgD1dgamYJx0zKHFHI+daIHhQ2t820MKhAcw9p5i4ZiQ9UmU1Dzr2fjm3eVjHc719Q3L1GMAdnBi3ioUvRjN7Yy+7n/DuuatcIJfocFDOk5dfPMeGh9jaM3XTrFQowZcYGcEgPkqCqNDbTs/pw0V6vWdx3aRaajrLP7sZsi8STF1flE9Sgb0CQDVqWticZlVHaN8PE6KiINkiRxhvB7qE1h+4Gc/8yrFCIfshd4DIPpopfg== 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-SenderADCheck; bh=rRxkvsuynKZiwELP/GsBJcCIronelnOLN9PEF7ZShxA=; b=Gx46oFSUc+A42LNCUfVCwm7MwYLaibfVkqCywb/YBr7xDqyhbmj+lMcoubxGtm6eiJtJ/jBosEf/wV5gTUnSMTbcs7Pqg87IW3//3krWOVJX8uJTmUWohWv4mj8+mjP6lDHbjs0AscWAXsdWdC27NqHWJfA3jTvstlDQuqTUdf9xrcGFzk7R6MU//+v2omXJkPaQimpNRLx7iX5dgxPndKk4Zfe3+ejRyUIVbwsnaSTM+HAEWD806CEnk6Njm3j/HvK6+q896svMkuNZC/8svuyQ4yGh4uFsLpf5EAtk34gOZ3vIaOkb07R+5EaWSKay01hbWi4P+jKaMXIeIthNAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4810.namprd12.prod.outlook.com (2603:10b6:5:1f7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25; Mon, 16 Nov 2020 20:16:19 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9%7]) with mapi id 15.20.3564.028; Mon, 16 Nov 2020 20:16:19 +0000 From: Jason Gunthorpe To: Subject: [PATCH 2/4] verbs: Simplify the logic assigning vid in ibv_resolve_eth_l2_from_gid() Date: Mon, 16 Nov 2020 16:16:14 -0400 Message-ID: <2-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> In-Reply-To: <0-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR12CA0006.namprd12.prod.outlook.com (2603:10b6:208:a8::19) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (156.34.48.30) by MN2PR12CA0006.namprd12.prod.outlook.com (2603:10b6:208:a8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25 via Frontend Transport; Mon, 16 Nov 2020 20:16:17 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kekvA-006kmB-MH for linux-rdma@vger.kernel.org; Mon, 16 Nov 2020 16:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1605557771; bh=KMbAfhl+V28GcZdSXt21UbDtqtAbXOHsI6cC0ckh0N0=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: Subject:Date:Message-ID:In-Reply-To:References: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy: MIME-Version:X-MS-Exchange-MessageSentRepresentingType; b=X0GPQ7NtPnJY/4CefsmyzfyRyfOgGAu3nduLfzXdzhNAUggaEk3PAYTZV30aAQiN2 gTCZ5qUTXv3Nb+XHz+Bvfn/IhesoU/aVzIeQhJzQjcfBWIcK8ySfzuexlGtQWTztBs MRg9XgCZ4CbS+mB74mtURQHLOeQ5BQSiukAa993FCpQW1LdEZSGYeRfCdcv/ai03rx GfezeD/Qp/ztC5a4FA3wvtFXvt1j16zdvg1QA564byClnvR9V459wnI4jTWLhlSW6O YFRbIzMLjoTFlfeSaukmRGXLMYvu/HkqsYYANfaSYbZ2fenCjosqHOYNPnoZoNmeLy oUgwflPG556yQ== Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org gcc 10 with LTO reports: ../libibverbs/verbs.c:1040:8: error: 'ret_vid' may be used uninitialized in this function [-Werror=maybe-uninitialized] 1040 | *vid = ret_vid; Which seems like a compiler bug as there is obviously no way for this to be true, nor is it clear how LTO has any impact here since neigh_get_vlan_id_from_dev() always returns a defined value. Nevertheless, the logic is tortured, so simplify it by combining everything into one if. Signed-off-by: Jason Gunthorpe --- libibverbs/verbs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libibverbs/verbs.c b/libibverbs/verbs.c index 7fc10240cf9def..2b0ede84e8d635 100644 --- a/libibverbs/verbs.c +++ b/libibverbs/verbs.c @@ -973,7 +973,6 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, int ether_len; struct peer_address src; struct peer_address dst; - uint16_t ret_vid; int ret = -EINVAL; int err; @@ -1022,10 +1021,11 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, goto free_resources; if (vid) { - ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler); + uint16_t ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler); if (ret_vid <= 0xfff) neigh_set_vlan_id(&neigh_handler, ret_vid); + *vid = ret_vid; } /* We are using only Ethernet here */ @@ -1036,9 +1036,6 @@ int ibv_resolve_eth_l2_from_gid(struct ibv_context *context, if (ether_len <= 0) goto free_resources; - if (vid) - *vid = ret_vid; - ret = 0; free_resources: From patchwork Mon Nov 16 20:16:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11910743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71857C2D0A3 for ; Mon, 16 Nov 2020 20:16:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08E29217A0 for ; Mon, 16 Nov 2020 20:16:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="OOzL9pcE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729744AbgKPUQU (ORCPT ); Mon, 16 Nov 2020 15:16:20 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:2705 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbgKPUQT (ORCPT ); Mon, 16 Nov 2020 15:16:19 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 16 Nov 2020 12:16:23 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 16 Nov 2020 20:16:19 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 16 Nov 2020 20:16:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MBuYbwKM7emi4zkKoQENaERDz6b8atkZCSVDtd1yY3+nun2CswcduiX+ep8nX2rTO+Is4yfpS4T3yMA575jCkxDZW/HHdgY5BsfkVQqEZn8aDTcYTdPBQr+mmQlbALWgzf9l11XN7m2NaATGdMT+LwROSvE4CB1KNX8GNSaMv8kLY76/kyD6f6EtUw3RDpJrCHyYcaj0LVhoVBcHUr1So1WDRPMFjYrJMYegQHdd5gB47ZQ9crBxm40cbwLtXXuO6rvCj2l7yHfH3Vr+yLu5r4swuO1Ecdj/ytemetwx4rxW1vnqEenpLwsgNdVgXHQRJDdAZMJAnxaIMQ87yGgowQ== 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-SenderADCheck; bh=aV4/UkYUuW9ZruyzQVzhUOiNWRi/ddN1BL+iIQ+ms6U=; b=XJZcVW9HBxEyjSWu5i6Nw042fv/PPIzKbNWMEylFEcnGUk6yLRR0lTLQYQT9t506GRMOacq948Er/FpSwJsFiK1YC5NE+E5VUGRlXnls8oJg9bTCHMeBKQjOHhOufSEU2z9N7JUgjPbIbH49WUon6kAH1pkuIdTY/14Z73B5OKdakUMkl070hUL3Ymf5Bw0EWOdmqqDM9C6ZLJypoGlCOyizpEgwR0xuetoDw4rfc6itqWanicFhl4HJwJkE7pj4qvj2A/lqba6Hjnw1wRTWZ/Y8p4lb/qlY0Qqlf1nOh7zvs+paaT7qC1nsk9bdpNXn1F4uXN8MMHT5IrEBzO5lsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4810.namprd12.prod.outlook.com (2603:10b6:5:1f7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25; Mon, 16 Nov 2020 20:16:18 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9%7]) with mapi id 15.20.3564.028; Mon, 16 Nov 2020 20:16:18 +0000 From: Jason Gunthorpe To: Subject: [PATCH 3/4] iwpmd: Always copy the ss_family in copy_iwpm_sockaddr() Date: Mon, 16 Nov 2020 16:16:15 -0400 Message-ID: <3-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> In-Reply-To: <0-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR01CA0041.prod.exchangelabs.com (2603:10b6:208:23f::10) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (156.34.48.30) by MN2PR01CA0041.prod.exchangelabs.com (2603:10b6:208:23f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25 via Frontend Transport; Mon, 16 Nov 2020 20:16:17 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kekvA-006kmF-N7 for linux-rdma@vger.kernel.org; Mon, 16 Nov 2020 16:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1605557783; bh=mZUT2DUJm9nduciCWrQB9nPmIKLWLF2pVT9oC1VB+uk=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: Subject:Date:Message-ID:In-Reply-To:References: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy: MIME-Version:X-MS-Exchange-MessageSentRepresentingType; b=OOzL9pcEPWgPFHAuXzzHPQU8UkjkoyJdEMcDp4rXmVNUFfHvHzpdIjuQbJl6qDDN6 ONa0PwCIIRLEiRYDY+r8vT7Oty2FXuQFSVaPua7h8Ce8Y1gsg5M2/1y+PxXSvGpBto NinVEQ22yaCshsL9amr71kkcB36TGHWIYCXQBvkn5NdvwnAcZPs6RNbuVUWn0q4Vjk eda7Yd3rBViIv8NlS4fmAO4U8k8M+b7AbY5ZtEZPnKoQN8OraH5JNWFPbaJWvn6Jrj SRVDHi1Ww1TYXu7lxceu2dvZkPoYKEKEi3TEmbHz0o4g+OuAc/mbS8j8I/0ROlOz2e Hqq7jQ7yFkSlw== Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org gcc10 with LTO finds a path where process_iwpm_wire_request() calls copy_iwpm_sockaddr() and then does print_iwpm_sockaddr() against the dst. If the case statement in copy_iwpm_sockaddr() bails then print_iwpm_sockaddr() is still called and this triggers a read from uninitialized memory. Always copy the ss_family, this will cause the default case to be taken in print_iwpm_sockaddr() as well. Signed-off-by: Jason Gunthorpe --- iwpmd/iwarp_pm_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/iwpmd/iwarp_pm_common.c b/iwpmd/iwarp_pm_common.c index 8160180aee48e8..67309cbee6a057 100644 --- a/iwpmd/iwarp_pm_common.c +++ b/iwpmd/iwarp_pm_common.c @@ -570,6 +570,10 @@ void copy_iwpm_sockaddr(__u16 addr_family, struct sockaddr_storage *src_sockaddr *dst = *src; break; } + default: + assert(false); + if (dst_sockaddr) + dst_sockaddr->ss_family = addr_family; } } From patchwork Mon Nov 16 20:16:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11910749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EDFFC61DD8 for ; Mon, 16 Nov 2020 20:16:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6F7521D7E for ; Mon, 16 Nov 2020 20:16:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="KDZHMUiH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729707AbgKPUQW (ORCPT ); Mon, 16 Nov 2020 15:16:22 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:11997 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729248AbgKPUQV (ORCPT ); Mon, 16 Nov 2020 15:16:21 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 16 Nov 2020 12:16:30 -0800 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 16 Nov 2020 20:16:20 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.177) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 16 Nov 2020 20:16:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kqxdJwLIMj/T/gEu8I0n+LHtd0JHdd7pmWocgqZyeutEy15BKDAQq+983DzPaHn7e7YHBLGJYcBynQbmeQgwVgeEyLys7l5gpIkeMldvaizBZW14tueYyyWyfvaiqWyGkD/Eg5sxcoJjMEhX1f39cdYNZ/8PxyVtfBFnlro1LZZBAyahViMFt+V48lJcMuqN9e7EufMim9/VOdHH8MGonxJFCFuocPrqYjla7Tlt8f9/f4kFT2oGfARuGohcvUBaAk8YwRjvEQP24VceSUJ6MEK+4MWTgXa+IbIRPybUo6wkUbwRP49WcwjTbP2ZQ3AD/7ipEawwifClWsvjnyxXgw== 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-SenderADCheck; bh=aPNCuKOxdVgADTdxhvq0pU9C2ZUChbdl5OcB2L5rMMk=; b=ePM+DZyR0pkQdUtPbHlze2i7/CaVG6M5B8YdSOWgoBRWr2zclc0SgpBr/AH9UbN5tS8WJRcOH8T9bg4pkhx60cIsehGq0pUZQSk2Nup3jJ1XmJvq+SDF799X4YUAau9JalB60MSlyUK4huqc+JAnS4VYpap4q4oUL8Y4bO01DAcpqHXUwQAs1aj+mBf9JyUgzoR7F6mzpuexcfBQ33FY4havVnl5FHSMPqhwFrZHlckQBqlbnRm9/iGwYJHvzMcCSK39BNxCrFBBLb57cuRrWPfC4tv8v13XnDEl8z7LpmMi65wMeJ2ISFuqOXaZZgCOv6SJbQfqDo8dIZ5qs+OKhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) by DM6PR12MB4810.namprd12.prod.outlook.com (2603:10b6:5:1f7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25; Mon, 16 Nov 2020 20:16:19 +0000 Received: from DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9]) by DM6PR12MB3834.namprd12.prod.outlook.com ([fe80::e40c:730c:156c:2ef9%7]) with mapi id 15.20.3564.028; Mon, 16 Nov 2020 20:16:19 +0000 From: Jason Gunthorpe To: Subject: [PATCH 4/4] util: Use GCC 10's attribute symver to define compat symbol versions Date: Mon, 16 Nov 2020 16:16:16 -0400 Message-ID: <4-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> In-Reply-To: <0-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR01CA0061.prod.exchangelabs.com (2603:10b6:208:23f::30) To DM6PR12MB3834.namprd12.prod.outlook.com (2603:10b6:5:14a::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (156.34.48.30) by MN2PR01CA0061.prod.exchangelabs.com (2603:10b6:208:23f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.25 via Frontend Transport; Mon, 16 Nov 2020 20:16:18 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kekvA-006kmJ-Nr for linux-rdma@vger.kernel.org; Mon, 16 Nov 2020 16:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1605557790; bh=+igmOoWzzOVgWRl7NVGOd4YgqTlBSGeDQKeBMfmqGNs=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: Subject:Date:Message-ID:In-Reply-To:References: Content-Transfer-Encoding:Content-Type:X-ClientProxiedBy: MIME-Version:X-MS-Exchange-MessageSentRepresentingType; b=KDZHMUiHsi87rWtS93k4q8BWFIkRJZ4iBWP2kL01UQuQUDZrB4lwMySSa6FFIVxG6 9q1N8/Bry8/jahwlIpayd6qR14HSmeQfkTGsnHwlCVwh6tv8xOBhw3eM7hY4QyVyYO GqCB+eV9Y7MSJUaUnL4rQu1FFoA6U08wxEmsS/A47AEqmD5z+ognPM8Q54HI5dRasu 8BP7f4IGH2QD9HEvZkfbvkYYAs8MV3sl/uSZm/bzpgkvpAiXueo8xe/n2ASR5zaRIK fmKlnkv6FGxm/6GXm47sT7dUClJu6Sjes/Ns/BW7LvRHoI0OT3UnjgMETSQVf1/tTE GfEFdPTEbKzlA== Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This has no behavior change but allows LTO to be used to build rdma-core. Also remove the LTO disablement in the spec files since it works now. Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 13 +++++++++++++ buildlib/FindLDSymVer.cmake | 28 +++++++++++++++++++--------- buildlib/config.h.in | 2 ++ redhat/rdma-core.spec | 7 ------- suse/rdma-core.spec | 2 -- util/symver.h | 9 +++++++-- 6 files changed, 41 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab9caff1f68d02..33fd120f23581a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,6 +282,16 @@ CHECK_C_SOURCE_COMPILES(" HAVE_FUNC_ATTRIBUTE_IFUNC FAIL_REGEX "warning") +CHECK_C_SOURCE_COMPILES(" + #include + + void _sym(void); + __attribute__((__symver__(\"sym@TEST_1.1\"))) void _sym(void) {} + + int main(int argc,const char *argv[]) { _sym(); }" + HAVE_FUNC_ATTRIBUTE_SYMVER + FAIL_REGEX "warning") + # The code does not do the racy fcntl if the various CLOEXEC's are not # supported so it really doesn't work right if this isn't available. Thus hard # require it. @@ -700,6 +710,9 @@ endif() if (NOT HAVE_FUNC_ATTRIBUTE_IFUNC) message(STATUS " Compiler attribute ifunc NOT supported") endif() +if (NOT HAVE_FUNC_ATTRIBUTE_SYMVER) + message(STATUS " Compiler attribute symver NOT supported, can not use LTO") +endif() if (NOT HAVE_COHERENT_DMA) message(STATUS " Architecture NOT able to do coherent DMA (check util/udma_barrier.h) some providers disabled!") endif() diff --git a/buildlib/FindLDSymVer.cmake b/buildlib/FindLDSymVer.cmake index 48238f2407f4fd..d4065d92220a6e 100644 --- a/buildlib/FindLDSymVer.cmake +++ b/buildlib/FindLDSymVer.cmake @@ -27,15 +27,25 @@ else() endif() # And matching source, this also checks that .symver asm works -check_c_source_compiles(" -void ibv_get_device_list_1(void); -void ibv_get_device_list_1(void){} -asm(\".symver ibv_get_device_list_1, ibv_get_device_list@IBVERBS_1.1\"); -void ibv_get_device_list_0(void); -void ibv_get_device_list_0(void){} -asm(\".symver ibv_get_device_list_0, ibv_get_device_list@@IBVERBS_1.0\"); - -int main(int argc,const char *argv[]){return 0;}" _LDSYMVER_SUCCESS) +if (HAVE_FUNC_ATTRIBUTE_SYMVER) + check_c_source_compiles(" + void ibv_get_device_list_1(void); + __attribute((__symver__(\"ibv_get_device_list@IBVERBS_1.1\"))) + void ibv_get_device_list_1(void){} + void ibv_get_device_list_0(void); + __attribute((__symver__(\"ibv_get_device_list@IBVERBS_1.0\"))) + void ibv_get_device_list_0(void){} + int main(int argc,const char *argv[]){return 0;}" _LDSYMVER_SUCCESS) +else() + check_c_source_compiles(" + void ibv_get_device_list_1(void); + void ibv_get_device_list_1(void){} + asm(\".symver ibv_get_device_list_1, ibv_get_device_list@IBVERBS_1.1\"); + void ibv_get_device_list_0(void); + void ibv_get_device_list_0(void){} + asm(\".symver ibv_get_device_list_0, ibv_get_device_list@@IBVERBS_1.0\"); + int main(int argc,const char *argv[]){return 0;}" _LDSYMVER_SUCCESS) +endif() file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.map") set(CMAKE_EXE_LINKER_FLAGS "${SAFE_CMAKE_EXE_LINKER_FLAGS}") diff --git a/buildlib/config.h.in b/buildlib/config.h.in index e22e136a5878aa..c5b0bf55709d03 100644 --- a/buildlib/config.h.in +++ b/buildlib/config.h.in @@ -46,6 +46,8 @@ #cmakedefine HAVE_FUNC_ATTRIBUTE_IFUNC 1 +#cmakedefine HAVE_FUNC_ATTRIBUTE_SYMVER 1 + #cmakedefine HAVE_WORKING_IF_H 1 // Operating mode for symbol versions diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec index e1ee0801344a45..179f4a61aca9a9 100644 --- a/redhat/rdma-core.spec +++ b/redhat/rdma-core.spec @@ -279,13 +279,6 @@ easy, object-oriented access to IB verbs. %setup %build -# This package uses top level ASM constructs which are incompatible with LTO. -# Top level ASMs are often used to implement symbol versioning. gcc-10 -# introduces a new mechanism for symbol versioning which works with LTO. -# Converting packages to use that mechanism instead of toplevel ASMs is -# recommended. -# Disable LTO -%define _lto_cflags %{nil} # New RPM defines _rundir, usually as /run %if 0%{?_rundir:1} diff --git a/suse/rdma-core.spec b/suse/rdma-core.spec index c89ecba6242f1f..229c75bb0118f7 100644 --- a/suse/rdma-core.spec +++ b/suse/rdma-core.spec @@ -389,8 +389,6 @@ Pyverbs is a Cython-based Python API over libibverbs, providing an easy, object-oriented access to IB verbs. %prep -# Make sure LTO is disable as rdma-core fails to compile with LTO enabled -%define _lto_cflags %{nil} %setup -q -n %{name}-%{version}%{git_ver} %build diff --git a/util/symver.h b/util/symver.h index ae413050650e0f..eb14c57ebdc132 100644 --- a/util/symver.h +++ b/util/symver.h @@ -58,11 +58,16 @@ warnings. See also Documentation/versioning.md */ +#if HAVE_FUNC_ATTRIBUTE_SYMVER #define _MAKE_SYMVER(_local_sym, _public_sym, _ver_str) \ - asm(".symver " #_local_sym "," #_public_sym "@" _ver_str) + __attribute__((__symver__(#_public_sym "@" _ver_str))) +#else +#define _MAKE_SYMVER(_local_sym, _public_sym, _ver_str) \ + asm(".symver " #_local_sym "," #_public_sym "@" _ver_str); +#endif #define _MAKE_SYMVER_FUNC(_public_sym, _uniq, _ver_str, _ret, ...) \ _ret __##_public_sym##_##_uniq(__VA_ARGS__); \ - _MAKE_SYMVER(__##_public_sym##_##_uniq, _public_sym, _ver_str); \ + _MAKE_SYMVER(__##_public_sym##_##_uniq, _public_sym, _ver_str) \ _ret __##_public_sym##_##_uniq(__VA_ARGS__) #if defined(HAVE_FULL_SYMBOL_VERSIONS) && !defined(_STATIC_LIBRARY_BUILD_)