Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp719730yba; Thu, 16 May 2019 07:55:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOd6PiG+ZL4zxFFY/T+LkOkBkgu5h6eoSbdb58P+xeeaHZY/Ou/t68CV1ug+2N3L+I3CXh X-Received: by 2002:a62:ac01:: with SMTP id v1mr14064077pfe.110.1558018545627; Thu, 16 May 2019 07:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558018545; cv=none; d=google.com; s=arc-20160816; b=g6R3NWEOaLzQrqs4/5ZEIIEkKzr4zZVivymJvbh3Ta7mSJkckAPFoFEzmpRn7fIapV Zj0TduooI9Fbi3Cw8mKAs5/vvFU519DR3C4rILY0nqjzUrA/NukjwXVu+ApB0sXjDRlx hZKgd8gLiF6kZmTBg9qrS+wQ1ZFfZY5qKJLvPqMtu6ZdMLA4dZItTCMdW/tMXPjEdyBK 8zoaFEAIw/WW7uYPLReXUPLsqytSnhZOQZBI7f9hUMYxKY874PJam4OX0MR2UnnGRD6y n2GbB6VdbRuQZvV3lWSL+gSYnidWrd2iws+4G2IyoV1+GhpWHufNw0+SZRoYEVmMTObi AWCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=novTqX8VvyU0HXZyZbhAxQptriFkKNdmf0KSk9TZzOw=; b=S+7tTjsTM2XeqcFnKjnTNAt8xtrEO4klUInjrFHTxcsBXYoz8dsRCEeVVsGAyPpk0Z AQcyghEfSDOw28JV9dSFg+LvFoZoxci7a/xyKWvQYoQUtGD7BBQRgf40wH7TjTj66ryy nAXm+EzDmKnurUWJDNZkiDfGQOrjdSV5CwMPP6qITLydMPHHdYrJwaY3FSKZPHXD7otD fpQcwKIcShT/9bI07xokI6sKWxNS79VlwbFWqbKfZP7wxLnpjtmS5MrMxqxbHqEVkZts nijZ5q2y5cqrCJBBijpn5TvHjalT+biQ2008JdX/Durkoane7jUAupbWAEZxUZXPzo4V SRdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Duz81vOL; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30si5185534pla.105.2019.05.16.07.55.30; Thu, 16 May 2019 07:55:45 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Duz81vOL; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727426AbfEPOw0 (ORCPT + 99 others); Thu, 16 May 2019 10:52:26 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34336 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727336AbfEPOwZ (ORCPT ); Thu, 16 May 2019 10:52:25 -0400 Received: by mail-wr1-f65.google.com with SMTP id f8so2348673wrt.1; Thu, 16 May 2019 07:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=novTqX8VvyU0HXZyZbhAxQptriFkKNdmf0KSk9TZzOw=; b=Duz81vOL3a+Ms57KLi31wimSiefhtpZHyZ3ftpLvkBDZ2hPQt5xdsAw5jPh3gMw4i6 RYrHuknu9z4Rsy4VzsQeFvsMomSRdfNup2H0Xh80xnRvAisrraeJHqPkDEmOkdBPANQt Ty0YuUjtrxkZ+sTNzT57666ht00QA3SglQpY13pLiM5VBWYfCQcw6grU8OAQS4X+OthZ qZUBypk9Xx6x8i8NVI8Wi5TbK0XzB7OdNmQCu2KmLG6PEioGTr6MjHfbjUddEhGAH03N 3kTN89jUtvFFT3N8gi6k5iVGNGIVkkqxLtd0XR1Y9F9MvdZu9yeuS3tcBRijwxiRcjXp 9DYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=novTqX8VvyU0HXZyZbhAxQptriFkKNdmf0KSk9TZzOw=; b=YRRBIY/T3+rkaA2Iiaskm0OwDoLhST5qY+0YX0ABb0ZqFyioDZ1Uzg/SwXyeBtJW1m DWraoV0qjqLVHj+BxeUi58hu9KBQfa/oWR3AB00ZLJtwbnmYvNp5PdrD+Mfuznmkqj5c mPMfyItzUAq43I3g16Gvr4n16mmM9AGd3QU7hQmzrCBQSCJ+U4VQCidNQkWy+/xZoG9A lfrRjMOqr0BkqW4vWYsnWaAHTjj9rJqEw4vJ/P5ZOn2l4nSpvG3h2balODsPHPhJNbY0 O6Qx6e61GV0x2u9Ki7e4DcCXH359O9qaADsxztSV9PqO3ccUcEBXUIux1B2SKEhfZXbX w+yg== X-Gm-Message-State: APjAAAV7g5vRC5NEbVxEdLMA2wKF/XPIejryFA+kVR5Bny1HhQU826D3 unqcib+1OfrKjrb/hiwuLaPQik1KJJB3lO06HiU= X-Received: by 2002:adf:9023:: with SMTP id h32mr19240055wrh.95.1558018343668; Thu, 16 May 2019 07:52:23 -0700 (PDT) MIME-Version: 1.0 References: <20190516040931.16276-1-yuehaibing@huawei.com> In-Reply-To: <20190516040931.16276-1-yuehaibing@huawei.com> From: Shubhrajyoti Datta Date: Thu, 16 May 2019 20:22:12 +0530 Message-ID: Subject: Re: [PATCH] serial-uartlite: Fix null-ptr-deref in ulite_exit To: YueHaibing Cc: jacmet@sunsite.dk, Greg Kroah-Hartman , jslaby@suse.com, Shubhrajyoti Datta , linux-kernel , linux-serial@vger.kernel.org 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 Hi YueHaibing, Thanks for the patch. On Thu, May 16, 2019 at 9:42 AM YueHaibing wrote: > > If ulite_probe is not called or failed to registed s/registed/register > uart_register_driver, unload the module will call > uart_unregister_driver, which will tigger NULL s/tigger/trigger > pointer dereference like this: > > BUG: KASAN: null-ptr-deref in tty_unregister_driver+0x19/0x100 > Read of size 4 at addr 0000000000000034 by task syz-executor.0/4246 > > CPU: 0 PID: 4246 Comm: syz-executor.0 Tainted: G C 5.1.0+ #26 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 > Call Trace: > dump_stack+0xa9/0x10e > ? tty_unregister_driver+0x19/0x100 > ? tty_unregister_driver+0x19/0x100 > __kasan_report+0x171/0x18d > ? tty_unregister_driver+0x19/0x100 > kasan_report+0xe/0x20 > tty_unregister_driver+0x19/0x100 > uart_unregister_driver+0x30/0xc0 > __x64_sys_delete_module+0x244/0x330 > ? __ia32_sys_delete_module+0x330/0x330 > ? __x64_sys_clock_gettime+0xe3/0x160 > ? trace_hardirqs_on_thunk+0x1a/0x1c > ? trace_hardirqs_off_caller+0x3e/0x130 > ? lockdep_hardirqs_off+0xb5/0x100 > ? mark_held_locks+0x1a/0x90 > ? do_syscall_64+0x14/0x2a0 > do_syscall_64+0x72/0x2a0 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > > This patch fix this by moving uart_unregister_driver > to ulite_remove. > Reviewed-by: Shubhrajyoti Datta > Reported-by: Hulk Robot > Fixes: 415b43bdb008 ("tty: serial: uartlite: Move uart register to probe") > Signed-off-by: YueHaibing > --- > drivers/tty/serial/uartlite.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c > index b8b912b..2e49fb6 100644 > --- a/drivers/tty/serial/uartlite.c > +++ b/drivers/tty/serial/uartlite.c > @@ -867,6 +867,7 @@ static int ulite_remove(struct platform_device *pdev) > pm_runtime_disable(&pdev->dev); > pm_runtime_set_suspended(&pdev->dev); > pm_runtime_dont_use_autosuspend(&pdev->dev); > + uart_unregister_driver(&ulite_uart_driver); > return rc; > } > > @@ -897,7 +898,6 @@ static int __init ulite_init(void) > static void __exit ulite_exit(void) > { > platform_driver_unregister(&ulite_platform_driver); > - uart_unregister_driver(&ulite_uart_driver); > } > > module_init(ulite_init); > -- > 1.8.3.1 > >