From patchwork Sat Mar 26 20:27:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 64504 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp757296lbc; Sat, 26 Mar 2016 13:28:01 -0700 (PDT) X-Received: by 10.140.233.135 with SMTP id e129mr11730455qhc.86.1459024081567; Sat, 26 Mar 2016 13:28:01 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u4si15502252qka.50.2016.03.26.13.28.01; Sat, 26 Mar 2016 13:28:01 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id F097B6186C; Sat, 26 Mar 2016 20:28:00 +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, 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 CADAD6164A; Sat, 26 Mar 2016 20:27:56 +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 0C0AB61683; Sat, 26 Mar 2016 20:27:54 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by lists.linaro.org (Postfix) with ESMTPS id 4D3C26161B for ; Sat, 26 Mar 2016 20:27:53 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id r187so131200309oih.3 for ; Sat, 26 Mar 2016 13:27:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aV36FD9vtZ7Yn2B+YebnDAz5IvUMZjnL7HWh0PFTHFA=; b=SrP3+O3LRISER9pYZH034V6tmCsq3Ze2c3eLmVdOs33uSo6yXH85LaMGY/bl4bat+T ftDd6upZfnWy54cYTe0i/G6sL0PHnYLRZX8F0VpJBI9S8dn7WtI+TvzVyDX2x7h6tk47 VQuYQF6ZjYphOESK4gsh7Pz/DVhgAhQ+hQehf2dwu70OYZwDertx9RVz8WU2Ji2c73sB NzprDpLQd+MYXfZMZ4gfRoKYqkNPNk5izcffcieCM7E3lSBkzZFF5Ahrgmi5Hc9Tia61 jsLuWWXb4YlRmyX8NLs1nZrea61unOeKS/BuxphiVgaGCoxUHiF4jsjhAr6X3P9D3b7v oahg== X-Gm-Message-State: AD7BkJLoEojV04JiQOBnWJjzxFxrm8MS8rWYvtSj/qpWJZyyf9Pzffwq4alYxMpHu3Y6DtXm/O0= X-Received: by 10.157.39.110 with SMTP id r101mr3295560ota.49.1459024072814; Sat, 26 Mar 2016 13:27:52 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id i43sm5630191otd.41.2016.03.26.13.27.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Mar 2016 13:27:52 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 26 Mar 2016 15:27:49 -0500 Message-Id: <1459024069-14700-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: tm: reduce byte range to prevent array overflow 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2120 by reducing the random array guard by one to ensure that at least two bytes of random data remain before accessing them. Signed-off-by: Bill Fischofer Reviewed-by: Balasubramanian Manoharan --- platform/linux-generic/odp_traffic_mngr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 99dc020..08e83c1 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -154,7 +154,7 @@ static uint16_t tm_random16(tm_random_data_t *tm_random_data) uint32_t buf_idx; uint16_t rand8a, rand8b; - if (256 <= tm_random_data->next_random_byte) + if (255 <= tm_random_data->next_random_byte) tm_init_random_data(tm_random_data); /* Collect 2 random bytes and return them. Endianness does NOT matter