From patchwork Fri Nov 3 14:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 117899 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3349790edm; Fri, 3 Nov 2017 07:01:10 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qf4AvyzaUFPLJYyJj+mmYs3YvaO710g8sGZJ1DB23D/KvFFso9lOxtth9FZai1jUYAjtTe X-Received: by 10.55.53.9 with SMTP id c9mr9179689qka.177.1509717670490; Fri, 03 Nov 2017 07:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509717670; cv=none; d=google.com; s=arc-20160816; b=t/3bnFJlJhBkpP9sJVQAZRYVOBQrIvvvmJQYA+P/eaDTsJODjZv4NkbDH4Oxzw5RLG uZiua026TVTrBJIFZtrVcLPbycInaZ4RdjeoCECU8jvRlZx+yNrTbfqiMbqnqIrgHTpL Jow8bDov15CPrerIdwQmCMWHwEHIb9s9F/pj2vQFGL96yW3usMTDH0FWr3wZ0o3AMKfo GZZjdzx89R5Ofj4C91Kj2yvgQ2BZ6aQcHS+rovVT7N5gqnRpygdVADZH2pbfDpWH6BmA aJlZlE/lwNNlN96OTY4rTD6nbEPG2LpsYeX8o2rpTvDXBimvzmV3BeP3zp3ZV+KomFzZ LlSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=G6KC9bRD/I3vEmV0y5VRSsx1kW0giBeDf4GtY8VX7UU=; b=eLcOAMYI1VILMOQUOHpk2gQSx2dl9XfCVHPy5+2XsQXm8uHXtInIFnzOWxx+wWi6mo YkHGE8pICcSle56QVUGvKuM7Ci6+VkjyR6yqGcM3fVNupCTzkOpwpC6S4ShS+0QU6qIO ZlH/A6X/UxxM8jKd0NWnHCmcYy5bcosDNsivQMRKVHnsdX+qA5zE+QA24hNMp8S6aqDV Y7aBo1w0Y/OSRCu7x5BJ8Ihm7q2QnTe+aV25b6npWcDpgQlvfUfLIoz854lZ3UhXfLs5 qO+LrdDRckFKrQA5DUyODnjIVHZ7FFrXPtNDkgzoip2NBC8WEGZvpIyd/hqvmIRpzPZG w37Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id y26si1988809qtj.176.2017.11.03.07.01.10; Fri, 03 Nov 2017 07:01:10 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 0E6F3610B2; Fri, 3 Nov 2017 14:01:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1D58360509; Fri, 3 Nov 2017 14:00:21 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3ABA3607E1; Fri, 3 Nov 2017 14:00:15 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 826DE60389 for ; Fri, 3 Nov 2017 14:00:10 +0000 (UTC) Received: from mxback14g.mail.yandex.net (mxback14g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:93]) by forward104o.mail.yandex.net (Yandex) with ESMTP id 02F6C704352 for ; Fri, 3 Nov 2017 17:00:09 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback14g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id S6o5tLjvku-08vmkHme; Fri, 03 Nov 2017 17:00:08 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id iE8MiELA7F-08auIb70; Fri, 03 Nov 2017 17:00:08 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 3 Nov 2017 17:00:06 +0300 Message-Id: <1509717606-13378-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509717606-13378-1-git-send-email-odpbot@yandex.ru> References: <1509717606-13378-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 274 Subject: [lng-odp] [PATCH v1 1/1] linux-gen: crypto: fix openssl_lock pointer type X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Wrong pointer type (pointer to pointer) to openssl_lock array caused data overlapping when running on other than 64-bit machines. Fixed pointer type and simplified global data structure to contain only one dynamically sized array (openssl locks). Session array was already fixed size but was not defined as such. Signed-off-by: Petri Savolainen Signed-off-by: Viktor Tikkanen --- /** Email created from pull request 274 (psavol:master-openssl-lock) ** https://github.com/Linaro/odp/pull/274 ** Patch: https://github.com/Linaro/odp/pull/274.patch ** Base sha: 2dd964e170d71078cfe03d4c9e00c6f592b4326b ** Merge commit sha: 24c118a015a9af290f4d232c4cd49996574d29b9 **/ platform/linux-generic/odp_crypto.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 40b6d74b4..9cf903d03 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -83,9 +83,9 @@ typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { odp_spinlock_t lock; - odp_ticketlock_t **openssl_lock; odp_crypto_generic_session_t *free; - odp_crypto_generic_session_t sessions[0]; + odp_crypto_generic_session_t sessions[MAX_SESSIONS]; + odp_ticketlock_t openssl_lock[0]; }; static odp_crypto_global_t *global; @@ -961,11 +961,9 @@ static void ODP_UNUSED openssl_lock(int mode, int n, int line ODP_UNUSED) { if (mode & CRYPTO_LOCK) - odp_ticketlock_lock((odp_ticketlock_t *) - &global->openssl_lock[n]); + odp_ticketlock_lock(&global->openssl_lock[n]); else - odp_ticketlock_unlock((odp_ticketlock_t *) - &global->openssl_lock[n]); + odp_ticketlock_unlock(&global->openssl_lock[n]); } int @@ -977,8 +975,7 @@ odp_crypto_init_global(void) int nlocks = CRYPTO_num_locks(); /* Calculate the memory size we need */ - mem_size = sizeof(*global); - mem_size += (MAX_SESSIONS * sizeof(odp_crypto_generic_session_t)); + mem_size = sizeof(odp_crypto_global_t); mem_size += nlocks * sizeof(odp_ticketlock_t); /* Allocate our globally shared memory */ @@ -998,12 +995,8 @@ odp_crypto_init_global(void) odp_spinlock_init(&global->lock); if (nlocks > 0) { - global->openssl_lock = - (odp_ticketlock_t **)&global->sessions[MAX_SESSIONS]; - for (idx = 0; idx < nlocks; idx++) - odp_ticketlock_init((odp_ticketlock_t *) - &global->openssl_lock[idx]); + odp_ticketlock_init(&global->openssl_lock[idx]); CRYPTO_THREADID_set_callback(openssl_thread_id); CRYPTO_set_locking_callback(openssl_lock);