Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1411658imm; Thu, 5 Jul 2018 22:53:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcxQ/RBTf2anwntE5wEEjxRp6KAyyRIAHo6KxJ0kJ8Nq2BEKKv7Rastzo/ovlKc9ZP4Celn X-Received: by 2002:a63:2106:: with SMTP id h6-v6mr6749290pgh.161.1530856419528; Thu, 05 Jul 2018 22:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530856419; cv=none; d=google.com; s=arc-20160816; b=CZhL0fFEMVq7FbVsPUzstuYHRsMHMfuss/GJHtAXZw+pxt1zw6sidpTJKuSEI/PfvD 7xdG9KnWdFa1Kq9f9ljv4QCxp4aGvKdHcF+n+rbG87ccqICcLNMKK75xCsU3oHmy081r GKsqNJ/Qm2/Wn+DA8m7EuFjzkXghVspnpB3Pw2usmg/RelI/wQ0rxKU9ezUAPabIeC0t I2dRDjqEu+yt5bna0J8NfN6PNUFtSiq1y1H2NVAMCku2sWjrnVMmTbGKhf5WPg0EIkpw keNO/cB0faw0msIJAuO5q1VYukW6zr78/aXqlqgrb3zJ0iGTftnbNVm6wmx+3bnphejs KhJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=tx/h1Okl8gQbdoYP4qQcNSI7y36UNmuN6pdLIv2ji/E=; b=PU8wlSy0j7rw9qYxi1Q2BoBuUc1SDAVetcN0EdKSMdsr5nycvVdoOPRPC2MCDUVrrP Wv48HH7aF6BtVGm6Z47BFot0/gvJHP7t6ymOzN6ASMcXO+6hKTUxheW/MxnREDReVcNK XwgqeUULOiSv9gzUO5HfUkwFB04kqyOdNLxqhstdLzwIpF15wqneS9psqAuHY4vew/77 ntX0EY2B2adDtT08iyZHu5tYzh3okM7kVRexy7QPtZuLgMmbDWJpDZSdN+b3OX2nzFvp ts6UveSQ0rcx5xkauQViItlcd3Br6705BqR86Af/XO2gThcUjCXW2Yz0980OYa9XlazV yyxQ== ARC-Authentication-Results: i=1; mx.google.com; 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 65-v6si7640768pfd.73.2018.07.05.22.53.25; Thu, 05 Jul 2018 22:53:39 -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; 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 S934514AbeGFFwI (ORCPT + 99 others); Fri, 6 Jul 2018 01:52:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33682 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933857AbeGFFwF (ORCPT ); Fri, 6 Jul 2018 01:52:05 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 18F6C86A; Fri, 6 Jul 2018 05:52:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+17a8efdf800000@syzkaller.appspotmail.com, Alexander Potapenko Subject: [PATCH 4.14 14/61] vt: prevent leaking uninitialized data to userspace via /dev/vcs* Date: Fri, 6 Jul 2018 07:46:38 +0200 Message-Id: <20180706054712.883804664@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Potapenko commit 21eff69aaaa0e766ca0ce445b477698dc6a9f55a upstream. KMSAN reported an infoleak when reading from /dev/vcs*: BUG: KMSAN: kernel-infoleak in vcs_read+0x18ba/0x1cc0 Call Trace: ... kmsan_copy_to_user+0x7a/0x160 mm/kmsan/kmsan.c:1253 copy_to_user ./include/linux/uaccess.h:184 vcs_read+0x18ba/0x1cc0 drivers/tty/vt/vc_screen.c:352 __vfs_read+0x1b2/0x9d0 fs/read_write.c:416 vfs_read+0x36c/0x6b0 fs/read_write.c:452 ... Uninit was created at: kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279 kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189 kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315 __kmalloc+0x13a/0x350 mm/slub.c:3818 kmalloc ./include/linux/slab.h:517 vc_allocate+0x438/0x800 drivers/tty/vt/vt.c:787 con_install+0x8c/0x640 drivers/tty/vt/vt.c:2880 tty_driver_install_tty drivers/tty/tty_io.c:1224 tty_init_dev+0x1b5/0x1020 drivers/tty/tty_io.c:1324 tty_open_by_driver drivers/tty/tty_io.c:1959 tty_open+0x17b4/0x2ed0 drivers/tty/tty_io.c:2007 chrdev_open+0xc25/0xd90 fs/char_dev.c:417 do_dentry_open+0xccc/0x1440 fs/open.c:794 vfs_open+0x1b6/0x2f0 fs/open.c:908 ... Bytes 0-79 of 240 are uninitialized Consistently allocating |vc_screenbuf| with kzalloc() fixes the problem Reported-by: syzbot+17a8efdf800000@syzkaller.appspotmail.com Signed-off-by: Alexander Potapenko Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -782,7 +782,7 @@ int vc_allocate(unsigned int currcons) / if (!*vc->vc_uni_pagedir_loc) con_set_default_unimap(vc); - vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); + vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); if (!vc->vc_screenbuf) goto err_free; @@ -869,7 +869,7 @@ static int vc_do_resize(struct tty_struc if (new_screen_size > (4 << 20)) return -EINVAL; - newscreen = kmalloc(new_screen_size, GFP_USER); + newscreen = kzalloc(new_screen_size, GFP_USER); if (!newscreen) return -ENOMEM;