From patchwork Mon Sep 21 16:27:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 309346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BA37C43465 for ; Mon, 21 Sep 2020 16:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D83B2223E for ; Mon, 21 Sep 2020 16:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600707466; bh=3wRgz9njpE+lwA5Lwdpi4A+ePptV7i/tL3UDcDxYKGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0UfDPLSc5CUfvWA/6t/giAJZ9OQpui8UzuTau2uZh+xm3CNkmigHOi5RREamLTsAs nvEPYW/3ROIXr+16pyuDqhy/aar4BVTvxYXVDOhVKPRGuqG5aHN2nLJizxLyLFt8ZW iIQA0WSV/43xH/oGlT5qF9lQtccYWSr8LuODepm8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729555AbgIUQnM (ORCPT ); Mon, 21 Sep 2020 12:43:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:47470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728652AbgIUQnF (ORCPT ); Mon, 21 Sep 2020 12:43:05 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 309F7238E6; Mon, 21 Sep 2020 16:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706584; bh=3wRgz9njpE+lwA5Lwdpi4A+ePptV7i/tL3UDcDxYKGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgTl+Ho+KQpiNef1gKTzZi6LoHOegNRCuXpK2ATYSpJ6kwc8yG1SuNcGCzDlDguYF JUQ+4yKpH2aUQ1hLmR/3WH++GxZoDCkmkoAFwZxGaJJ5KPgU1dJsQtNOhtssA46LVA m5ltnlwYKNw44P7WW9KKSZ52OHU659xhhyf9Iz/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moti Haimovski , Oded Gabbay , Sasha Levin Subject: [PATCH 5.8 012/118] habanalabs: prevent user buff overflow Date: Mon, 21 Sep 2020 18:27:04 +0200 Message-Id: <20200921162036.900249682@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Moti Haimovski [ Upstream commit 6396feabf7a4104a4ddfecc00b8aac535c631a66 ] This commit fixes a potential debugfs issue that may occur when reading the clock gating mask into the user buffer since the user buffer size was not taken into consideration. Signed-off-by: Moti Haimovski Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/habanalabs/debugfs.c b/drivers/misc/habanalabs/debugfs.c index 6c2b9cf45e831..650922061bdc7 100644 --- a/drivers/misc/habanalabs/debugfs.c +++ b/drivers/misc/habanalabs/debugfs.c @@ -982,7 +982,7 @@ static ssize_t hl_clk_gate_read(struct file *f, char __user *buf, return 0; sprintf(tmp_buf, "0x%llx\n", hdev->clock_gating_mask); - rc = simple_read_from_buffer(buf, strlen(tmp_buf) + 1, ppos, tmp_buf, + rc = simple_read_from_buffer(buf, count, ppos, tmp_buf, strlen(tmp_buf) + 1); return rc;