Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4805293ooa; Tue, 14 Aug 2018 10:47:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwOkrWp7RqMYvLtm0NSa9n/kIon8SCr2Wcr89skoEwTavz99HSQCfd/RfR9zCqbn+qPo2VL X-Received: by 2002:a63:6d0a:: with SMTP id i10-v6mr22323884pgc.215.1534268862117; Tue, 14 Aug 2018 10:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268862; cv=none; d=google.com; s=arc-20160816; b=Z8StLIHvJXNuPU/H2FW/BS76q3s/7G/wErS/VTaHXaArRrI+f6fLqzE9WSIo1RYpL2 5JQr8dHXM6Jeyt5flHjrLxcxL3GhObqqZ/p94XTz5QOCnp8IgD73T0H8SpTPdCQf/Ajh bZOQ8dhZMRGH+h57v/5uDJo3bqT5LJoLNHLIytgSKYD4rxFiaPVN5bFCcOeCyy+66uhW SkHmXLl9bcOXhoSB1V5deE2D6G2g7NhZ9zDX/Bv2w1KHhaF49W6R9t2w2uRSmNhNaFos zwTeDz5KiEwC15qCguhum7p5+E1De4DBRuilDq0JYPIns4pVONi1fziapd1SCp+QL4zk A5TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Jo0Hd7O6NjbAuX9J8ftmnsxv9+6acL6aZB5HURn9FX8=; b=SNp+lYaH3ODNoi930NtRwpxvK+QBn3ZK5xY5IER13eYMo06OyJq4Laobv7tTLqfil/ lL3Polh3fV0tv6THq3gCG6qDcPIzyH0fv4uZPqra7ZokMJkLjh+ln6Ll18QeJFRHpuY2 NRAr2jzZLmmDtU/RlLyE55w92d96BGmfXwSAp04eL1xWN1N4Ye/VIYUKJoG2Mjh6Abzm 2pNGOTipVFSf2q9OF2QF4yf3T9qvnFlDupu5dkbVsunh1dYfNtlOrQTQxS3rB+qYXWsh AqR3iyR71EDdH04tz0FZMr7YiTn5zut3yVrx2diVkcUW7yla3Op9E4UdpRpGR8Y0uoEC iQfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v38-v6si20740647pgn.431.2018.08.14.10.47.27; Tue, 14 Aug 2018 10:47:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391033AbeHNUe1 (ORCPT + 99 others); Tue, 14 Aug 2018 16:34:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60360 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390473AbeHNUe0 (ORCPT ); Tue, 14 Aug 2018 16:34:26 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3524CCAE; Tue, 14 Aug 2018 17:46:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Mera , Leon Romanovsky , Doug Ledford , Amit Pundir Subject: [PATCH 4.4 15/43] IB/ocrdma: fix out of bounds access to local buffer Date: Tue, 14 Aug 2018 19:17:51 +0200 Message-Id: <20180814171518.106262417@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171517.014285600@linuxfoundation.org> References: <20180814171517.014285600@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Mera commit 062d0f22a30c39840ea49b72cfcfc1aa4cc538fa upstream. In write to debugfs file 'resource_stats' the local buffer 'tmp_str' is written at index 'count-1' where 'count' is the size of the write, so potentially 0. This patch filters odd values for the write size/position to avoid this type of problem. Signed-off-by: Michael Mera Reviewed-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c @@ -643,7 +643,7 @@ static ssize_t ocrdma_dbgfs_ops_write(st struct ocrdma_stats *pstats = filp->private_data; struct ocrdma_dev *dev = pstats->dev; - if (count > 32) + if (*ppos != 0 || count == 0 || count > sizeof(tmp_str)) goto err; if (copy_from_user(tmp_str, buffer, count))