Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2631573img; Sun, 24 Mar 2019 14:18:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMj+N490TS4cU1jZqEKGUAq4vM6gBnhnoMBHSRHHZvcq2r/dSFiH6vadFxcXdDucQghab+ X-Received: by 2002:a17:902:801:: with SMTP id 1mr21039244plk.299.1553462290551; Sun, 24 Mar 2019 14:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553462290; cv=none; d=google.com; s=arc-20160816; b=dKkYvcaq2z4VU4nZKuatXI1xSpuqZAEuOeB55TPskN5vnVnrLEhmAhlUPJRuYDs/fM cebeILr5PCSQWfh73yvGa31qIJVEIbeLekzuaNR1bHJQX9yBDaZr2mWtXFnVkr3XYbQQ ZuNEigzOnBEMBMzkmN+4wIEcGQRHbMPGCOMU/VaVlT/+gBbxMM3xVGJ1PVY0eDvrPKYT IOhW75qsTAuLToAgv/VoEhx9wG/UgSd8qiPKXr0K1knTuMxXoNAHkEYfT1+4A4dzLXKh /6JdxjUIDK4MdOPDw//PQDrtGiu/1+JppGmCjdOqwMeQn2UFWllXGdfNjxG6TIFVmBnC vIsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=URy/gPnArnozf8ozCIf0nNqV6wFIS+j8YQEgP3gm//s=; b=jwwefWvdPwedFKLo5vMXc5R580qfuYidqKUcyDwGtO4WL4yEgxVo09C+smgc4hEuZ5 6NV5ii6fM65w+x1e0o4kIWAsWFO+pdDYIWBKapofjv78TPlA1aaBWy0hbtspoKmQuHwE TvOZV4OxR0rY2vOgqE/8Zp7u+wCeCaeVvlfZDLr2kzhJeqe5Kr43PXbgkxY0FyAAn0ZM xxrxFKzgLzzSqXXQAIKc4xnTHKV3tl8yfiFrj1LCGszwXIOrP3IIGXVFwUl9bbAE+9xy 3iEQt+gtqaEfv8oMWDL1Ohza+OxmtLBH8yoLxyuJg2e9pTMFsXjgfpULsPigqi9EOb1D ZRHw== 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 j2si11453290pgp.167.2019.03.24.14.17.55; Sun, 24 Mar 2019 14:18:10 -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; 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 S1728971AbfCXVQw (ORCPT + 99 others); Sun, 24 Mar 2019 17:16:52 -0400 Received: from terminus.zytor.com ([198.137.202.136]:42161 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726743AbfCXVQv (ORCPT ); Sun, 24 Mar 2019 17:16:51 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x2OLGknt1635524 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 24 Mar 2019 14:16:46 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x2OLGjIX1635521; Sun, 24 Mar 2019 14:16:45 -0700 Date: Sun, 24 Mar 2019 14:16:45 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Prasad Sodagudi Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, psodagud@codeaurora.org, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, psodagud@codeaurora.org, hpa@zytor.com, mingo@kernel.org In-Reply-To: <1553439424-6529-1-git-send-email-psodagud@codeaurora.org> References: <1553439424-6529-1-git-send-email-psodagud@codeaurora.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq: Prevent use-after-free and work list corruption Git-Commit-ID: 59c39840f5abf4a71e1810a8da71aaccd6c17d26 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 59c39840f5abf4a71e1810a8da71aaccd6c17d26 Gitweb: https://git.kernel.org/tip/59c39840f5abf4a71e1810a8da71aaccd6c17d26 Author: Prasad Sodagudi AuthorDate: Sun, 24 Mar 2019 07:57:04 -0700 Committer: Thomas Gleixner CommitDate: Sun, 24 Mar 2019 22:13:17 +0100 genirq: Prevent use-after-free and work list corruption When irq_set_affinity_notifier() replaces the notifier, then the reference count on the old notifier is dropped which causes it to be freed. But nothing ensures that the old notifier is not longer queued in the work list. If it is queued this results in a use after free and possibly in work list corruption. Ensure that the work is canceled before the reference is dropped. Signed-off-by: Prasad Sodagudi Signed-off-by: Thomas Gleixner Cc: marc.zyngier@arm.com Link: https://lkml.kernel.org/r/1553439424-6529-1-git-send-email-psodagud@codeaurora.org --- kernel/irq/manage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 1401afa0d58a..53a081392115 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -357,8 +357,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) desc->affinity_notify = notify; raw_spin_unlock_irqrestore(&desc->lock, flags); - if (old_notify) + if (old_notify) { + cancel_work_sync(&old_notify->work); kref_put(&old_notify->kref, old_notify->release); + } return 0; }