Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2153753ybm; Thu, 23 May 2019 12:14:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/nFH5HRLwXCdqfskGSD9y3wsIpnBPgEpUJC0zIYJnhwwU4LaBcEY8Jxg/PqHUIjZiwOev X-Received: by 2002:a65:6116:: with SMTP id z22mr100596647pgu.50.1558638882127; Thu, 23 May 2019 12:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638882; cv=none; d=google.com; s=arc-20160816; b=lcHW+IKLB/xdiNGZaq4/V8eK8l79sbHh1zA82D1dzkM9E33NJtSCBn3XX5taUsgqJr S5Om3ZwuWm34xa8vfngj3eDEW7UJDDPSPYmQ9lmJMOBxMc079n+DgdID1w8e05ZLx23K osmq4RpihLkxRXA/PHlBSsUDfydgozMzu7s2KtE/KHFkXPi1SgX5hNinNDEo5ylqcZvs AeYKXJiawxzf885Nnyyzt1zfXRqvuzsPa9yfkyO+MXITGRMmku6tgyIGwIcO57yo7USe kfX3rqDmd1j+GRTwSkvq/bJjeREj06yPPjSzRSkChCDvUYmFTANvOYbKTfaLX0rGyX0a aUgQ== 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=7D2rFaA9rs0RLwGtQCnXpiciv7UgeIhJbN4tbBjhQ4c=; b=rlAVr0VUKnLBa3MwhMkXIVwWg0MuLeaM5nr8B+9D0FbcyKc20qexTKkckfZ39dkFsC PDOagFfRGC3lmb1IjDDf2BOAp1FDWXL89+UtHMf/gt1dzzlqgYhKdiR+nTadwf/EqESR ThBD6KyziCfPjMwaBSswghxGAx4olT7sQhFYN6jMeLMWJS4ARKVvlWc0Ggr+e9KXmBbc jshFDrRhj5YqncZMrBJfmLkBMcvhIQTTWQ7CJBCoaMVxfwg+etiLDNCcJX42HrzkIS2A +M1aJmGEJB4BP0CiwfaznNMQHaoHlh5owhubmYF91hGLrAvIU/rinqSVRYGeivdfiji/ Q7zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jfQkF8hS; 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 q16si402622pjc.23.2019.05.23.12.14.26; Thu, 23 May 2019 12:14:42 -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=@kernel.org header.s=default header.b=jfQkF8hS; 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 S2388054AbfEWTLI (ORCPT + 99 others); Thu, 23 May 2019 15:11:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:44478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388069AbfEWTLF (ORCPT ); Thu, 23 May 2019 15:11:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 19BA0217F9; Thu, 23 May 2019 19:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638664; bh=E8Fez+UjFAXlTw7Yz7IfL44Gcey0YmhWjuPBqO4+gB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jfQkF8hSg7lL4k0VUE3TdylxD93+lPKRRMBuH497kmS2qaqy8LcHJp4b4ciu3uHfL vjpXIzwYUf/1wfeCTcWx9HTgw/qk8gPK0gsVJYhn31v8AGCk03fV7QgGVz/kvvSoQn zbespLKK5JWfZ7hKa21syCawuK/UToFYvwVKtjDo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , YueHaibing , Guillaume Nault , "David S. Miller" Subject: [PATCH 4.14 05/77] ppp: deflate: Fix possible crash in deflate_init Date: Thu, 23 May 2019 21:05:23 +0200 Message-Id: <20190523181720.797965477@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181719.982121681@linuxfoundation.org> References: <20190523181719.982121681@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: YueHaibing [ Upstream commit 3ebe1bca58c85325c97a22d4fc3f5b5420752e6f ] BUG: unable to handle kernel paging request at ffffffffa018f000 PGD 3270067 P4D 3270067 PUD 3271063 PMD 2307eb067 PTE 0 Oops: 0000 [#1] PREEMPT SMP CPU: 0 PID: 4138 Comm: modprobe Not tainted 5.1.0-rc7+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:ppp_register_compressor+0x3e/0xd0 [ppp_generic] Code: 98 4a 3f e2 48 8b 15 c1 67 00 00 41 8b 0c 24 48 81 fa 40 f0 19 a0 75 0e eb 35 48 8b 12 48 81 fa 40 f0 19 a0 74 RSP: 0018:ffffc90000d93c68 EFLAGS: 00010287 RAX: ffffffffa018f000 RBX: ffffffffa01a3000 RCX: 000000000000001a RDX: ffff888230c750a0 RSI: 0000000000000000 RDI: ffffffffa019f000 RBP: ffffc90000d93c80 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa0194080 R13: ffff88822ee1a700 R14: 0000000000000000 R15: ffffc90000d93e78 FS: 00007f2339557540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa018f000 CR3: 000000022bde4000 CR4: 00000000000006f0 Call Trace: ? 0xffffffffa01a3000 deflate_init+0x11/0x1000 [ppp_deflate] ? 0xffffffffa01a3000 do_one_initcall+0x6c/0x3cc ? kmem_cache_alloc_trace+0x248/0x3b0 do_init_module+0x5b/0x1f1 load_module+0x1db1/0x2690 ? m_show+0x1d0/0x1d0 __do_sys_finit_module+0xc5/0xd0 __x64_sys_finit_module+0x15/0x20 do_syscall_64+0x6b/0x1d0 entry_SYSCALL_64_after_hwframe+0x49/0xbe If ppp_deflate fails to register in deflate_init, module initialization failed out, however ppp_deflate_draft may has been regiestred and not unregistered before return. Then the seconed modprobe will trigger crash like this. Reported-by: Hulk Robot Signed-off-by: YueHaibing Acked-by: Guillaume Nault Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ppp/ppp_deflate.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) --- a/drivers/net/ppp/ppp_deflate.c +++ b/drivers/net/ppp/ppp_deflate.c @@ -610,12 +610,20 @@ static struct compressor ppp_deflate_dra static int __init deflate_init(void) { - int answer = ppp_register_compressor(&ppp_deflate); - if (answer == 0) - printk(KERN_INFO - "PPP Deflate Compression module registered\n"); - ppp_register_compressor(&ppp_deflate_draft); - return answer; + int rc; + + rc = ppp_register_compressor(&ppp_deflate); + if (rc) + return rc; + + rc = ppp_register_compressor(&ppp_deflate_draft); + if (rc) { + ppp_unregister_compressor(&ppp_deflate); + return rc; + } + + pr_info("PPP Deflate Compression module registered\n"); + return 0; } static void __exit deflate_cleanup(void)