From patchwork Tue Nov 7 09:00:14 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: 118126 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3725639qgn; Tue, 7 Nov 2017 01:03:33 -0800 (PST) X-Google-Smtp-Source: ABhQp+TaqwVV5er/6G2SOa19rfKIMQZCc9PVo80bPtI6EPlviWno8cw3g3X02jtFzfYngN6rg1NR X-Received: by 10.107.165.78 with SMTP id o75mr23562173ioe.194.1510045413412; Tue, 07 Nov 2017 01:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510045413; cv=none; d=google.com; s=arc-20160816; b=zRBNxGHErjjs3Jl/ex1p/yt3oSEM5ELQTkCw4SkAxEmVkLyflV6k/LSYlkYBomQuIk cIQ8Jg3zvysrevpxSKNSi4T0U40EWVmRmfMq3Evaejps5Ar1qyESQbOGoOVxhgXNjhYn dlpjhsQkebXSRra7v0NL49qi+ezwSemYT4Q1TBRvkwA4JeB1GIWPN7zzqG0imSlPjF57 48MTnvgnZcTrIqg1wPd4GZhqyb6OB+khnozsINGac8sGLJKiZbK32chzOsjRKVKib9S/ dgmlhhMIptxfsT52dH3J95ocT/kVzooi6pz0kGiILrJpt8pbtppeFYC9xzwk2/lXlOWc ILJg== 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=jusZaV1z85sqX4h4GT41z9fsJxKM7ne4pfex5DPDCv4=; b=nZQpoxeq78GaDaY9h2ikMc9UZmM7uy35m9G8HxeINRqLzaTcGKLG8d4MZBhtyNgcdG eXlxLMlqvmTD0SvvcAkXzAuTe0XxypGhqirSUJVhK/Zs2RsgXu1YakEoaScJIy0CVxmm vrxuw+w6e+Dyp7MPvtt4tENgMLBG0soPcAMNbB6iKOtWx+6EurEBvbsMw/VxnSKC1vSq iWIX6RuxCAFB60XZV0exTtOopu+wYRzoQWN3CBMWJTytIieVjgYRpy1l3XEWXhHQdEor OLu38iEzEGc3dcSkp89QA00BXcFJl7+6BfLp921+c5NU9Qajols61k/MPu8XJS+CM5BA B5hg== 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 t15si858243iti.159.2017.11.07.01.03.33; Tue, 07 Nov 2017 01:03:33 -0800 (PST) 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 E4D0A60C4E; Tue, 7 Nov 2017 09:03:32 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 876A660C6A; Tue, 7 Nov 2017 09:00:46 +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 E4D4360765; Tue, 7 Nov 2017 09:00:27 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 227226069B for ; Tue, 7 Nov 2017 09:00:23 +0000 (UTC) Received: from mxback18j.mail.yandex.net (mxback18j.mail.yandex.net [IPv6:2a02:6b8:0:1619::94]) by forward100p.mail.yandex.net (Yandex) with ESMTP id E2CAA5102095 for ; Tue, 7 Nov 2017 12:00:20 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback18j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id co3YWnqaZi-0K6Gi8WL; Tue, 07 Nov 2017 12:00:20 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id AmLcx04vWq-0KfGCGXU; Tue, 07 Nov 2017 12:00:20 +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: Tue, 7 Nov 2017 12:00:14 +0300 Message-Id: <1510045214-25000-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510045214-25000-1-git-send-email-odpbot@yandex.ru> References: <1510045214-25000-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 274 Subject: [lng-odp] [PATCH v2 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. Fixes bug: https://bugs.linaro.org/show_bug.cgi?id=3411 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: e069ae9f65ab3e029f2a61b5d60ab0180b4b6ea9 **/ 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);