From patchwork Wed Dec 20 23:13:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10126791 X-Patchwork-Delegate: leon@leon.nu Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F39060245 for ; Wed, 20 Dec 2017 23:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F1B7291BD for ; Wed, 20 Dec 2017 23:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73E4C291DB; Wed, 20 Dec 2017 23:14:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E59A0291BD for ; Wed, 20 Dec 2017 23:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755811AbdLTXOG (ORCPT ); Wed, 20 Dec 2017 18:14:06 -0500 Received: from mail-eopbgr30040.outbound.protection.outlook.com ([40.107.3.40]:23280 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756720AbdLTXOD (ORCPT ); Wed, 20 Dec 2017 18:14:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bSb966tMSv4KT+/q6UJunIJSoKvRXLaW9dF2AY2jvP4=; b=crbSCwMb3CcFlbnZY6ct9yhjA9XgSsGenIpqdBc1KfYEAwz6ur5yIGWlOd/UcH6cJ5WZ8Yfl/tHdXQikAF7sA/R20NK6/iu9liFtXO5ZevVxzPXT+/sAWy7CL0cMhF71n4nItuog/ldzXlO1hDrHtGjdect3iubDT/EVnrrL1yM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (70.74.179.152) by AM4PR0501MB2849.eurprd05.prod.outlook.com (2603:10a6:200:5c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Wed, 20 Dec 2017 23:14:01 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eRnYc-00052V-VX; Wed, 20 Dec 2017 16:13:50 -0700 Date: Wed, 20 Dec 2017 16:13:50 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, Yishai Hadas Subject: [PATCH rdma-core] verbs: Remove comp_mask checks from verbs.h Message-ID: <20171220231350.GA19130@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [70.74.179.152] X-ClientProxiedBy: AM0PR0102CA0059.eurprd01.prod.exchangelabs.com (2603:10a6:208::36) To AM4PR0501MB2849.eurprd05.prod.outlook.com (2603:10a6:200:5c::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64eeb5e2-404e-4e64-32f2-08d547ff5b60 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7153060); SRVR:AM4PR0501MB2849; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2849; 3:q11fJnnY7kWtNvJKWNBdWH3q7ZCLdB6BW3N0hxI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5PxgiaFlk3LQWs68z0RBbQgrZfgKjGPKNpo0QDMGV1FhHgpnnpebzzcthy/FfsUM3Yxv75iucUzQHcqtXjc5QTxXCRq16rEjBOMOYy/1acEoMVzPtQxymbIkgmwLQ2gMCcU9nbqlzcCTnhpIXeBcZIgV7AXfspY6uC0z3SGd+yVfeAFKhN4ZA09kikK4Db/rawT8ovuB5d+xXz/IYmxpTCmAXB+Yh6+fVrVmf1wA47kZyZ2G2tw1yKzBi10fKrnxoturNqOPEUyw6UCWljrOMrz5/sjYzZZwtHBztH0kOZ5agmO4/5bg7V7fZtwmqWf1VANJ4RCmd+ccKwaLdWZGJQonaNR; 4:NSuiCEP+L481RRbUCM22qGnZLLdna5CtQQntfyRxmanFkMRzNzlhDyrcycNyq59XHAb7/d+pxLhYw0C5VP0wl91kbqsIAHSQBUsAdBBvvL7anECSIgcMq3oPLjPS1aNjhneww58DYvqdH4eKFq0ywyBUKLPmDJOI/2XLAq/Uf4YRva+7cXBhrLmmwW2vRCb10Zk2pZwfZc+uqUoE4M3DrHuEKni/AFro12zFijGtlkmzH1OrwGm18VYFDzG0Q0FWvjX6EUFaOfdX3O6KuK62ew== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231023)(10201501046)(6055026)(6041268)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM4PR0501MB2849; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM4PR0501MB2849; X-Forefront-PRVS: 0527DFA348 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(396003)(39860400002)(39380400002)(346002)(189003)(199004)(122856001)(47776003)(83506002)(9686003)(52116002)(105586002)(386003)(33896004)(106356001)(50466002)(83796002)(316002)(57986006)(58126008)(16586007)(6636002)(33656002)(2906002)(5660300001)(66066001)(46656002)(69596002)(81166006)(478600001)(8676002)(36756003)(81156014)(6116002)(3846002)(9746002)(1076002)(9786002)(68736007)(97736004)(53936002)(7736002)(8936002)(86362001)(6862004)(575784001)(23726003)(305945005)(18370500001)(24400500001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2849; H:mlx.ziepe.ca; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0501MB2849; 23:kzU57Avo/DsLlJ2iOWuPtFUfvu/UG6IKmHvGhea?= =?us-ascii?Q?NPDgNQw4oxMC0Y7LDSlt6UJ2Z8nILHUs11kvCtXCl6YaivXbmLUXd9tQlIZ2?= =?us-ascii?Q?180q60tnqfG7PGZs3fCa7ugsZawydoxaChKpZha5pL1Qb4xUDOn6hSj9WkaB?= =?us-ascii?Q?sxNyFEVkKFhxpRHAPtQ1Xl2Eum3z9AfmGO25xtG4evqOz/Emlk6QTlvDFbT8?= =?us-ascii?Q?mQec1yM/IAkL5ZJqtyo33CCQLWmNVghD7G1uiUnIWz9q3aoWCoiCZT6+4ugm?= =?us-ascii?Q?//ppN5Yhc1K6hVh3TtjIey7De8K9QjAdQuNwNfUiPO0ce5N54JCHyrmReNF6?= =?us-ascii?Q?oi0sBHepB7k+Q+pPz6uJmWCA7ZL+i+GJyVwUU08FDfSYYBpTFUeC4o/onOkI?= =?us-ascii?Q?n1+TYhWY1RHXapLRcfqI9IsiTWlX2DiEhg4Pl+KUbCjc0xOSbarGcMrP2Fwz?= =?us-ascii?Q?bowsh1PWOHgFnBH5rEOWJG5EcXTZiThZ75OLQ7z4weJzrKoJVqKJzTKT2q58?= =?us-ascii?Q?Upz1S2bUhG0ra6+KolorfGdcTwDCrKayHieJ/q7K2ovs/+A1LLX/iN2fdFyH?= =?us-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hb/YQZJeBqE/WSPTvyOIx+hjJsUoJhrNuYJl0YYNPD9sOoA8eQSfXa8U3hsSq+VH45zph5J53VEchp+mxwna0lAKepwXsErHy1Tfwx81RYt1wIeR+Nzw40Qj+4vZsQ+RaduXlpzuH2rdWqBRrQEWMtD8=; 5:Mj9qmQwkS7LPCI+f8XCc+57sU5JMyh5XRTLeg9j9OEKUS36iCoD4hAMgjgPTcjdjsRTXWhDt+Lhl/+cQVslu7pN8wVB9aB+gQgkDhU98hJ+QmRiDNBdZ4dZjo9W6LsXSAYITjqzLuTCpAvvD7XvMS7mX7KZomL+7PQtzTVTHv4w=; 24:1OWmZRZDf102VjmFGBPcPrWTm8UBC/MApjUUQhSzZsUwpKMbn8p3+Vr1//WK5taT2wvzkoxWmJPMekpUmuVn5/dSo1plkU3VltX143xeOQ0=; 7:fkquMzZjNwJfbWcTuzX7J97MqLiU8Rpz/jXR40PAXq8kUTDBMvq0gu7DHIHWOdXniT4q0/VHx0UlRagpmRn3E7X8w3IYzilSSr8JFYZckOEDWxCGjhOIrNMC4efGGZnwaN+QtO6vn0hW7HngL7Gcstwqv5o7lAPj5oCguxGO5typUPUd3CfgDYzdDbKOD55+E9fc6JAfN8kwqmcCIgkYl4yvHFrH7O7Wh4v+AIjFJMoYuXTXevfPk8cYxKKTjtX0 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 23:14:01.6338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64eeb5e2-404e-4e64-32f2-08d547ff5b60 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2849 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the case of ibv_create_cq_ex this duplicates a check already done by ibv_cmd_create_cq_ex. In the case of ibv_queryrt_values_ex, there is no check in the function op, which is an ABI mistake. So move the check there. comp_mask should never be tested in the inline trampolines to generate EINVAL as the inlines are part of the app and could be from a future libibverbs with an expanded comp_mask. Signed-off-by: Jason Gunthorpe --- libibverbs/verbs.h | 8 -------- providers/mlx4/verbs.c | 3 +++ providers/mlx5/verbs.c | 3 +++ 3 files changed, 6 insertions(+), 8 deletions(-) I missed these when reviewing the earlier patches, and now people are cargo-cult copying them into new APIs. diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 775bad52601781..7b53a6f5dff51f 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1967,11 +1967,6 @@ struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context *context, return NULL; } - if (cq_attr->comp_mask & ~(IBV_CQ_INIT_ATTR_MASK_RESERVED - 1)) { - errno = EINVAL; - return NULL; - } - return vctx->create_cq_ex(context, cq_attr); } @@ -2200,9 +2195,6 @@ ibv_query_rt_values_ex(struct ibv_context *context, if (!vctx) return ENOSYS; - if (values->comp_mask & ~(IBV_VALUES_MASK_RESERVED - 1)) - return EINVAL; - return vctx->query_rt_values(context, values); } diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c index ec02bd4642b2d2..0a4ed1fde001eb 100644 --- a/providers/mlx4/verbs.c +++ b/providers/mlx4/verbs.c @@ -135,6 +135,9 @@ int mlx4_query_rt_values(struct ibv_context *context, uint32_t comp_mask = 0; int err = 0; + if (!check_comp_mask(values->comp_mask, IBV_VALUES_MASK_RAW_CLOCK)) + return EINVAL; + if (values->comp_mask & IBV_VALUES_MASK_RAW_CLOCK) { uint64_t cycles; diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index a3323fd47651a7..579c0f3402d54d 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -108,6 +108,9 @@ int mlx5_query_rt_values(struct ibv_context *context, uint32_t comp_mask = 0; int err = 0; + if (!check_comp_mask(values->comp_mask, IBV_VALUES_MASK_RAW_CLOCK)) + return EINVAL; + if (values->comp_mask & IBV_VALUES_MASK_RAW_CLOCK) { uint64_t cycles;