Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp55802imu; Thu, 8 Nov 2018 14:42:24 -0800 (PST) X-Google-Smtp-Source: AJdET5fngerJd1Q4Fx+3XkGdP/iH5HgJu/Ez57W5OTeyg0ymAWdpyoUVuv385/u8nWhvIxwcKbC5 X-Received: by 2002:a63:9041:: with SMTP id a62mr5240588pge.163.1541716944273; Thu, 08 Nov 2018 14:42:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716944; cv=none; d=google.com; s=arc-20160816; b=vaWU077Ya4K7XcstYOYy21dMEeXNlh1N1T9vz64GznpGAyTWSB9r3YqXUQP5dzjO22 pP9KgBq/Fr5Iqqmah6DEJLkg9jhpxcGmRXge2c6l59C8QHX/CcoTZiYyAH8j6VravKTy kzcveLy0IHZqXV3doIaoQLmDv30Y8cqGBSKWxAsZU/6wI/6gB0uitvaEWi5xHhqem2Pc 146NQ+dIME2ihdNpT4f7BXeTJ+9yQpOm/u1S3ilIkyno9NjXZOPynKIKG2ttFxdzc7bT 6dlDlcnT4QihrxMCnNcO/5GBtUIh9NhwnVYJyZHUrZ4f1bYmpCWBZklDB/ZbntlgUHhB sPwg== 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=I8V77zobWWp8uKyn+6aJLsyN5MSWZhH4g5Mwvch5j6I=; b=YmXMO8iEV0SG5zSceuSFKsFoiBJjAR8otOrlLTlv01K/0cH4yfYp2bwagzBxPnS/0n orL0/pxlSG54XyXxWNWf5lnU/Msy+DkU/FRajE+zJI4Ix/klG4gysfsxrvbLlR9HJPbj w/8lfKd+K36tpSOzj8jWstydgqC4cjz9yqoErHqxLXbKL0HIpof3OuDKc8s4szMYCjZ1 7c1x24FcHJ8nCi9RBcJnCmE35jxYYrVoKf03YvqN4Qc/xQQmxjIkqsI49z9/l8S2D8sz ni7V7IeFMTadeJ25lh6eO1RzDtOjL7rp8FEiWgLmbS0BdtW8B846jLXoRdv3Bsb+PQOE nffw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=11o4srqO; 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 m20si4758650pgk.323.2018.11.08.14.42.08; Thu, 08 Nov 2018 14:42:24 -0800 (PST) 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=11o4srqO; 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 S1729119AbeKIHdr (ORCPT + 99 others); Fri, 9 Nov 2018 02:33:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:49960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbeKIHdp (ORCPT ); Fri, 9 Nov 2018 02:33:45 -0500 Received: from localhost (unknown [208.72.13.198]) (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 03E18214DE; Thu, 8 Nov 2018 21:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714178; bh=lmtMqJarJlFcgFfPaSh+62K8u/B9PoHzEoNJURyp4pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=11o4srqO1qTHibMAc2Pgg5WcAFsQU3ynNsFKLRvs8pakVE5ZGxC4l9DZOCu6oxt8n eoGdqEG4Z3Ef/bFZ9rQQA9UnUKbLvX27SWdWZS8YJznN6NBSqtnjl+r0O+E9uGYPng 28zoaUBw4UKiPQbcQsQb9HL+S1yWG9gwGNkkpVlE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel , "Peter Zijlstra (Intel)" , Jiang Liu , "H. Peter Anvin" , Jan Beulich , "K. Y. Srinivasan" , Linus Torvalds , Prarit Bhargava , Rasmus Villemoes , Yinghai Lu , alnovak@suse.com, joro@8bytes.org, Ingo Molnar , Sasha Levin Subject: [PATCH 3.18 085/144] x86/irq: Check for valid irq descriptor in check_irq_vectors_for_cpu_disable() Date: Thu, 8 Nov 2018 13:50:56 -0800 Message-Id: <20181108215101.560811707@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d97eb8966c91f2c9d05f0a22eb89ed5b76d966d1 ] When an interrupt is migrated away from a cpu it will stay in its vector_irq array until smp_irq_move_cleanup_interrupt succeeded. The cfg->move_in_progress flag is cleared already when the IPI was sent. When the interrupt is destroyed after migration its 'struct irq_desc' is freed and the vector_irq arrays are cleaned up. But since cfg->move_in_progress is already 0 the references at cpus before the last migration will not be cleared. So this would leave a reference to an already destroyed irq alive. When the cpu is taken down at this point, the check_irq_vectors_for_cpu_disable() function finds a valid irq number in the vector_irq array, but gets NULL for its descriptor and dereferences it, causing a kernel panic. This has been observed on real systems at shutdown. Add a check to check_irq_vectors_for_cpu_disable() for a valid 'struct irq_desc' to prevent this issue. Signed-off-by: Joerg Roedel Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Jiang Liu Cc: H. Peter Anvin Cc: Jan Beulich Cc: K. Y. Srinivasan Cc: Linus Torvalds Cc: Prarit Bhargava Cc: Rasmus Villemoes Cc: Yinghai Lu Cc: alnovak@suse.com Cc: joro@8bytes.org Link: http://lkml.kernel.org/r/20150204132754.GA10078@suse.de Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/kernel/irq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 37907756fc41..1d6e2946a3da 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -302,6 +302,9 @@ int check_irq_vectors_for_cpu_disable(void) irq = __this_cpu_read(vector_irq[vector]); if (irq >= 0) { desc = irq_to_desc(irq); + if (!desc) + continue; + data = irq_desc_get_irq_data(desc); cpumask_copy(&affinity_new, data->affinity); cpu_clear(this_cpu, affinity_new); -- 2.17.1