From patchwork Mon Feb 16 16:04:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 44720 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6C82B21544 for ; Mon, 16 Feb 2015 16:04:45 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id b13sf19896868wgh.2 for ; Mon, 16 Feb 2015 08:04:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=0e6LJLqQBqnB6V5LIbTgpfmrrj8CQTf9QhWdSTichQA=; b=DU6qDuHAtQGMHVL/09gMMyBielf5dCDTNxFeGnjos04s3TJQy3WM/0jAMR5ZKgRGez See8U+MnlcBGLuwCs9pemgpdXVY9SteYGnyMpGjRqwuEVgihH8FUiYYi060s38eD+ozA f1Xu2vuJgBY+QEKWoZ34G7ZzDxoaS3uzU8vomPltYjiz1R9BGIYwMgPFIcb1hKyGzVwc w1aPw5xmK0P3nmJ0MctBRGZVPBkbSrzz1XtVt8Ci5PeRGgwgMP89uuwoB2iieHNjFZFx sH+u9CC0OftIr2vGqOettLNEwhXaF0QM6X33NtR8kwz7C6DUkTdFI7fbhzh47jTZTWyb EcdA== X-Gm-Message-State: ALoCoQkO2ZCCZcg+HSkvM0eOjHEKPCjmkvANqHkzol7+ej53SHBDvILS6XadVm8jg1NEqS+s78ee X-Received: by 10.194.221.65 with SMTP id qc1mr3038095wjc.7.1424102684768; Mon, 16 Feb 2015 08:04:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.231 with SMTP id bb7ls306406lab.50.gmail; Mon, 16 Feb 2015 08:04:44 -0800 (PST) X-Received: by 10.152.6.195 with SMTP id d3mr23582816laa.36.1424102684605; Mon, 16 Feb 2015 08:04:44 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id mv5si10083175lbb.104.2015.02.16.08.04.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Feb 2015 08:04:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labgq15 with SMTP id gq15so30229893lab.6 for ; Mon, 16 Feb 2015 08:04:44 -0800 (PST) X-Received: by 10.152.26.199 with SMTP id n7mr23310111lag.29.1424102684516; Mon, 16 Feb 2015 08:04:44 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1670291lbj; Mon, 16 Feb 2015 08:04:43 -0800 (PST) X-Received: by 10.140.130.6 with SMTP id 6mr644329qhc.18.1424102683124; Mon, 16 Feb 2015 08:04:43 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 73si14577347qga.22.2015.02.16.08.04.41 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 16 Feb 2015 08:04:43 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YNOA1-00085g-Mq; Mon, 16 Feb 2015 16:04:37 +0000 Received: from mail-la0-f46.google.com ([209.85.215.46]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YNO9v-00085W-Ud for lng-odp@lists.linaro.org; Mon, 16 Feb 2015 16:04:32 +0000 Received: by lamq1 with SMTP id q1so30099218lam.5 for ; Mon, 16 Feb 2015 08:04:26 -0800 (PST) X-Received: by 10.152.181.196 with SMTP id dy4mr20609255lac.45.1424102665950; Mon, 16 Feb 2015 08:04:25 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-106.2com.net. [46.188.125.106]) by mx.google.com with ESMTPSA id dl2sm3018750lbb.32.2015.02.16.08.04.24 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Feb 2015 08:04:25 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 16 Feb 2015 19:04:17 +0300 Message-Id: <1424102658-26557-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: crypto patch Subject: [lng-odp] [PATCH 1/2] linux-generic: handle copy error in odp_crypto_operation X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In _odp_packet_copy_to_packet copying of packet can fail, with check for enought room in the packet. That may happen due to allocation error or possible memory corruption. Just call ODP_ABORT here. https://bugs.linaro.org/show_bug.cgi?id=1054 CID 85004: Unchecked return value (CHECKED_RETURN) Calling "_odp_packet_copy_to_packet" without checking return value (as is done elsewhere 5 out of 6 times). Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_crypto.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index bc0f961..fb1e3fc 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -355,6 +355,7 @@ odp_crypto_operation(odp_crypto_op_params_t *params, enum crypto_alg_err rc_auth = ODP_CRYPTO_ALG_ERR_NONE; odp_crypto_generic_session_t *session; odp_crypto_op_result_t local_result; + int ret; session = (odp_crypto_generic_session_t *)(intptr_t)params->session; @@ -367,8 +368,13 @@ odp_crypto_operation(odp_crypto_op_params_t *params, if (params->pkt != params->out_pkt) { if (odp_unlikely(ODP_PACKET_INVALID == params->out_pkt)) ODP_ABORT(); - _odp_packet_copy_to_packet(params->pkt, 0, params->out_pkt, 0, - odp_packet_len(params->pkt)); + ret = _odp_packet_copy_to_packet(params->pkt, + 0, + params->out_pkt, + 0, + odp_packet_len(params->pkt)); + if (odp_unlikely(ret)) + ODP_ABORT(); _odp_packet_copy_md_to_packet(params->pkt, params->out_pkt); odp_packet_free(params->pkt); params->pkt = ODP_PACKET_INVALID;