Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3850719ybz; Mon, 4 May 2020 10:52:27 -0700 (PDT) X-Google-Smtp-Source: APiQypJ1R5N/c/IQyHCn4e3wcdklvQlc8SZ3bcuLQrkJxFJvgNuSKgzpAVJl6tf5dJ/rJ+pouo8Y X-Received: by 2002:aa7:d0d6:: with SMTP id u22mr16191209edo.262.1588614747401; Mon, 04 May 2020 10:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588614747; cv=none; d=google.com; s=arc-20160816; b=r0T9foafujGO8SQT4T0S0VkxX7cMBW7YMn7p1nVk/2pQoirt6cMD862gcWopPvVFTP Qe3bUJ9Pf4wegZTkQ8mw+A1zj3dXprOhlXSf/HKat7aSe78+XMsB9QxKZfCqcSywilc7 ED7lUt0zMeD/FwizvQSDt29WE5vefB6DW7IBfQD+xiXoqF4gZ7qbTLWOTzjw1okaBVkR nY6HPFCjCZ/+s7uJ0LYr1/cHZGYBlHxgdbE8EF1EoRIkj4y8bbQgw8DwAfMkVvPNAEip KWGyQUTECZV16ydvGJAR6YO8a4o3o+V0DR8eiWEUMzu0MXcr493DgqfrhjCNHKrvo6n2 14cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9O9pOv93g7JmOc2UpRRs5DUt0jFUPNWmQLQ3nDY1Vjc=; b=QBfUn4x7BAJBYUJ3WZs+kXUDW+pX52qfJ7LwHaV/baCN+tn1rbE8G8O3aV48vZdgHe GRM50iI4i9+SDOxXS6o/AWzpcOyuyApA2Pfmr21EWfzSSciVXI17fnPc+wD59N54v016 axdfFUc8MzCbmM05k1bml/ZBQQVg3WOOT13G/PvDYppj5+/69g0296eWaR/tgsRCreUR plTzHS5SyLbHW4sZ3kNCbKnXYyxLxdzD29iB1QBXTwrka/Wds2fpLQBmeIHue29elok8 IdGuzTcFmv3f9nWmomGavr1Jnu7eUlWQi6WoXMXf20TarC9oJnblHL4Zt1Vu5lpY/Rli 9v3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=S5BasPFc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 35si6957383edm.560.2020.05.04.10.52.02; Mon, 04 May 2020 10:52:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=S5BasPFc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730445AbgEDRtj (ORCPT + 99 others); Mon, 4 May 2020 13:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729839AbgEDRti (ORCPT ); Mon, 4 May 2020 13:49:38 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97FF7C061A0E for ; Mon, 4 May 2020 10:49:38 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id b1so261323qtt.1 for ; Mon, 04 May 2020 10:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9O9pOv93g7JmOc2UpRRs5DUt0jFUPNWmQLQ3nDY1Vjc=; b=S5BasPFcYpNCX02Po60a7tIfWWh50cRfls4aZ8I6Zi7e2YDq8cgTPHA7QqOUNMY7n8 8OB8NvLBMMSfoaiCEyDGke/7MZcdrOr/FwiL9Fv4Xyx+BH8Emf7of8pg/T0NyJkl8Esg Nx6bGhzRLerxuGWbM19JNvOvLwa0DA0+QgXzBchAPDrcMbv4aafsq0jXAZA4z26HP+o7 iEwhatzAhhZyFg++5gRLUCOxYTL6637TbGHDZdxx48WPSlNWUsNhWUF+awyaEchH8Xgb uWuSeD/GlNCUfHODM0pVP00OJBNe2wq9YXVqbEE82j9u6y8zinuHXtPqpQD4jrg0pP7+ Cz8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9O9pOv93g7JmOc2UpRRs5DUt0jFUPNWmQLQ3nDY1Vjc=; b=R1dZQSxLPLmdPqHZg3bHfYlYTEg7836l/2ui64xzHf24Em5DZpU8l88EeDOYtJAxnc iIgrLR6+R3pSk8D55N0MYnSod35BVoHjGaHgDvhX1rrNWAwS0XidmMlSinr5L2oREZmo ClA1oIA0nK6gw8vdw/yRUjqy5bQq/kFG6mqP6OZZQw8mUxxHmwvcJ6lzKaDHR31BpT+u s29nCwnsn8M212jZgMiKfo/JkAb5A/c55uXOv8cifwA5AYg6AiKPYSz/24L4bjNkrknd zD8bcs48tZhmZQF38i/MzAh+NKkx7CtMdxjZCurz0+fwlS6Kd+TALkJPLv9NF3m7lWO0 oCVg== X-Gm-Message-State: AGi0PubbYsTT5r7FcyP6kUP0JWHs76yfYnjpi2TkmgvCHdnh5CDrA2tG dcU+xBRIRBRwEIAdFZGsb0GWkQ== X-Received: by 2002:ac8:6f0d:: with SMTP id g13mr268950qtv.328.1588614577576; Mon, 04 May 2020 10:49:37 -0700 (PDT) Received: from google.com ([2620:0:1003:510:c948:3327:92b6:e959]) by smtp.gmail.com with ESMTPSA id k43sm12239311qtk.67.2020.05.04.10.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 10:49:36 -0700 (PDT) Date: Mon, 4 May 2020 13:49:33 -0400 From: Richard Yeh To: Oscar Carter Cc: Rob Springer , Todd Poynor , Ben Chan , Greg Kroah-Hartman , Simon Que , John Joseph , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: gasket: Check the return value of gasket_get_bar_index() Message-ID: <20200504174933.GA83381@google.com> References: <20200501155118.13380-1-oscar.carter@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200501155118.13380-1-oscar.carter@gmx.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 01, 2020 at 05:51:18PM +0200, Oscar Carter wrote: > Check the return value of gasket_get_bar_index function as it can return > a negative one (-EINVAL). If this happens, a negative index is used in > the "gasket_dev->bar_data" array. > > Addresses-Coverity-ID: 1438542 ("Negative array index read") > Fixes: 9a69f5087ccc2 ("drivers/staging: Gasket driver framework + Apex driver") > Signed-off-by: Oscar Carter > --- > drivers/staging/gasket/gasket_core.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c > index 8e0575fcb4c8..67325fbaf760 100644 > --- a/drivers/staging/gasket/gasket_core.c > +++ b/drivers/staging/gasket/gasket_core.c > @@ -925,6 +925,10 @@ do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma, > gasket_get_bar_index(gasket_dev, > (vma->vm_pgoff << PAGE_SHIFT) + > driver_desc->legacy_mmap_address_offset); > + > + if (bar_index < 0) > + return DO_MAP_REGION_INVALID; > + > phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset; > while (mapped_bytes < map_length) { > /* > -- > 2.20.1 > Reviewed-by: Richard Yeh