Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4024077ybl; Mon, 3 Feb 2020 11:04:10 -0800 (PST) X-Google-Smtp-Source: APXvYqy+iNHDwfb3RkaFWWVCHH4bkM4jYfyHG9iimFLjkQUn0b6XhxH2+/cM872SthHVLerUSwq7 X-Received: by 2002:aca:cd46:: with SMTP id d67mr365373oig.156.1580756649937; Mon, 03 Feb 2020 11:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580756649; cv=none; d=google.com; s=arc-20160816; b=Ba5QCxBOdfCq4Mk/q3tvq3FlAX3yNlqrOct/oy3K/iJ9U4lDFLuo9B5HaIubyeHkcj ynhy2YmMaYfMqGwYJ8lnUhEhCE6gM0ZbB3XE67Nsw+lUQDzEl+v7/418wgVbn612a9Gi fS7XOUSoXWfrYMqjxTszIk/kdny/FcIv0x8lohw4W/JBiXCV5LJbzWAQM24B78PlLWVo 4oDa4dB7+6r0JHKZystcD71a5op7YI1w9y/SFMu0RhamkCJwjbKcij//Mo3iJhATXaPU LtNudT71mIajbaQtLnHrD5dU0MhWAz5G/9RAxRnzy/vSync5fv/MI1nWURpke2ug8yN3 AKdg== 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=VEhjgHrU0jt2OJQEEaWGsC2AKjx2k9WaOSk4xT0XXaw=; b=iSwJ1QZelZTaj0V1cmiBayZKVVaU+LFmfsxc3aYVLPiUHN86sJ3J3XVaemnSLCdCd0 01VNM0c8lyyh/uP1I2upyoFGKhL8xpgb2cVg0ejR8mN1STvxJl6ZgQofZOmm9WxdLw9d lEwUx0MKMA4A2EHiveIF03NZ9LpBrGsd90P/zNwM0oigwR/C0jcq3F7BBAvzH/k9zJdd etphfD4qFjYt1aBDEuKDqs9HuChcPL3wMRmLymOpzaiKVt5BSfYP7D/WTlBti40gzuGk oWuR2XS2VPBSMGZgT9W4jgtiQDY1D7Pag0b5V1bgZ+vCht0eEhSA1eDkTuZEBzF8p+/f 5ZUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LlOkBys0; 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 p12si9639555otk.173.2020.02.03.11.03.58; Mon, 03 Feb 2020 11:04:09 -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=LlOkBys0; 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 S1729441AbgBCQ1f (ORCPT + 99 others); Mon, 3 Feb 2020 11:27:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:38874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729433AbgBCQ1e (ORCPT ); Mon, 3 Feb 2020 11:27:34 -0500 Received: from localhost (unknown [104.132.45.99]) (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 317052086A; Mon, 3 Feb 2020 16:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580747253; bh=p8BeVFlI4B5jR4xhcn1nzxAZeFco8rxCzUuCaHxiy8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LlOkBys0By3xopfdq437g2h+Ddegjaf5ueLjgetxffIuQHVzZDycojNv5SWimYFdR 2waxTM0rGZt0BD6aJe+O0LX5kBgDHJ1Fu/xLPvCuENigt/uJH90RwPOaasaFM/QXbb oa/bW9y7NUL0MNZNU17CnJT4UPUELTv/sPy2+ybM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilja Van Sprundel , Michael Ellerman , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 55/68] airo: Fix possible info leak in AIROOLDIOCTL/SIOCDEVPRIVATE Date: Mon, 3 Feb 2020 16:19:51 +0000 Message-Id: <20200203161914.040441122@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200203161904.705434837@linuxfoundation.org> References: <20200203161904.705434837@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: Michael Ellerman [ Upstream commit d6bce2137f5d6bb1093e96d2f801479099b28094 ] The driver for Cisco Aironet 4500 and 4800 series cards (airo.c), implements AIROOLDIOCTL/SIOCDEVPRIVATE in airo_ioctl(). The ioctl handler copies an aironet_ioctl struct from userspace, which includes a command and a length. Some of the commands are handled in readrids(), which kmalloc()'s a buffer of RIDSIZE (2048) bytes. That buffer is then passed to PC4500_readrid(), which has two cases. The else case does some setup and then reads up to RIDSIZE bytes from the hardware into the kmalloc()'ed buffer. Here len == RIDSIZE, pBuf is the kmalloc()'ed buffer: // read the rid length field bap_read(ai, pBuf, 2, BAP1); // length for remaining part of rid len = min(len, (int)le16_to_cpu(*(__le16*)pBuf)) - 2; ... // read remainder of the rid rc = bap_read(ai, ((__le16*)pBuf)+1, len, BAP1); PC4500_readrid() then returns to readrids() which does: len = comp->len; if (copy_to_user(comp->data, iobuf, min(len, (int)RIDSIZE))) { Where comp->len is the user controlled length field. So if the "rid length field" returned by the hardware is < 2048, and the user requests 2048 bytes in comp->len, we will leak the previous contents of the kmalloc()'ed buffer to userspace. Fix it by kzalloc()'ing the buffer. Found by Ilja by code inspection, not tested as I don't have the required hardware. Reported-by: Ilja Van Sprundel Signed-off-by: Michael Ellerman Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/wireless/cisco/airo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 04939e576ee02..7956b5b529c99 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -7819,7 +7819,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { return -EINVAL; } - if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL) + if ((iobuf = kzalloc(RIDSIZE, GFP_KERNEL)) == NULL) return -ENOMEM; PC4500_readrid(ai,ridcode,iobuf,RIDSIZE, 1); -- 2.20.1