Received: by 10.223.185.111 with SMTP id b44csp917354wrg; Fri, 9 Mar 2018 16:49:18 -0800 (PST) X-Google-Smtp-Source: AG47ELtTRXbTZFXj08hh8wmm0WQQOIceADkDWE20Jq5HZOEYBJJRryCQSbV+z0DndbisW/6kpTPh X-Received: by 2002:a17:902:32a2:: with SMTP id z31-v6mr392343plb.32.1520642958026; Fri, 09 Mar 2018 16:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642957; cv=none; d=google.com; s=arc-20160816; b=ninH4srslT8fYTgUPcShUFT58qQwaGt9VrrESmDXi9GWQdb+Cpy9qx3avyzncL5yIk 7kVZIBdREUfBcI0BrdsmEmpAB4AVQIEauQanmOqf2R/9RNp9x3B+T+ktHLF/XyltwOaJ P8ar9Ig05Ks2An/Am52yxEsSwLU/ASG++dALvES41SoaF4sB/4sBLYbIsqvpuzgRJHdx +5kWCo16wqo/qC2OT2oaHQ9zaodxf/hRITbKnngy+bOgpWkpEtG21ob+0Q3Of6D+9d5z Q5zEk6hGJAI3pHgYosGN55Hbfvbyp1LZ6K2PVi3NpfssoDK7okiuIlhvSWFgmqH9mgSL sUWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0UF01T9h9FkYMj52e2fY7ZoofrR15b85ZLMS0kynsnI=; b=TBFRhDd1SG38Ybfbg97J39guqd7YC/inkj1g6+eCszwh+NmYe7sGf/0nSYr7dhaOpt GKR9JWJzsfvdkqTgQiQyf5K08h7voWuezmjowMzR89cLEsF8t2Xmzb1RdfTSAeQZn9+Q GwaRNC+UAgiDR/KS+j20W+y93Z1pIZfhofrNhhGIVkJ1Hx+4JAW64qroOAl9woZzqz0c NQs4jdda55RXEs+elD4Dult8iR412P/34zP4Y06LZ5q8Nvf/L1Vi7vjo0fBbrHOh4m90 vMhETjTkEG2p17D6bZ/lpxeuwkNA4aes1M5IqWxhj7oKOmvWb8m2a/NFsCyYJoWrQVGB A3vA== 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 be7-v6si1766225plb.201.2018.03.09.16.49.04; Fri, 09 Mar 2018 16:49:17 -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; 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 S933162AbeCJATu (ORCPT + 99 others); Fri, 9 Mar 2018 19:19:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38824 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933126AbeCJATs (ORCPT ); Fri, 9 Mar 2018 19:19:48 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4E331F4D; Sat, 10 Mar 2018 00:19:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Hutchings , Thomas Gleixner Subject: [PATCH 4.4 14/36] x86/apic/vector: Handle legacy irq data correctly Date: Fri, 9 Mar 2018 16:18:30 -0800 Message-Id: <20180310001808.021236165@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001807.213987241@linuxfoundation.org> References: <20180310001807.213987241@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner The backport of upstream commit 45d55e7bac40 ("x86/apic/vector: Fix off by one in error path") missed to fixup the legacy interrupt data which is not longer available upstream. Handle legacy irq data correctly by clearing the legacy storage to prevent use after free. Fixes: 7fd133539289 ("x86/apic/vector: Fix off by one in error path") - 4.4.y Fixes: c557481a9491 ("x86/apic/vector: Fix off by one in error path") - 4.9.y Reported-by: Ben Hutchings Signed-off-by: Thomas Gleixner Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/apic/vector.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -91,8 +91,12 @@ out_data: return NULL; } -static void free_apic_chip_data(struct apic_chip_data *data) +static void free_apic_chip_data(unsigned int virq, struct apic_chip_data *data) { +#ifdef CONFIG_X86_IO_APIC + if (virq < nr_legacy_irqs()) + legacy_irq_data[virq] = NULL; +#endif if (data) { free_cpumask_var(data->domain); free_cpumask_var(data->old_domain); @@ -316,11 +320,7 @@ static void x86_vector_free_irqs(struct apic_data = irq_data->chip_data; irq_domain_reset_irq_data(irq_data); raw_spin_unlock_irqrestore(&vector_lock, flags); - free_apic_chip_data(apic_data); -#ifdef CONFIG_X86_IO_APIC - if (virq + i < nr_legacy_irqs()) - legacy_irq_data[virq + i] = NULL; -#endif + free_apic_chip_data(virq + i, apic_data); } } } @@ -361,7 +361,7 @@ static int x86_vector_alloc_irqs(struct err = assign_irq_vector_policy(virq + i, node, data, info); if (err) { irq_data->chip_data = NULL; - free_apic_chip_data(data); + free_apic_chip_data(virq + i, data); goto error; } }