Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp327805ybi; Thu, 11 Jul 2019 20:15:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzESNBPOWHE5QgSQ0TI7bB+qWiydDfQ/paxhh9XvOjtYIPc589a3sGm2z7jDYFaUgLAsKTJ X-Received: by 2002:a63:505a:: with SMTP id q26mr7908173pgl.18.1562901326927; Thu, 11 Jul 2019 20:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562901326; cv=none; d=google.com; s=arc-20160816; b=Vc7RNWfeacx6I9o2sJtu/Ugfl/P6vQit1pLiNDnUopZ/draPTrfJjlU74XVzi2YTIV eQb97e8chImhrtKQliiwX9WThER6GeZiBjLB0hAOisk3vEILjszl26g4yeLZz3/4jc/8 w3yoSEJANl5RDEvpR1TFzioasYCSCtdQEwST22cXMt0O7bNtl4NZjDT08Zp5ZxwrUkxq kBWqsvCJEenC/nhdI0eaI0IMqaioGlfA4ZHIZN8uRQCEdMRRPdqfN8KmmamcrebrSf7S /NlBFkFKE4hvGewIN2a4n3SZLmckgUdlfecXfp3r27GZanNV7sPDCFID9a+X6NqQPQap tX1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=7NHMc15S0o6Qcl+tq3/m1zdVESV0n/AifBG3M+SaWUo=; b=bNobl5jIapI7VOlloyJ4VCAohYIsSFcyRl3eWTrg31TbGH2heOrgXWcX5M3b/Rhop+ z0T5NDCIeblJD7vVDjRaHXN3w9LUy3yR6OmQxnjcy9LInp3iQK8pXvxM3HmiLfsCJjIf SHIKznHQcqSxyieea/DqMrvrCf0u/KFNl2Hta50vJsEB0McwXbNvDS0HMJtqfWRYUcKW fXqO7lDW5OgvRsT/6nslPejC3M1pNSt8+ocEOvUTvF0EXQaImnpCdwEL62qyy/154i/e Tk2XbXSR8lCV64juHiRlfxWcR/B8W0VsP1ZaM0hzs7adN5EQfw/t7Gn6kmrgttkM7TIV oGcQ== 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 61si6372836ple.275.2019.07.11.20.15.11; Thu, 11 Jul 2019 20:15:26 -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 S1729120AbfGLDOj (ORCPT + 99 others); Thu, 11 Jul 2019 23:14:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2264 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728497AbfGLDOj (ORCPT ); Thu, 11 Jul 2019 23:14:39 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 603536B08CDE0BF53948; Fri, 12 Jul 2019 11:14:36 +0800 (CST) Received: from HGHY2Y004646261.china.huawei.com (10.184.12.158) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Fri, 12 Jul 2019 11:14:29 +0800 From: Zenghui Yu To: , , CC: , , , , , , , Feng Tiantian , Zenghui Yu Subject: [RFC PATCH] fbcon: fix ypos over boundary issue Date: Fri, 12 Jul 2019 03:13:36 +0000 Message-ID: <1562901216-9916-1-git-send-email-yuzenghui@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.184.12.158] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Feng Tiantian While using "top" on a CentOS guest's VNC-client, then continuously press "Shift+PgUp", the guest kernel will get panic! Backtrace is attached below. We tested it on 5.2.0, and the issue remains. [ 66.946362] Unable to handle kernel paging request at virtual address ffff00000e240840 [ 66.946363] Mem abort info: [ 66.946364] Exception class = DABT (current EL), IL = 32 bits [ 66.946365] SET = 0, FnV = 0 [ 66.946366] EA = 0, S1PTW = 0 [ 66.946367] Data abort info: [ 66.946368] ISV = 0, ISS = 0x00000047 [ 66.946368] CM = 0, WnR = 1 [ 66.946370] swapper pgtable: 64k pages, 48-bit VAs, pgd = ffff000009660000 [ 66.946372] [ffff00000e240840] *pgd=000000023ffe0003, *pud=000000023ffe0003, *pmd=000000023ffd0003, *pte=0000000000000000 [ 66.946378] Internal error: Oops: 96000047 [#1] SMP [ 66.946379] Modules linked in: vfat fat crc32_ce ghash_ce sg sha2_ce sha256_arm64 virtio_balloon virtio_net sha1_ce ip_tables ext4 mbcache jbd2 virtio_gpu drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm i2c_core virtio_scsi virtio_pci virtio_mmio virtio_ring virtio [ 66.946403] CPU: 0 PID: 1035 Comm: top Not tainted 4.14.0-49.el7a.aarch64 #1 [ 66.946404] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 [ 66.946405] task: ffff8001c18fdc00 task.stack: ffff00000d4e0000 [ 66.946409] PC is at sys_imageblit+0x40c/0x10000 [sysimgblt] [ 66.946431] LR is at drm_fb_helper_sys_imageblit+0x28/0x4c [drm_kms_helper] [ 66.946433] pc : [] lr : [] pstate: 00000005 [ 66.946433] sp : ffff00000d4ef7f0 [ 66.946434] x29: ffff00000d4ef7f0 x28: 00000000000001ff [ 66.946436] x27: ffff8001c1c88100 x26: 0000000000000001 [ 66.946438] x25: 00000000000001f0 x24: 0000000000000018 [ 66.946440] x23: 0000000000000000 x22: ffff00000d4ef978 [ 66.946442] x21: ffff00000e240840 x20: 0000000000000000 [ 66.946444] x19: ffff8001c98c9000 x18: 0000fffff9d56670 [ 66.946445] x17: 0000000000000000 x16: 0000000000000000 [ 66.946447] x15: 0000000000000008 x14: 1b20202020202020 [ 66.946449] x13: 00000000000001f0 x12: 000000000000003e [ 66.946450] x11: 000000000000000f x10: ffff8001c8400000 [ 66.946452] x9 : 0000000000aaaaaa x8 : 0000000000000001 [ 66.946454] x7 : ffff0000020b0090 x6 : 0000000000000001 [ 66.946456] x5 : 0000000000000000 x4 : 0000000000000000 [ 66.946457] x3 : ffff8001c8400000 x2 : ffff00000e240840 [ 66.946459] x1 : 00000000000001ef x0 : 0000000000000007 [ 66.946461] Process top (pid: 1035, stack limit = 0xffff00000d4e0000) [ 66.946462] Call trace: [ 66.946464] Exception stack(0xffff00000d4ef6b0 to 0xffff00000d4ef7f0) [ 66.946465] f6a0: 0000000000000007 00000000000001ef [ 66.946467] f6c0: ffff00000e240840 ffff8001c8400000 0000000000000000 0000000000000000 [ 66.946468] f6e0: 0000000000000001 ffff0000020b0090 0000000000000001 0000000000aaaaaa [ 66.946470] f700: ffff8001c8400000 000000000000000f 000000000000003e 00000000000001f0 [ 66.946471] f720: 1b20202020202020 0000000000000008 0000000000000000 0000000000000000 [ 66.946472] f740: 0000fffff9d56670 ffff8001c98c9000 0000000000000000 ffff00000e240840 [ 66.946474] f760: ffff00000d4ef978 0000000000000000 0000000000000018 00000000000001f0 [ 66.946475] f780: 0000000000000001 ffff8001c1c88100 00000000000001ff ffff00000d4ef7f0 [ 66.946476] f7a0: ffff000002202e74 ffff00000d4ef7f0 ffff0000020a040c 0000000000000005 [ 66.946478] f7c0: ffff00000d4ef7e0 ffff0000080ea614 0001000000000000 ffff000008152f08 [ 66.946479] f7e0: ffff00000d4ef7f0 ffff0000020a040c [ 66.946481] [] sys_imageblit+0x40c/0x10000 [sysimgblt] [ 66.946501] [] drm_fb_helper_sys_imageblit+0x28/0x4c [drm_kms_helper] [ 66.946510] [] virtio_gpu_3d_imageblit+0x2c/0x78 [virtio_gpu] [ 66.946515] [] bit_putcs+0x288/0x49c [ 66.946517] [] fbcon_putcs+0x114/0x148 [ 66.946519] [] do_update_region+0x118/0x19c [ 66.946521] [] do_con_trol+0x114c/0x1314 [ 66.946523] [] do_con_write.part.22+0x1d8/0x890 [ 66.946525] [] con_write+0x84/0x8c [ 66.946527] [] n_tty_write+0x19c/0x408 [ 66.946529] [] tty_write+0x150/0x270 [ 66.946532] [] __vfs_write+0x58/0x180 [ 66.946534] [] vfs_write+0xa8/0x1a0 [ 66.946536] [] SyS_write+0x60/0xc0 [ 66.946537] Exception stack(0xffff00000d4efec0 to 0xffff00000d4f0000) [ 66.946539] fec0: 0000000000000001 0000000000457958 0000000000000800 0000000000000000 [ 66.946540] fee0: 00000000fbad2885 0000000000000bd0 0000ffff8556add4 0000000000000000 [ 66.946541] ff00: 0000000000000040 0000000000000000 0000000000434a88 0000000000000012 [ 66.946543] ff20: 0000000100000000 0000fffff9d564f0 0000fffff9d564a0 0000000000000008 [ 66.946544] ff40: 0000000000000000 0000ffff85593b1c 0000fffff9d56670 0000000000000800 [ 66.946546] ff60: 0000000000457958 0000ffff856a1158 0000000000000800 0000ffff85720000 [ 66.946547] ff80: 0000000000000000 0000ffff856f604c 0000000000000000 0000000000436000 [ 66.946548] ffa0: 000000001c90a160 0000fffff9d56f20 0000ffff855965f4 0000fffff9d56f20 [ 66.946549] ffc0: 0000ffff855f12c8 0000000020000000 0000000000000001 0000000000000040 [ 66.946551] ffe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 66.946554] [] __sys_trace_return+0x0/0x4 [ 66.946556] Code: 0a080084 b86478e4 0a040124 4a050084 (b9000044) [ 66.946561] ---[ end trace 32d49c68b19c4796 ]--- [ 66.946562] Kernel panic - not syncing: Fatal exception [ 66.946564] SMP: stopping secondary CPUs [ 66.946596] Kernel Offset: disabled [ 66.946598] CPU features: 0x1802008 [ 66.946598] Memory Limit: none [ 67.092353] ---[ end Kernel panic - not syncing: Fatal exception From our non-expert analysis, fbcon ypos will sometimes over boundary and then fbcon_putcs() access invalid VGA framebuffer address. We modify the real_y() to make sure fbcon ypos is always less than rows. Reported-by: Zengruan Ye Signed-off-by: Feng Tiantian Signed-off-by: Zenghui Yu --- Hi Bartlomiej, Zengruan had reported this issue [1] but received no reply. Does it make sense to fix this issue? Could you please take a look into this patch? Thanks, zenghui [1] https://lkml.org/lkml/2018/11/27/639 drivers/video/fbdev/core/fbcon.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h index 20dea85..b1aa00e 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -230,7 +230,10 @@ static inline int real_y(struct fbcon_display *p, int ypos) int rows = p->vrows; ypos += p->yscroll; - return ypos < rows ? ypos : ypos - rows; + if (rows == 0) + return ypos; + else + return ypos < rows ? ypos : ypos % rows; } -- 1.8.3.1