Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5996236ybc; Wed, 27 Nov 2019 13:06:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwdzC33x0QzlTmgM+6oDer+yzg6fIf6Z+2JqX46tRLue5yE2Ca3ItCJQR6S3BK8g1zq3POS X-Received: by 2002:a17:906:ecad:: with SMTP id qh13mr52461901ejb.25.1574888806135; Wed, 27 Nov 2019 13:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888806; cv=none; d=google.com; s=arc-20160816; b=EPDYqii+kqNPJ4Ak7fNe0tSaZTo8RWOlJ7DknHqL5Yc9qiagUmAPWLAPtC9hwNFOXn AY0rz1sq1MWsFo9r+fkziflRyWkzgRf7rHvnlAx57/s7IyOHOFh253Vu1Hy7r/wq0S69 sN+7rV3e04WxYbavxPOnD1D4aSs2h3djY0xmb29Lu98/yeR1YFEMqP6KZlb+FA6pTssW to8y4eFFgHnLBiOLTjPZNNIyLxciNMpBh5TbwS2qbOXr8WyevmdZStbUQLHPscXoJjYx elBl2HTcRpAsWigHcNUcNYeLmhZHppTzC9VM1x/vtdPUeMeHycXx1zZ5/clgKXAHYrDv WVSw== 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=Y7rGz2d0T9BoKQ8CJyxRn6bSbB92WUKgSQds44uYQ9U=; b=P8CyNcP3Fa/go49h2rlxJmVPY3o+02iUUCfb4ATT2ZrH7GNsbenvQ/KsnWKOWBPO40 ETCqGmytKqi6ihUJ4RErcney64mkZIPbMc0hVNd3jtnJ8YnAzVur8kyK2RTa59xk+r3Y 3rd6qIEhiPG8id7rptDGUFvaZyej3j7WlOr3P83CadHYTbs+F9z3LZ7NfISRrD7iCAJ4 54EF0oLiNgkbmeZI3tPmKTTkk7TsEYrFQ7RpTmHxVO9AE0t3ZUA3Ed0/YeEt49WAvpbf TglBBXU3d1FLcMsRfCQulsMfpyW1FPoPqZ8NG6DBeI82tlg/bplpUqzG+JJ9pIwNMuHy BCRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pDR8bYGL; 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 f10si10423933ejq.289.2019.11.27.13.06.22; Wed, 27 Nov 2019 13:06:46 -0800 (PST) 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=pDR8bYGL; 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 S1732108AbfK0VEG (ORCPT + 99 others); Wed, 27 Nov 2019 16:04:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:57406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731779AbfK0VEC (ORCPT ); Wed, 27 Nov 2019 16:04:02 -0500 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 AE4AF215E5; Wed, 27 Nov 2019 21:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888642; bh=dbwZ9WoF8rg/RelWJxEXUDmfrzz1lEIsxZkZhBEk6vI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pDR8bYGL+yWtvz+0VxB1vYN7kxRmR9ZgBVUdVNPdPyOj98aaZiIYzSrb0BEvWbF0r jwbxkhKPpa1/aNgbz5AmyW5eRB80RZbk0WXq/3uIYtdxDcSzWjVCUTL8+nvGsBpfHB 2tYYxoFy3IaNsnUMSNZo00z87xlV8pNP+ef8bs10= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ahmad Masri , Maya Erez , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 213/306] wil6210: fix debugfs memory access alignment Date: Wed, 27 Nov 2019 21:31:03 +0100 Message-Id: <20191127203130.670982441@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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 From: Ahmad Masri [ Upstream commit 84ec040d0fb25197584d28a0dedc355503cd19b9 ] All wil6210 device memory access should be 4 bytes aligned. In io blob wil6210 did not force alignment for read function, this caused alignment fault on some platforms. Fixing that by accessing all 4 lower bytes and return to host the requested data. Signed-off-by: Ahmad Masri Signed-off-by: Maya Erez Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/wil6210/debugfs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c index ceace95b1595c..44296c0159252 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -662,10 +662,10 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf, enum { max_count = 4096 }; struct wil_blob_wrapper *wil_blob = file->private_data; struct wil6210_priv *wil = wil_blob->wil; - loff_t pos = *ppos; + loff_t aligned_pos, pos = *ppos; size_t available = wil_blob->blob.size; void *buf; - size_t ret; + size_t unaligned_bytes, aligned_count, ret; int rc; if (test_bit(wil_status_suspending, wil_blob->wil->status) || @@ -683,7 +683,12 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf, if (count > max_count) count = max_count; - buf = kmalloc(count, GFP_KERNEL); + /* set pos to 4 bytes aligned */ + unaligned_bytes = pos % 4; + aligned_pos = pos - unaligned_bytes; + aligned_count = count + unaligned_bytes; + + buf = kmalloc(aligned_count, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -694,9 +699,9 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf, } wil_memcpy_fromio_32(buf, (const void __iomem *) - wil_blob->blob.data + pos, count); + wil_blob->blob.data + aligned_pos, aligned_count); - ret = copy_to_user(user_buf, buf, count); + ret = copy_to_user(user_buf, buf + unaligned_bytes, count); wil_pm_runtime_put(wil); -- 2.20.1