Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3009532ybi; Mon, 17 Jun 2019 14:36:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXRxopyR65niUglb4WmCo652c+lLuFovKcSc8sCZ3qZzf/3GgnSc2dIlXczkPNMBMAb+PB X-Received: by 2002:a62:e910:: with SMTP id j16mr14078605pfh.123.1560807359909; Mon, 17 Jun 2019 14:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807359; cv=none; d=google.com; s=arc-20160816; b=mpfzs6sZtV4W4qG3+8MxmAV5yvXnVr9MRNoAuMnupkdtSL8iosMSOEmJH5M/8gUK6x uUXYfcu371czVshkFjwOQvHpRs87bfNaHNQyLGrfReKFeYYykMqRaMPuHQPZ7zAYB4dN LzMzBzemtm7r/JBATQkJxNGv6mh6KFqPUwb3GmXdXq0l+TAX1cZAOmEw103C8z6jli3h JwcsKvKAL6+G8YQvcv1uREM9EDxLjHxaAsCntYAR4moXb9JlVQ0expAtA5xvYX8lVLBr CSx5pbyjO+Q3S8h3RGVCRX9L4Nw+QtOOPjigwqgiK/rTVv+u9I7vKpkMVCHgPg8rlDM4 GI2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JPrn95tsz6CFXHVJsKLi4dPJl6e6jzCCi0W52QI/TaU=; b=0SmO1Sed3W3F9I+j5/n3FiCw6BHMSg8FHmI/dAMHOBANIJPWxEnvoLePq4H65TXcsy 3jvG32mzk1Bx2Ga9rZ3bxKJA/Pwv+xgI/ucCX08BlhD5wfsPuFhUjrjtG3R5l1zFoSpw 0Iemd7jNgG687rkFvtqI8xvIhlkmaq3MMffLhE7WCocHhk46Wy9GHrMKyiQzbP2fkciG aT7WR/jUzTMoz7CMYpIhUWWYSmedIt/CNdBvti05AZoyr9kWsGNZRTNiNuq+KYYNSs6E zrSaiJPQAl8BOzhJnAW55TXHB4ypk4m2TwyHnnNoxvlAnDYYV2Uu/AWYyLUIDi/2PS0K AULQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RGNqAsoz; 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 j14si11260225pfi.276.2019.06.17.14.35.44; Mon, 17 Jun 2019 14:35:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=RGNqAsoz; 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 S1729256AbfFQVfk (ORCPT + 99 others); Mon, 17 Jun 2019 17:35:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:47236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729556AbfFQVWc (ORCPT ); Mon, 17 Jun 2019 17:22:32 -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 C125320673; Mon, 17 Jun 2019 21:22:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806551; bh=W0AM3mZ2w2n/ClyM2senMPvoTAFPrTIAe6at9yE9fyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGNqAsozvz4fmVFOMz//X9jC8gIssrJwVcGG7eLwhuTSR2z+Kv8jH190nYRxvzIpS NiqXeZrvnWFb00yI0fB7WLZmrNTKzvElr78sfXyeOXEUSK0iPCfg0MBhBCIvGCX/nu 2My5ulyq1djq0WCPsY1Rbk03SIiGBxz2jw7uyaMc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Young Xiao , Sasha Levin Subject: [PATCH 5.1 046/115] Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var Date: Mon, 17 Jun 2019 23:09:06 +0200 Message-Id: <20190617210802.647826725@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 de20bdaa148d..8b01257783dd 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -1135,7 +1135,7 @@ static void kgdbts_put_char(u8 chr) static int param_set_kgdbts_var(const char *kmessage, const 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"); @@ -1155,7 +1155,7 @@ static int param_set_kgdbts_var(const char *kmessage, 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