From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 96E792C8 for ; Wed, 23 May 2018 14:11:19 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id f8-v6so8540158wmc.4 for ; Wed, 23 May 2018 05:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jPBcVqID0Kc/svr3DK9nd1B9QQAsRMspiyPCE/xLQGA=; b=kvy6AAM6Gn7kb4a513GcvY3S9Zuj1XsiCEFpQvdObWhMco8ydeWb2dr6QNtWMyYf+4 B4ONezen9uII0ZLaK5ShgP1HQplrXbh9acEIlrD81DcPBppqnXngUjU/oelNVVn9qz03 CpyJirTgML1LumvAX2dklOvvYE+TGftpCgtpSvlz6ek5dW+toXnlKU7VNED+KlE24dUP 1N2lx7vdRfGamSAPEC3HN4WB82WDnNZsu36s0WoM6UCGvwAQ3cuzrt+/KDXdas/zFIK5 p2YEhZlkj+aNi89ekCuudC+a06RdfXgxO2XT3pqXTJJXmQMtVbvQG2r76iF4KrKy2UZR xrKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jPBcVqID0Kc/svr3DK9nd1B9QQAsRMspiyPCE/xLQGA=; b=NqUj0B0C4U83D4cCm9vg3B5ONPBvQ/8umHHXkPN0KFynVNyHOdQHpZEt//WQ4tQ+wJ LaVeIliGQ9JsMntGE8L53jMfxv91Qy9Nxhq8dyHA++IE+Bm917Vv9WBXxnNjuk4GZlgB qYYYlXySLLl4jI30ODHeq0WkY6UQmZk6T1Nuvy5smR3lOMVbGBFWJOExp5hyiVb76U+j SWboG94vGNYxfCOSSW+Ep6Fj5ZaVjBtzsX+kDqFwwYQQvpxO3VwcyKOjbJwenlongkpu nc3890mab5At3KSVovrQmzvnGG1lzMqlwM17/ppinbMT51rDEDbAwnbn9GX7ehFSh/pe JTzw== X-Gm-Message-State: ALKqPwd8z0SG3u243/QCM5URS0IG6T1712w4uJ0JFI6ohhE7B9e99MK2 dfU8XWkg/X6rrD331+DFsDegD6IE0tU= X-Google-Smtp-Source: AB8JxZr+Iwxep8fLchCfPVSttaPdt/Qj+2bmagrHNVoRQZhmQ0bThUFFJxO9UQCdLpR5Tm/LeVwqag== X-Received: by 2002:a1c:d53:: with SMTP id 80-v6mr4510551wmn.138.1527077479310; Wed, 23 May 2018 05:11:19 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id u69-v6sm3394321wma.37.2018.05.23.05.11.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 05:11:18 -0700 (PDT) From: luca.boccassi@gmail.com To: Pablo de Lara Cc: Fiona Trahe , dpdk stable Date: Wed, 23 May 2018 13:09:50 +0100 Message-Id: <20180523121010.8385-39-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180523121010.8385-1-luca.boccassi@gmail.com> References: <20180516101323.2234-2-luca.boccassi@gmail.com> <20180523121010.8385-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'cryptodev: fix supported size check' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2018 12:11:19 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/25/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From cb3df2753561dfcefbc0ee18c747c9d501ff1e33 Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Tue, 15 May 2018 20:13:13 +0100 Subject: [PATCH] cryptodev: fix supported size check [ upstream commit 23f0db51adbeb5ec098a9a6ed7b888f96ef7729b ] Crypto capability structure contains supported sizes for key, IV, digest, etc. on different algorithms. These sizes can be expressed as a single value or a range of values. The check was broken when a size was checked against a range with multiple values. Also, for more clarity, the param_range_check macro has been converted into a function. Fixes: 38227c0e3ad2 ("cryptodev: retrieve device info") Signed-off-by: Pablo de Lara Acked-by: Fiona Trahe --- lib/librte_cryptodev/rte_cryptodev.c | 45 ++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 8745b6b02..5728d2e05 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -262,19 +262,40 @@ rte_cryptodev_sym_capability_get(uint8_t dev_id, } -#define param_range_check(x, y) \ - (((x < y.min) || (x > y.max)) || \ - (y.increment != 0 && (x % y.increment) != 0)) +static int +param_range_check(uint16_t size, const struct rte_crypto_param_range *range) +{ + unsigned int next_size; + + /* Check lower/upper bounds */ + if (size < range->min) + return -1; + + if (size > range->max) + return -1; + + /* If range is actually only one value, size is correct */ + if (range->increment == 0) + return 0; + + /* Check if value is one of the supported sizes */ + for (next_size = range->min; next_size <= range->max; + next_size += range->increment) + if (size == next_size) + return 0; + + return -1; +} int rte_cryptodev_sym_capability_check_cipher( const struct rte_cryptodev_symmetric_capability *capability, uint16_t key_size, uint16_t iv_size) { - if (param_range_check(key_size, capability->cipher.key_size)) + if (param_range_check(key_size, &capability->cipher.key_size) != 0) return -1; - if (param_range_check(iv_size, capability->cipher.iv_size)) + if (param_range_check(iv_size, &capability->cipher.iv_size) != 0) return -1; return 0; @@ -285,13 +306,13 @@ rte_cryptodev_sym_capability_check_auth( const struct rte_cryptodev_symmetric_capability *capability, uint16_t key_size, uint16_t digest_size, uint16_t iv_size) { - if (param_range_check(key_size, capability->auth.key_size)) + if (param_range_check(key_size, &capability->auth.key_size) != 0) return -1; - if (param_range_check(digest_size, capability->auth.digest_size)) + if (param_range_check(digest_size, &capability->auth.digest_size) != 0) return -1; - if (param_range_check(iv_size, capability->auth.iv_size)) + if (param_range_check(iv_size, &capability->auth.iv_size) != 0) return -1; return 0; @@ -303,16 +324,16 @@ rte_cryptodev_sym_capability_check_aead( uint16_t key_size, uint16_t digest_size, uint16_t aad_size, uint16_t iv_size) { - if (param_range_check(key_size, capability->aead.key_size)) + if (param_range_check(key_size, &capability->aead.key_size) != 0) return -1; - if (param_range_check(digest_size, capability->aead.digest_size)) + if (param_range_check(digest_size, &capability->aead.digest_size) != 0) return -1; - if (param_range_check(aad_size, capability->aead.aad_size)) + if (param_range_check(aad_size, &capability->aead.aad_size) != 0) return -1; - if (param_range_check(iv_size, capability->aead.iv_size)) + if (param_range_check(iv_size, &capability->aead.iv_size) != 0) return -1; return 0; -- 2.14.2