From patchwork Thu Jan 28 15:44:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Saxena X-Patchwork-Id: 8151801 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C04DBEEE5 for ; Thu, 28 Jan 2016 15:45:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E63020155 for ; Thu, 28 Jan 2016 15:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7583F201B9 for ; Thu, 28 Jan 2016 15:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934869AbcA1PpE (ORCPT ); Thu, 28 Jan 2016 10:45:04 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35881 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755614AbcA1PpA (ORCPT ); Thu, 28 Jan 2016 10:45:00 -0500 Received: by mail-pf0-f169.google.com with SMTP id n128so25214057pfn.3 for ; Thu, 28 Jan 2016 07:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=avagotech.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uNthwqiMNAr9WOLsLwYNMjcYfdms5GoUS0PuvJjvgHE=; b=pQaN5h8GP19kwcIDuk7FktM8mANCOZtyTW7QSunBjUalpucDzJCuwaAPIAxBke1toq YjOoKDiCGrqMf/2Zg55l9svyytvCAF/BxtuX3iwWDkPwqyDbLq9DWMx6dStbZedXGwvk EgICY5Nwk5GGSqqGZuF27EY37vDkQwe+Wp5Do= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uNthwqiMNAr9WOLsLwYNMjcYfdms5GoUS0PuvJjvgHE=; b=jjvYUxq9vmN443M3HmYxzUkXD9Gigh+bsBO1vr9eHp5DDYtYl7So/sOMYGgjaUUA6/ A5wXpj4dGTD0zUI+PshMX4VdOCmbsbTQPI9Xje7Z6vIO9IY8sj4lIdgwNOka90vrct7T pnA8rh1cNK4KIkuEX9Vpz/9IPnRHYwhEK4JbxoVSuIEBgo+w4E5n6+Sh7lEuGovJZlQM wlrpLgVT/c8Pcg660TX8d4UEz06qQaGFWUstn3VeDJv+sH/o+NkAkTvh66jq/Q08KJ1w aHOg0NjERQHQatAquvQrSrIWA8gxeYzLRMvdtNDwD8w2DfxWrVg8U1jULtoLxT65wPqT C8Ew== X-Gm-Message-State: AG10YOQZEmVEZOzT6qJFOZ3QtbrF/qWf9XFzm/X0FcXQQ8QXb3Qf3+vhxSgPoJjTRp4u2ZY4 X-Received: by 10.98.8.218 with SMTP id 87mr5601777pfi.39.1453995899955; Thu, 28 Jan 2016 07:44:59 -0800 (PST) Received: from host1.dhcp.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id l21sm14026358pfi.63.2016.01.28.07.44.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 07:44:58 -0800 (PST) From: Sumit Saxena To: jbottomley@parallels.com, hch@infradead.org, martin.petersen@oracle.com, thenzl@redhat.com Cc: linux-scsi@vger.kernel.org, kashyap.desai@avagotech.com, sumit.saxena@avagotech.com Subject: [PATCH 2/2] megaraid_sas: Fix SMAP issue Date: Thu, 28 Jan 2016 21:14:26 +0530 Message-Id: <1453995866-25097-3-git-send-email-sumit.saxena@avagotech.com> X-Mailer: git-send-email 2.0.2 In-Reply-To: <1453995866-25097-1-git-send-email-sumit.saxena@avagotech.com> References: <1453995866-25097-1-git-send-email-sumit.saxena@avagotech.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Inside compat IOCTL hook of driver, driver was using wrong address of ioc->frame.raw which leads sense_ioc_ptr to be calculated wrongly and failing IOCTL. Signed-off-by: Sumit Saxena Reviewed-by: Tomas Henzl --- drivers/scsi/megaraid/megaraid_sas_base.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 52f3419..cc92c81 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -6843,9 +6843,9 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) int i; int error = 0; compat_uptr_t ptr; - unsigned long local_raw_ptr; u32 local_sense_off; u32 local_sense_len; + u32 user_sense_off; if (clear_user(ioc, sizeof(*ioc))) return -EFAULT; @@ -6863,17 +6863,16 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) * sense_len is not null, so prepare the 64bit value under * the same condition. */ - if (get_user(local_raw_ptr, ioc->frame.raw) || - get_user(local_sense_off, &ioc->sense_off) || - get_user(local_sense_len, &ioc->sense_len)) + if (get_user(local_sense_off, &ioc->sense_off) || + get_user(local_sense_len, &ioc->sense_len) || + get_user(user_sense_off, &cioc->sense_off)) return -EFAULT; - if (local_sense_len) { void __user **sense_ioc_ptr = - (void __user **)((u8*)local_raw_ptr + local_sense_off); + (void __user **)((u8 *)((unsigned long)&ioc->frame.raw) + local_sense_off); compat_uptr_t *sense_cioc_ptr = - (compat_uptr_t *)(cioc->frame.raw + cioc->sense_off); + (compat_uptr_t *)(((unsigned long)&cioc->frame.raw) + user_sense_off); if (get_user(ptr, sense_cioc_ptr) || put_user(compat_ptr(ptr), sense_ioc_ptr)) return -EFAULT;