Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1217075ybl; Tue, 13 Aug 2019 09:07:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEFgcldo3AoagZgtbKULotFUmfnhtqWd38/DlDB3moPo+VEPWCcV5sJfLDC9nvCaq7GeOy X-Received: by 2002:a17:90a:9905:: with SMTP id b5mr3010551pjp.70.1565712420163; Tue, 13 Aug 2019 09:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565712420; cv=none; d=google.com; s=arc-20160816; b=V1D9C2FlT6M4vnUlRPCmKnPbG1Tu294o7aFlKpAjIkvyc9A5FKSSsO0BaVKVEvdAHT J+8UEPzhBwzA97l85viJ6bnoIjvQye81hjNfJ8/srB+KJgwcVMPZTcUYZOzucEGcsTMr neiwHnm6s3jI2UlKIRdPeyGsXQW5asxK4wZtIPe6ZMB9uGD7ILdjzKM7T0ghkB2jNsRg NzA5X9qKyUuZSmbB5iGhJDbsCO0wQpQfVLK0ff8HJ+VJbsDx4YWPygcbchje87KA0KS4 fXnKFcoGCOhC1LSgUtqb1K5fbizXBeiksvvI5ZFY/90X9wJlLfUrJTtrm/sZYl6x4L7j 7TIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:subject:cc:to:from:date; bh=T0xsXK4KIPsgEhwojZG7bb3pIEb6oG/sW3q+ygSEQhw=; b=lefT7Oznp09Szq7AkPrF2pIQaowNaETsOIpIAouHCd6rgz+kF10B2m7ENXnwWwwS4o SXeN6xGgdeur+dXMvzuya/XD39a5RyFL9lDOr3g8pM/9V9vHGIQ3LEG7Sz82FPcQIuva TYLxL+58AQSI4NkLGujCXCHepO+NHikXpYTgfcPVuYiUkkKLL2cdXbGoEJrHGPUh8nVu x3jSSyqdrGO1clDZWcZBjnleH5J2vDCusJ7HMLmI4Rk31eCiuxr91xdJ1mpisdA4C9Qn tR+OxccefH/GWbU48ZXHIFeatiVap68Pa9QqCLH68EyOCvluhXv4ON3wAuGEk401+Mqq dK2g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si8054246pff.247.2019.08.13.09.06.44; Tue, 13 Aug 2019 09:07:00 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729600AbfHMO65 (ORCPT + 99 others); Tue, 13 Aug 2019 10:58:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41560 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729586AbfHMO64 (ORCPT ); Tue, 13 Aug 2019 10:58:56 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7DEsiCw150961 for ; Tue, 13 Aug 2019 10:58:55 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ubxy7shcj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Aug 2019 10:58:54 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Aug 2019 15:58:53 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 13 Aug 2019 15:58:50 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7DEwnN552560044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2019 14:58:49 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A592D42045; Tue, 13 Aug 2019 14:58:49 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EF7642041; Tue, 13 Aug 2019 14:58:49 +0000 (GMT) Received: from localhost (unknown [9.152.212.112]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 13 Aug 2019 14:58:49 +0000 (GMT) Date: Tue, 13 Aug 2019 16:58:48 +0200 From: Vasily Gorbik To: Stephen Rothwell , Matthew Garrett , James Morris , Steven Rostedt Cc: Linux Next Mailing List , Linux Kernel Mailing List Subject: [PATCH] tracefs: avoid crash when open callback is not set References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Bot: notify X-TM-AS-GCONF: 00 x-cbid: 19081314-0020-0000-0000-0000035F30A0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19081314-0021-0000-0000-000021B445EC Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-13_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=954 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908130157 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some tracefs files, e.g. tracing/events/syscalls/*/id do not define "open" file operation. Yet commit 757ff7244358 ("tracefs: Restrict tracefs when the kernel is locked down") introduces "open" proxy which unconditionally calls original open callback, which causes kernel crash when the callback is 0. Fix that by simply returning 0, if open callback is not set. Fixes: 757ff7244358 ("tracefs: Restrict tracefs when the kernel is locked down") Signed-off-by: Vasily Gorbik --- fs/tracefs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 12a325fb4cbd..77407632c916 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -43,7 +43,9 @@ static int default_open_file(struct inode *inode, struct file *filp) return ret; real_fops = dentry->d_fsdata; - return real_fops->open(inode, filp); + if (real_fops->open) + return real_fops->open(inode, filp); + return 0; } static ssize_t default_read_file(struct file *file, char __user *buf, -- ⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿ ⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿ ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿ ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿ ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿ ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿