Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2992764yba; Mon, 22 Apr 2019 17:21:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj9hk5p2G4TWMmt75UCqT/lirNyss96oR2Oh8VjYSq2Zr1YfNAQhWNcdJ0rXuGgQqdre0d X-Received: by 2002:a65:6655:: with SMTP id z21mr21501050pgv.33.1555978917970; Mon, 22 Apr 2019 17:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555978917; cv=none; d=google.com; s=arc-20160816; b=HmP/phvPIkkP+dRlF1uki+n9nor2TXrnjMhwRa/NEsXL4Ij+974ErX4BgdcvezCBEd WSmpZsWSKB86Rq+sNHmiakEaNPwN/g9eQzjXGbyPkr8SRIsHueuCY6BWwjzW3Znv3D5Y Sdr92IZnjRLtPDVMQXPzUL7gEnj3TzCyjAvmdoJuw4SDEjwx75BVtbMwu3hd0sfQ8DBE O0A919+T3VeU94kGzDO4BTqSG8oyr8oMC1KBHWSUJVB8yQIaVvhsj4X3ptIQKe9A4UUi CyjSsBY8dLgIKdAYF3RbapyQ2N4kRSbhCgJFiEl6GAtBsJS6NP5HK3DYl9P/W1Dxs6Ev nyCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rMO7SlSyVNyND2gDx5PUQQILT0x4pJI8ng4+M08k0CY=; b=EG/SAPP9vdKx7mw9QXlvlOcnamvL0bweUXaxIthTCl3hNAXSaO3JfulVG1ZCFIqVQ1 b4Pofy6ewS3E3uhtUqDRoPBH3XZfYjCOMK1nbW1uPThhY/f/rluEyVHYf2CE94oYIhGY 3hpJul0iSZo3z5BcNW8eJMExrXx1lr0UqxHsVHFyD//8OEclFVRa90Ip6DgPF0NfxFK3 WlNPTiCPOFo31Co5m54q3hnSfGPNrmxiqyDuHJ+NI1QklV2zSbz8SdAc0MDJeiTyUqmv K2UIhAuj5/4bBygrBVPQ4VzuqlAwtY3CAkZbLIwoH6QbhM47FWarvTCDPDHdK0EUQmps FZEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=USF8MpcX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si7530280pgt.378.2019.04.22.17.21.42; Mon, 22 Apr 2019 17:21:57 -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=USF8MpcX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732337AbfDVUGr (ORCPT + 99 others); Mon, 22 Apr 2019 16:06:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:45532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbfDVTo1 (ORCPT ); Mon, 22 Apr 2019 15:44:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 782BC204EC; Mon, 22 Apr 2019 19:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962266; bh=UiE1/qz1leytIa5uK7KJExFF85Vy3sYKYepZmd343vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=USF8MpcX3Z9ePLmHz8w9DA9VWnqIMxYWTfvhdO3Hiq0Vj986FdPa+TTMrL4geoA76 VpTizPM5dUle41OV6m8UdIp8xKUhonkqNxjhO9EksqdX5q78J/6GEWq8Ya6WJLF3Q+ jziyNUxc5a2UXhVQ/dTtEu8GphhpA22lVFRljFhE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: raymond pang , Jens Axboe , Sasha Levin , linux-ide@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 74/98] libata: fix using DMA buffers on stack Date: Mon, 22 Apr 2019 15:41:41 -0400 Message-Id: <20190422194205.10404-74-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: raymond pang [ Upstream commit dd08a8d9a66de4b54575c294a92630299f7e0fe7 ] When CONFIG_VMAP_STACK=y, __pa() returns incorrect physical address for a stack virtual address. Stack DMA buffers must be avoided. Signed-off-by: raymond pang Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin (Microsoft) --- drivers/ata/libata-zpodd.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c index b3ed8f9953a8..173e6f2dd9af 100644 --- a/drivers/ata/libata-zpodd.c +++ b/drivers/ata/libata-zpodd.c @@ -52,38 +52,52 @@ static int eject_tray(struct ata_device *dev) /* Per the spec, only slot type and drawer type ODD can be supported */ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev) { - char buf[16]; + char *buf; unsigned int ret; - struct rm_feature_desc *desc = (void *)(buf + 8); + struct rm_feature_desc *desc; struct ata_taskfile tf; static const char cdb[] = { GPCMD_GET_CONFIGURATION, 2, /* only 1 feature descriptor requested */ 0, 3, /* 3, removable medium feature */ 0, 0, 0,/* reserved */ - 0, sizeof(buf), + 0, 16, 0, 0, 0, }; + buf = kzalloc(16, GFP_KERNEL); + if (!buf) + return ODD_MECH_TYPE_UNSUPPORTED; + desc = (void *)(buf + 8); + ata_tf_init(dev, &tf); tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf.command = ATA_CMD_PACKET; tf.protocol = ATAPI_PROT_PIO; - tf.lbam = sizeof(buf); + tf.lbam = 16; ret = ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, - buf, sizeof(buf), 0); - if (ret) + buf, 16, 0); + if (ret) { + kfree(buf); return ODD_MECH_TYPE_UNSUPPORTED; + } - if (be16_to_cpu(desc->feature_code) != 3) + if (be16_to_cpu(desc->feature_code) != 3) { + kfree(buf); return ODD_MECH_TYPE_UNSUPPORTED; + } - if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1) + if (desc->mech_type == 0 && desc->load == 0 && desc->eject == 1) { + kfree(buf); return ODD_MECH_TYPE_SLOT; - else if (desc->mech_type == 1 && desc->load == 0 && desc->eject == 1) + } else if (desc->mech_type == 1 && desc->load == 0 && + desc->eject == 1) { + kfree(buf); return ODD_MECH_TYPE_DRAWER; - else + } else { + kfree(buf); return ODD_MECH_TYPE_UNSUPPORTED; + } } /* Test if ODD is zero power ready by sense code */ -- 2.19.1