Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4602299ybh; Tue, 6 Aug 2019 14:40:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYw/S3a3KWZt6348ktC6kN+sI2oTSDOfT750laf3MpuYzzVPJkCJprnl34ewc+MJ6a8NVH X-Received: by 2002:a62:2f04:: with SMTP id v4mr5725008pfv.14.1565127624150; Tue, 06 Aug 2019 14:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565127624; cv=none; d=google.com; s=arc-20160816; b=f8c24oUJTDt3AAAuBtc5h4+3Yu5INqQ0z+1McfMK3w/qCZ7zsz9kumwME0j9A5L3uB VXMCbmmPFqPGC5a6ZbQSwRga5E3cfkjAT2KA54WmIDTtpxd+ASLnheg10sFNk5Sjbwdm 1VS5fcM9KQEQI+tl5YfS0RYZnsaOl7uw2JL9LnB1VYPm9ftTHZYd5g2bReP/4/81owuX J86qFT1T7X/WT1M1IItSfZn+NRff9qADRYN9xAAzbrtfotjjqPSIAs4NTRYcrOXvOyvb 6OPqFr6cxEWT5g1dh4KhIVOJvBlMDgtQSsm0G98V2z3GsRpfqHrNTefdtCdfhBK1xfvR 1Kgw== 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=2YEsVd764qY6neKAQa/LNHiIVKFRWEW+L9CDxPU8Zg4=; b=ZmIvFO1QkjnouDlMZ1oUHTeRfvvb3T7nvoX4OxbaQBO6e2rMkyxKE3KHJZ2/333XvB IrkC1nFPflfumea27ZzvGps7R/KVVAdaQ2B+qzViJivmKvyYtzGYjJ/F+ox99yqsF3wi 0HZGJMhaPU8zCG1M+m68zPuox6WGlX5FHUW2uo61gkJPEe4wTg/nfTc8or/EVm0Uaekx t5pHGOAVHTbFpUYeOZBUjgh/9UmVXrLhuOW9acF/JSB2szUs+Bh2cx4j0WlX72tQSZMI PslEA7jtlA1j1FqF9ypl18NcYa/WPAlb0ZJWpryhuk61dsFhF7WjHN3GB0QKxEedz4GG PZCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NmyCfyRi; 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 o61si48820466pld.392.2019.08.06.14.40.08; Tue, 06 Aug 2019 14:40:24 -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=NmyCfyRi; 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 S1727947AbfHFViy (ORCPT + 99 others); Tue, 6 Aug 2019 17:38:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:55732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbfHFViC (ORCPT ); Tue, 6 Aug 2019 17:38:02 -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 CF60720C01; Tue, 6 Aug 2019 21:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565127481; bh=Nge1Rt5g/b+aqtX1NJamqBDlTw67F+5Aabrmh1A3G+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NmyCfyRiPj2PTKMOz3CV92M6qTfamxY3htUVVtmAsN0XuZxRbH8wkDCuGf6pVNSeX 4rY6DrDe6KS/9nasseeGFUlpFFDjOrbI1dABCs2+bwTsi4Oiucgp5rSdtyVRI0RiTP exTCpPGFsGeYxdumahVAAy7RK1fn0xA5h2APrsC0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kees Cook , Jeffrin Jose T , Nick Desaulniers , Jens Axboe , Sasha Levin , linux-ide@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 06/14] libata: zpodd: Fix small read overflow in zpodd_get_mech_type() Date: Tue, 6 Aug 2019 17:37:40 -0400 Message-Id: <20190806213749.20689-6-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190806213749.20689-1-sashal@kernel.org> References: <20190806213749.20689-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: Kees Cook [ Upstream commit 71d6c505b4d9e6f76586350450e785e3d452b346 ] Jeffrin reported a KASAN issue: BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70 Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149 ... The buggy address belongs to the variable: cdb.48319+0x0/0x40 Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in eject_tray()"), this fixes a cdb[] buffer length, this time in zpodd_get_mech_type(): We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes. Reported-by: Jeffrin Jose T Fixes: afe759511808c ("libata: identify and init ZPODD devices") Link: https://lore.kernel.org/lkml/201907181423.E808958@keescook/ Tested-by: Jeffrin Jose T Reviewed-by: Nick Desaulniers Signed-off-by: Kees Cook Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/ata/libata-zpodd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c index 7017a81d53cf2..083856272e92a 100644 --- a/drivers/ata/libata-zpodd.c +++ b/drivers/ata/libata-zpodd.c @@ -55,7 +55,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev) unsigned int ret; struct rm_feature_desc *desc; struct ata_taskfile tf; - static const char cdb[] = { GPCMD_GET_CONFIGURATION, + static const char cdb[ATAPI_CDB_LEN] = { GPCMD_GET_CONFIGURATION, 2, /* only 1 feature descriptor requested */ 0, 3, /* 3, removable medium feature */ 0, 0, 0,/* reserved */ -- 2.20.1