Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4022554ybl; Mon, 3 Feb 2020 11:02:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzAVP1l4OB8k9fm31IO9YX9ra5Abd4MMroMaNDJBEgW/LrDL05zUU0kimdcXIxs/q3OqP23 X-Received: by 2002:aca:2307:: with SMTP id e7mr328202oie.163.1580756566109; Mon, 03 Feb 2020 11:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580756566; cv=none; d=google.com; s=arc-20160816; b=M6HbGkeuPFdEDorwBh/98Pdq1LwxV7EdvO5GEaak4iz6TB0ZYr89vGL6dd/aT2Dt3K zq+4IuiubEVW8qDPwYorT/faxwRuCQsEzpzwF1BGiA7FbwOKRnLM4n40qN5TXj9rF09F hzsAY1UsLpO1ZKWSACySt4Ua02I6Bdkc4dWBcNzbnMZV3++P6EK7paL0fSz1ak/q+9eU mLxVjZr4OdZE2+dSyH6IISBrYcoVpSQT8R70sw33iU+dPR8Zw+F/RUK3ZJb/8bD0OBJ0 wfu+MUcwGhaTKTUc1gDz8rEkQPNdIjzIKz7Ys0/8mPSTNOb8HbLXZxvbjia1E7MfFOK1 g3Vw== 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=ypyP6mDsNpMR5l7tkA/mHsI4DewU4um66YMNM978wMI=; b=MEM+O54JVCj9xR2BwzGcld5j9Hd9goJWUFZvCLSAFg1uucep4PdzshQcqhzbTcd60w y529K7AcDQdJ5zPrQOEqtMMHQbzfqgL7mYUBET06Xpj6yYzZ93HcA588bbigVtl18wv2 OR0BI2k1g/AvwI+/fym2kmNWEb8lYoCQz2waDBT1tqkwUY+MsKcQq2++gUCwBspNEPk0 l/fM01xWSMy/vrCeujFeASdvXtuViGzeG3FVoWYsB7+gMWDFet2BSCMLerEfmxDcZBf+ A1Xg/VyXJ9pcCC5P+qHIle8GZ81aV8wjCoEtcGFRyptGfZRkPbwfDMdTqoWUogxc3rOY 225g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gqqODzwR; 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 r22si9381471otn.192.2020.02.03.11.02.32; Mon, 03 Feb 2020 11:02: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=gqqODzwR; 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 S1727140AbgBCQV4 (ORCPT + 99 others); Mon, 3 Feb 2020 11:21:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:33966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729215AbgBCQVx (ORCPT ); Mon, 3 Feb 2020 11:21:53 -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 830632080C; Mon, 3 Feb 2020 16:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580746912; bh=dJ99gQh3O/vojkuYbo/2Mnv1K1SLRfANzJC7ZNyQkx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gqqODzwRduX1BkNgnriu07IL1/3nvaDJ8FAXbe2dX++Gr5kEAgsUmxl/P+JnhVE3S 6mJz3g0K2ynvip9kt9zFv/vHYx8R5q75YGnGHSqGoOU3SbuGxG4YIEhQnFXjKxj3BR K/lvduHwdgFH/F9oXxYROMF9x3muAez6iaiZJGrI= 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.4 42/53] airo: Fix possible info leak in AIROOLDIOCTL/SIOCDEVPRIVATE Date: Mon, 3 Feb 2020 16:19:34 +0000 Message-Id: <20200203161910.324910174@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200203161902.714326084@linuxfoundation.org> References: <20200203161902.714326084@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/airo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 82d24f2b9c190..94df9ddfb7eb1 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -7831,7 +7831,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