Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2726701ybv; Mon, 24 Feb 2020 10:23:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxaLWqLXzCkc04uCxobYbZzFcD/725x6nfui+NPkTNJNylTdQucq1HIn7Ogl33MEIEokReY X-Received: by 2002:a9d:600e:: with SMTP id h14mr39651504otj.113.1582568620851; Mon, 24 Feb 2020 10:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582568620; cv=none; d=google.com; s=arc-20160816; b=uWO4QZeoFKixDChX4Z+zxlAsi4M55F6PWLmttOVg7KbKNhqpdH502dExaVp300bGOk ZoweEJIBT9CRWFDcXeebMQGy2B97N5rd2mW5ol3cTeye+FKY3RlI2LEk60vdmUMNIjeV VRn3DzmLasX8G5whnDgjfZ5dvs2YVk0T1U/8AqC25Bmvn3QFjSm648nW7/VO092TLdL0 MR7lwLbkmFYcBZ12eZkUo32hiiIDitVxkq/pPbq0nQxVzXSpXgIdiSMwzMVYHAXeyaEl O+xTe1nRlY0fdfKD2f1GH1TxMhmDUi4ym646fQVCA2EoliwnW9ptP/n7NGktjJqXBce0 G6Rg== 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=n0v9O3M6ZtT/BOurCxYIhj7n2CriDZMDmYfPRLYihmQ=; b=Z3oPZW2xWxaC/hbfWi6yFxL6oWvI8Db4fKiPG8xuKonY90cbyS/Ydu6A0l0w3n22Ln r097xaCHzfwebGdJmJkibm57W0jYEKGEnydo7d5md7zta174S6yvPI9pIAwFq9xociTa t4lXBt0kUIbHyIg0TDTjBkeebjqGqW5RSBc+O6b9rccVh8xVl6x3Cd2h4Ehp0SgThH1G ijRsU4qIGGNRHCI1focGkuPV7qmDoqVClP+ArzQ9CcPcfn/VPUZ+gEMuYrZpjNnE0YBg Cwm5OCYHFAG4YU85O7Brmj7WGJ18kahmkVefM4VJkprDrLGZArjKIkC8ZLm9Z+TXay0s Tbrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LD8DxQ3o; 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 z20si4858164oib.26.2020.02.24.10.23.29; Mon, 24 Feb 2020 10:23:40 -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=LD8DxQ3o; 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 S1727916AbgBXSV7 (ORCPT + 99 others); Mon, 24 Feb 2020 13:21:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:58860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbgBXSVw (ORCPT ); Mon, 24 Feb 2020 13:21:52 -0500 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (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 0DD0D2084E; Mon, 24 Feb 2020 18:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582568512; bh=HHffBA1xZRZJMcbypgR4QrM3PbiivCptJcaucVhdCx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LD8DxQ3oknenBHer0gtf++MxWrn5G/pw1pR3EHAuHoD0J8hzJNry3BXTJ2BbkYXrq fRuyBA37lI58VOhUMoPLvf5KfRgc3M9TA2Wq7w/vUIsAGu+pwKwzk+d72QTeswXQsj FF/yW1GimcDuuMu9Kg52GjA+742jdXWuyvSFM8c8= From: Eric Biggers To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Al Viro Subject: [PATCH v2 1/2] tty: fix compat TIOCGSERIAL leaking uninitialized memory Date: Mon, 24 Feb 2020 10:20:43 -0800 Message-Id: <20200224182044.234553-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200224182044.234553-1-ebiggers@kernel.org> References: <20200224181532.GA109047@gmail.com> <20200224182044.234553-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers Commit 77654350306a ("take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()") changed the compat version of TIOCGSERIAL to start copying a whole 'serial_struct32' to userspace rather than individual fields, but failed to initialize all padding and fields -- namely the hole after the 'iomem_reg_shift' field, and the 'reserved' field. Fix this by initializing the struct to zero. [v2: use sizeof, and convert the adjacent line for consistency.] Reported-by: syzbot+8da9175e28eadcb203ce@syzkaller.appspotmail.com Fixes: 77654350306a ("take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()") Cc: # v4.20+ Signed-off-by: Eric Biggers --- drivers/tty/tty_io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 1fcf7ad83dfa0a..db4a13bc855ed6 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2730,7 +2730,9 @@ static int compat_tty_tiocgserial(struct tty_struct *tty, struct serial_struct32 v32; struct serial_struct v; int err; - memset(&v, 0, sizeof(struct serial_struct)); + + memset(&v, 0, sizeof(v)); + memset(&v32, 0, sizeof(v32)); if (!tty->ops->set_serial) return -ENOTTY; -- 2.25.0.265.gbab2e86ba0-goog