From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.8 required=3.0 tests=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 05818C31E5B for ; Mon, 17 Jun 2019 21:30:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFAE72063F for ; Mon, 17 Jun 2019 21:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560807035; bh=oHZ+D+qqoj/Fy19Nk7YNcsjpllGzO0Ch48+MNTt6MOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KklZFr8QBtQS31qZwoAkkpEW8b6THstcoXlSCuX2UU3w2/gLS/MZ9TSvk8sAbBPgi YvpKhh5U+rCJI8GiJa2HN+rr7vLb52r9j4YlaneLeKrsHjbNz3xub6pryqDjzn/2eU PieISEwBpV+prgxo1pz6nJWG3CW7er7BtRDV5whw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729764AbfFQVaH (ORCPT ); Mon, 17 Jun 2019 17:30:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:57322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730324AbfFQVaE (ORCPT ); Mon, 17 Jun 2019 17:30:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 3F7FC204FD; Mon, 17 Jun 2019 21:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560807003; bh=oHZ+D+qqoj/Fy19Nk7YNcsjpllGzO0Ch48+MNTt6MOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CdhaBVkMoPz7p0Ki7Fc3VZSpTKh0YRMlDLp9vv2cQlxptDi0KA9m8aYYQmIvI/YQb ElW+AOwDkKc6eYzSzwEumk1lU+SMvscApbQJBkk1rYEJZZzN4GmxUIoDUeBDzun2gH 5dyfY2rA40WTXbjFpk0qfQlk4RkzzXFkvAqiTkko= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Young Xiao , Sasha Levin Subject: [PATCH 4.14 27/53] Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var Date: Mon, 17 Jun 2019 23:10:10 +0200 Message-Id: <20190617210750.416667064@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210745.104187490@linuxfoundation.org> References: <20190617210745.104187490@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit b281218ad4311a0342a40cb02fb17a363df08b48 ] There is an out-of-bounds access to "config[len - 1]" array when the variable "len" is zero. See commit dada6a43b040 ("kgdboc: fix KASAN global-out-of-bounds bug in param_set_kgdboc_var()") for details. Signed-off-by: Young Xiao Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/kgdbts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index fc7efedbc4be..94cbc5c98cae 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -1134,7 +1134,7 @@ static void kgdbts_put_char(u8 chr) static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp) { - int len = strlen(kmessage); + size_t len = strlen(kmessage); if (len >= MAX_CONFIG_LEN) { printk(KERN_ERR "kgdbts: config string too long\n"); @@ -1154,7 +1154,7 @@ static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp) strcpy(config, kmessage); /* Chop out \n char as a result of echo */ - if (config[len - 1] == '\n') + if (len && config[len - 1] == '\n') config[len - 1] = '\0'; /* Go and configure with the new params. */ -- 2.20.1