From patchwork Mon Aug 12 00:28:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 11089205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 161AC1399 for ; Mon, 12 Aug 2019 00:28:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EECBE26E3C for ; Mon, 12 Aug 2019 00:28:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF77E27F60; Mon, 12 Aug 2019 00:28:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4B9926E3C for ; Mon, 12 Aug 2019 00:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbfHLA2h (ORCPT ); Sun, 11 Aug 2019 20:28:37 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:36268 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfHLA2h (ORCPT ); Sun, 11 Aug 2019 20:28:37 -0400 Received: from ben by shadbolt.decadent.org.uk with local (Exim 4.89) (envelope-from ) id 1hwyCQ-0006Uw-8J; Mon, 12 Aug 2019 01:28:34 +0100 Date: Mon, 12 Aug 2019 01:28:34 +0100 From: Ben Hutchings To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, Matthew Garrett , Steven Rostedt , Reinhard Karcher , 934304@bugs.debian.org Message-ID: <20190812002833.2zij7tfsqtpvqu3a@decadent.org.uk> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ben@decadent.org.uk Subject: [PATCH] tracefs: Fix potential null dereference in default_file_open() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on shadbolt.decadent.org.uk) Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The "open" operation in struct file_operations is optional, and ftrace_event_id_fops does not set it. In default_file_open(), after all other checks have passed, return 0 if the underlying struct file_operations does not implement open. Fixes: 757ff7244358 ("tracefs: Restrict tracefs when the kernel is …") References: https://bugs.debian.org/934304 Signed-off-by: Ben Hutchings --- fs/tracefs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 34da48036e08..761af8ce4015 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -42,6 +42,8 @@ static int default_open_file(struct inode *inode, struct file *filp) return ret; real_fops = dentry->d_fsdata; + if (!real_fops->open) + return 0; return real_fops->open(inode, filp); }