Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp159753imm; Wed, 5 Sep 2018 23:42:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYx2i2XLB/vgrez0nN6G2f8f7Czl6CmrMzPXHnnSWzUK709R8OfIOE5dSMSn6bCIujQYAwn X-Received: by 2002:a63:65c2:: with SMTP id z185-v6mr1313434pgb.276.1536216124420; Wed, 05 Sep 2018 23:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536216124; cv=none; d=google.com; s=arc-20160816; b=f6Y/apHSp+Iws6v6ef8buFbAFFxOy2Cf7dzcz+o51H1qdsdaRhnTWLZm5ghrvLn7l/ N/WeoLTi44AdVY6z4sjzh8y1dyjyKSN5qk0aoQ993mwLOG+t6n/RdaFfX5g1TJ33o8HX FI8uBWYjiP3kujSkfAt+lI0QjYm4W7HLF5Jyz7RVRhSUjwKfYPMNnOdJHFVgQyNQD8Jn UECZQ3fzt8z0xl4rG64uqmOn34CkXnjSaYLwXAnQHBs2+c0gsNFa6epSSXxj3DIuhPWj XOMni6Qfq6fNNoWoVsLVCsYHANxkQ/JF96T/4eQ4FNF1/QepJtkn2dxw0akcSWZAzgpj pgBw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=bF+Krm3I8WIUlKdtR2oIJZBTyfmrZZAUf0G6Dt3mXXw=; b=kSZT869Nl6MbwEC1Bls3GhqWiP+z7Q0Uqwzgqo7WmIdQLdnrSLXXzZG/EFY6zbg9yn L0m9Y9lBSlk0zBXSdcDCUN9fxkh6qXecNe2QQ578FG0kKP5ij3F5Wq589ijTzvcWORdK 55k3Cc/zboWemn55AFXYbiUfoRslEM3JgacAzgZVa+UOvpRrH1daogFTkNu+bQPqTv5o ypeZueScAz0NQXkBuwjm6uzcHu7AlVQApCESkB0vARGTy/f5ya6FOYqUf7eED5+Ly4dM xPyGlXt/TqGt4XG5NGkgI3EQHt1GCgBs08Ucj7KxubPJvimBJTn11KaAEeQSPDCeSmw6 9elg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@aepfle.de header.s=strato-dkim-0002 header.b=CtRHCxsY; 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 w26-v6si4465601pgl.340.2018.09.05.23.41.48; Wed, 05 Sep 2018 23:42:04 -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=fail header.i=@aepfle.de header.s=strato-dkim-0002 header.b=CtRHCxsY; 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 S1727672AbeIFLOh (ORCPT + 99 others); Thu, 6 Sep 2018 07:14:37 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.20]:28559 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbeIFLOh (ORCPT ); Thu, 6 Sep 2018 07:14:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1536216040; s=strato-dkim-0002; d=aepfle.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=bF+Krm3I8WIUlKdtR2oIJZBTyfmrZZAUf0G6Dt3mXXw=; b=CtRHCxsYQKKrf5YFk+TEK1PlRq+kzEnW/D3t+FhBD8rR9nM6iWkrzJQGx1NweAp7gj ++PH2xJXRfIeD6u/DQu2aa9PWwnuuSvHqHUnWEHL7HexIj8/7gmeC0bq3GsltDN//Ftm Ypi8dLzwE/KCR8HMNSmcF2otbCJvJEuzQ2H7e++xUVFaenF3l7jmsZDMgxI9CyzMFFMF l1woqxPr0ePVEb+b3/JEUuNP7NmDjKhomlW4wptihOkgMcMvXfXKMbrm7x++ZfVPKg7D IIHSKMJZvxWbkBT87p8S5dTBqmX2x+gTJiNt2wW+uXGrGKEwndwOvoxxun6TFpVL0JGP wm5g== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpIG0mv9coXAgc0/lb4QMstw0mqi/C51hpW50R4vli8caicjAbM" X-RZG-CLASS-ID: mo00 Received: from sender by smtp.strato.de (RZmta 44.0 AUTH) with ESMTPSA id L0862bu866bE8IH (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 6 Sep 2018 08:37:14 +0200 (CEST) From: Olaf Hering To: xen-devel@lists.xenproject.org Cc: Olaf Hering , Boris Ostrovsky , Juergen Gross , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] xen: avoid crash in disable_hotplug_cpu Date: Thu, 6 Sep 2018 08:37:11 +0200 Message-Id: <20180906063712.28639-1-olaf@aepfle.de> X-Mailer: git-send-email 2.16.4 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 The command 'xl vcpu-set 0 0', issued in dom0, will crash dom0: BUG: unable to handle kernel NULL pointer dereference at 00000000000002d8 PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 7 PID: 65 Comm: xenwatch Not tainted 4.19.0-rc2-1.ga9462db-default #1 openSUSE Tumbleweed (unreleased) Hardware name: Intel Corporation S5520UR/S5520UR, BIOS S5500.86B.01.00.0050.050620101605 05/06/2010 RIP: e030:device_offline+0x9/0xb0 Code: 77 24 00 e9 ce fe ff ff 48 8b 13 e9 68 ff ff ff 48 8b 13 e9 29 ff ff ff 48 8b 13 e9 ea fe ff ff 90 66 66 66 66 90 41 54 55 53 87 d8 02 00 00 01 0f 85 88 00 00 00 48 c7 c2 20 09 60 81 31 f6 RSP: e02b:ffffc90040f27e80 EFLAGS: 00010203 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff8801f3800000 RSI: ffffc90040f27e70 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffffffff820e47b3 R09: 0000000000000000 R10: 0000000000007ff0 R11: 0000000000000000 R12: ffffffff822e6d30 R13: dead000000000200 R14: dead000000000100 R15: ffffffff8158b4e0 FS: 00007ffa595158c0(0000) GS:ffff8801f39c0000(0000) knlGS:0000000000000000 CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000002d8 CR3: 00000001d9602000 CR4: 0000000000002660 Call Trace: handle_vcpu_hotplug_event+0xb5/0xc0 xenwatch_thread+0x80/0x140 ? wait_woken+0x80/0x80 kthread+0x112/0x130 ? kthread_create_worker_on_cpu+0x40/0x40 ret_from_fork+0x3a/0x50 This happens because handle_vcpu_hotplug_event is called twice. In the first iteration cpu_present is still true, in the second iteration cpu_present is false which causes get_cpu_device to return NULL. In case of cpu#0, cpu_online is apparently always true. Fix this crash by checking if the cpu can be hotplugged, which is false for a cpu that was just removed. Signed-off-by: Olaf Hering --- drivers/xen/cpu_hotplug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c index d4265c8ebb22..bf1e41ed9d41 100644 --- a/drivers/xen/cpu_hotplug.c +++ b/drivers/xen/cpu_hotplug.c @@ -19,6 +19,8 @@ static void enable_hotplug_cpu(int cpu) static void disable_hotplug_cpu(int cpu) { + if (!cpu_is_hotpluggable(cpu)) + return; if (cpu_online(cpu)) { lock_device_hotplug(); device_offline(get_cpu_device(cpu));