Received: by 10.213.65.68 with SMTP id h4csp264859imn; Fri, 23 Mar 2018 04:15:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELuXWWGYSc/apD0MBfZX3leC5i1qT3NAfbQtd5iNOVNN5S1pJMFaZbrJsj2DbJE8/AeWit3c X-Received: by 10.98.51.129 with SMTP id z123mr23815725pfz.132.1521803749400; Fri, 23 Mar 2018 04:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521803749; cv=none; d=google.com; s=arc-20160816; b=pd9cl7X2Rz8Qk231haXQuyqYamebIt1tpX5K/lMyYMKzinEcS8keo2MlQGm3eitX6Z 85pzxr6rdvEm8Lwf0ro4G21LkrQ5qVKzEUfzePjkFWe8DEZXmTz83FeoWPFrUDEJWjxZ tUP9qfFJxIt3JeSmNkKIQ6Z+dL7datLfFac0DTN1V7jTfXwzgwitGaoDwb6Untvm1ltt bGGSZolC16y/agf+i85OoWYWtsAD2XDEzqvLpjL+IZ6D5g5+E+q7KaxjSUwMkJ2a/+Cm 1PtcVRcjpz4ZrbSIHy1BxuVEnnXAi7IXWelU4dvt9WfCQAaXYFd44q/it1WABFgXXdS7 g73Q== 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=bvARXT9eVvGLpU4ZoJFTm/Q9lTyh7+HqbILIwUV3DvQ=; b=Pb/A3YLDYl73selupDlAafCDONf/UJd3bBUROUZglwY0iF6s+GZ47gkKr4SyShMYah Z4sitbmydlj+DzphlIHL6Da6FJuJnAjXjxqxznRr1ySr7AKDu4TS6my7ptQGePn8whS9 D5z0hyIi9wE/Bq3yUpGdCMysN9L7q/FcPVKb1BrP20luFXNFDYHhdyL/BwBAZNA3pRZ+ EEcxaIvECTNHrGZzRh2J0bTZGHkZVucY61S+CGdZzKMGpDOBjOZVhn6qHBuYdyQiXEe+ za/HN+t7ifdOSCaqe5E+ah3d5KC40zmofTuxrJ4hi9ub35kbNx+uD8tmReQ8ZpnlmoQm N4ug== 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 65-v6si8357434plb.573.2018.03.23.04.15.34; Fri, 23 Mar 2018 04:15:49 -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 S1751768AbeCWLOo (ORCPT + 99 others); Fri, 23 Mar 2018 07:14:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42432 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932645AbeCWKKN (ORCPT ); Fri, 23 Mar 2018 06:10:13 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 13599FC9; Fri, 23 Mar 2018 10:10:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Mera , Kalle Valo , Sasha Levin Subject: [PATCH 4.9 131/177] ath10k: fix out of bounds access to local buffer Date: Fri, 23 Mar 2018 10:54:19 +0100 Message-Id: <20180323094211.007752670@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Mera [ Upstream commit a16703aaeaedec7a8bee5be5522c7c3e75478951 ] During write to debugfs file simulate_fw_crash, fixed-size local buffer 'buf' is accessed and modified at index 'count-1', where 'count' is the size of the write (so potentially out of bounds). This patch fixes this problem. Signed-off-by: Michael Mera Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/ath10k/debug.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -624,17 +624,21 @@ static ssize_t ath10k_write_simulate_fw_ size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; + char buf[32] = {0}; + ssize_t rc; int ret; - simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); + /* filter partial writes and invalid commands */ + if (*ppos != 0 || count >= sizeof(buf) || count == 0) + return -EINVAL; - /* make sure that buf is null terminated */ - buf[sizeof(buf) - 1] = 0; + rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); + if (rc < 0) + return rc; /* drop the possible '\n' from the end */ - if (buf[count - 1] == '\n') - buf[count - 1] = 0; + if (buf[*ppos - 1] == '\n') + buf[*ppos - 1] = '\0'; mutex_lock(&ar->conf_mutex);