Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp303986ybf; Thu, 27 Feb 2020 21:42:40 -0800 (PST) X-Google-Smtp-Source: APXvYqy5fxoMbQzBHtAwEhHaraDnjHnxFSo9hJB8BFq2/d61hbTn46ymFKdb6eBlLqsD+WWk/2Pl X-Received: by 2002:aca:4587:: with SMTP id s129mr1931946oia.124.1582868560271; Thu, 27 Feb 2020 21:42:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582868560; cv=none; d=google.com; s=arc-20160816; b=qbol4P24i7o0z7Xa4TAfa2TxVY+vNyzp5XMtyTGJ3R3mlEco/Y1oHt+oCuoUui8t7o AoqatN+RyuNs1hae6/1YQkiW6C7xlua2GXtaTvXhtxBYdNbVE7kKllIFNcC0tV4RCM6L Vpi4IJD3TpqUa2gHPXqE5FGla0NKeBvRc7fvzcfSqYBjZC8HRxjqnanr9VrC65+qATOG YxW1kXWKopf1NIyG3kLfZa0XuGjeBpcUHT8tlc2jClWGXvpkVQlU25YwoznMzdS1oOsp SgpByuxnOaiAcP7QNRAQ1ysnKANxHfiVRyN5eGjRq7gCSVAD5n0hxaSDdBuTovo9FdxP 3DTg== 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 :content-language:mime-version:user-agent:date:message-id:cc:to :subject:from:dkim-signature; bh=RHqBzSjWYn2Rk3KYgmZDclzprjLz5YbM37KJXpO5Trs=; b=H789mCDLc3I4maQO/2tSiRkm07nE0QXS8WY11TCOYjOhMh1pStje+nO5HCNuo6BCpU t0/eCyscFutQsHajtk7+C3eiARrMWIZjmuibAJHpiJHmwHcKK3p+psXBh9mcKkjLNymY JfQoSv4XC1leemNPzVo6/epX1yMZrGgnbFOqRCwDZaSXgcVjG5ZvmltRYmsbY5lQCh19 eBLbYbdWFBxOkosg79BDDfEKVHiBp+Ah9kcFs4G2ReMYwoZxfC22PqjwLut6j899P8HC vKSJoCd6tCSteXHARgD9pP0ZoD/ziX2JqP6Qjiw9xgDWzP4IGV9N76uG+4ZexBadePiT 3Wyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=ZCnKA+YN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20si947614otf.271.2020.02.27.21.42.28; Thu, 27 Feb 2020 21:42:40 -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=@oracle.com header.s=corp-2020-01-29 header.b=ZCnKA+YN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725970AbgB1FmS (ORCPT + 99 others); Fri, 28 Feb 2020 00:42:18 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:34338 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbgB1FmR (ORCPT ); Fri, 28 Feb 2020 00:42:17 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01S5bbGH179811; Fri, 28 Feb 2020 05:42:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : subject : to : cc : message-id : date : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=RHqBzSjWYn2Rk3KYgmZDclzprjLz5YbM37KJXpO5Trs=; b=ZCnKA+YN14vSW+PRKcYfdi2WyPBgYM3InNRYieTPWiQP9/gn1mFqUsjQi3NiO6PsXcYJ WOwui/JrgHBhNa09R7TxTEy+bEYNgszXcx/exoEB/VIKFD0k/wG9gv46ZEA9iZnJpsqq tOsGxnAEEc2+O86GMO/ryQT4HxKsT33uUV/YtpJeK+VBv5R/lfDCbS4QmA6754Byjh7l XEk1M6S30OiAEEn69ZtoM8vs945uzlXpNnUg/Rws9tgoQnLkqR1kUJRJqLJ56xBvmDvE iUwsT+BAKbw389s4AlVw7GCyXC2vqO5gdAiKCBo0/j/6Qt0SdKVT9FLfej1VdeqMX5x2 0g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2ydcsnrdke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Feb 2020 05:42:06 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01S5aovX074836; Fri, 28 Feb 2020 05:42:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2ydcsebf1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Feb 2020 05:42:05 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01S5g4sp007459; Fri, 28 Feb 2020 05:42:04 GMT Received: from [10.159.136.144] (/10.159.136.144) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 Feb 2020 21:42:04 -0800 From: Joe Jin Subject: [PATCH] genirq/debugfs: add new config option for trigger interrupt from userspace To: Thomas Gleixner , Marc Zyngier , "linux-kernel@vger.kernel.org" Cc: Joe Jin Message-ID: <44a7007d-9624-8ac7-e0ab-fab8bdd39848@oracle.com> Date: Thu, 27 Feb 2020 21:42:02 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9544 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002280049 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9544 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 impostorscore=0 clxscore=1011 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002280049 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 536e2e34bd00 ("genirq/debugfs: Triggering of interrupts from userspace") is allowed developer inject interrupts via irq debugfs, which is very useful during development phase, but on a production system, this is very dangerous, add new config option, developers can enable it as needed instead of enabling it by default when irq debugfs is enabled. Signed-off-by: Joe Jin Cc: Thomas Gleixner Cc: Marc Zyngier --- kernel/irq/Kconfig | 15 +++++++++++++++ kernel/irq/debugfs.c | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index f92d9a687372..00521e896e6c 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -135,6 +135,21 @@ config GENERIC_IRQ_DEBUGFS If you don't know what to do here, say N. +config GENERIC_IRQ_DEBUGFS_INJECT_INT + bool "Allow trigger interrupts from userspace" + depends on DEBUG_FS && GENERIC_IRQ_DEBUGFS + default n + ---help--- + + Allow developers retrigger a (edge-only) interrupt from userspace. + To use this feature: + + echo -n trigger > /sys/kernel/debug/irq/irqs/IRQNUM + + WARNING: This is DANGEROUS, and strictly a debug feature. + + If you don't know what to do here, say N. + endmenu config GENERIC_IRQ_MULTI_HANDLER diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c index a949bd39e343..56db29bc1acf 100644 --- a/kernel/irq/debugfs.c +++ b/kernel/irq/debugfs.c @@ -178,6 +178,7 @@ static int irq_debug_open(struct inode *inode, struct file *file) return single_open(file, irq_debug_show, inode->i_private); } +#ifdef CONFIG_GENERIC_IRQ_DEBUGFS_INJECT_INT static ssize_t irq_debug_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -223,10 +224,13 @@ static ssize_t irq_debug_write(struct file *file, const char __user *user_buf, return count; } +#endif static const struct file_operations dfs_irq_ops = { .open = irq_debug_open, +#ifdef CONFIG_GENERIC_IRQ_DEBUGFS_INJECT_INT .write = irq_debug_write, +#endif .read = seq_read, .llseek = seq_lseek, .release = single_release, @@ -249,8 +253,13 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc) return; sprintf(name, "%d", irq); +#ifdef CONFIG_GENERIC_IRQ_DEBUGFS_INJECT_INT desc->debugfs_file = debugfs_create_file(name, 0644, irq_dir, desc, &dfs_irq_ops); +#else + desc->debugfs_file = debugfs_create_file(name, 0444, irq_dir, desc, + &dfs_irq_ops); +#endif } static int __init irq_debugfs_init(void) -- 2.21.1 (Apple Git-122.3)