Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2673952ybl; Thu, 29 Aug 2019 11:17:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmjZLy5a/fVvW39r0Vib8+LDKVHhhUemueVFZLmhlOZhpi6KHMHxLtxvj94wSq6qaIr2Pu X-Received: by 2002:a63:48c:: with SMTP id 134mr9694713pge.386.1567102652940; Thu, 29 Aug 2019 11:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567102652; cv=none; d=google.com; s=arc-20160816; b=GZfRhlRHg6Tf+xF6ciHzFJZEIfaCNvUVxVyaQik9tHYtrhSVy9+mxVoBJPXTaWTcEn mRjLyTmPFQVVos1obKZplB9BBrAhaaSscvI3Rw6rZvZHqMNkaUk5AKUv7zitVPRJ98F/ op1KrMSwrFB6SowKIZmxG1/ITKwHyltZIgOs5RL7+zN0x4IyN9Y6GDpNQ/qE2jIPCU04 vwB5lQY0FopAvr/enw0wK9172KWh/qfJd794VOEyqbTlPv+1tQHMWbzXeykOxVu6d9Fw OtGW8p/HMVGq421oNx/65dOnWQET3MjoYCWn5RZHfIXNqA2cwg++3vW0+evAfOMjxHa0 v8cg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LSWKzoQQPipeo9giFDcZZZcYft+mY5QE0lyyytejCX4=; b=mS/yzVF+pc7Vkdp1G5e4/0LsUkFn76um0DtIOSNgnGJ2h+wi9OnX1RzSnVs/+KEw13 0Ult16HfOmQ0JCjYLFd1vOXzTI9GO9zXlWYvM+EPxZxBk0tRsPCNViXp8f5Ex6z9ZVMG TlZMz1Jlv7GVVe4w04xxjVq891ZzGus8OU8cd70YLmpD66L7qzywt1b98hMlcCQRGCKi AV6TjFAhOa92vTNY23V2y4PRwFA8M+sByYGWuUPCXwR6rwFB5d+Q275RtLHrgXYKiHK7 fCoK8YEQUgodK+EpdASSsp1A4EPTFufUNM2c+EwTYuk3Qq7kTRupFENq2RFLTSxenvX/ Boow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c01ddU3j; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si2833487pgq.459.2019.08.29.11.17.17; Thu, 29 Aug 2019 11:17:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=c01ddU3j; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729386AbfH2SPi (ORCPT + 99 others); Thu, 29 Aug 2019 14:15:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:57354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729359AbfH2SPh (ORCPT ); Thu, 29 Aug 2019 14:15:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E59A72342B; Thu, 29 Aug 2019 18:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102536; bh=dVA703rK6IxI1rxx+YY4+dmvvsctabIC5SH1lxPtYk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c01ddU3jx7RgTp3wkQ15q0qg8czrN6kjezGq1bLpOcUGoOpjQ5JcnXaXzf4JxADKH 3dW6PSIwSx5rHN/V8aPfIBl/BJYXlTbOCpmkk6v3Nb5AFWIc0vdCUvDpRfqP8l95GU 4OIBm7YsNd67yyvEeyEbsF2bMmCpvXFSgSiSoVNk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marc Dionne , David Howells , Sasha Levin , linux-afs@lists.infradead.org Subject: [PATCH AUTOSEL 5.2 71/76] afs: Fix possible oops in afs_lookup trace event Date: Thu, 29 Aug 2019 14:13:06 -0400 Message-Id: <20190829181311.7562-71-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Dionne [ Upstream commit c4c613ff08d92e72bf64a65ec35a2c3aa1cfcd06 ] The afs_lookup trace event can cause the following: [ 216.576777] BUG: kernel NULL pointer dereference, address: 000000000000023b [ 216.576803] #PF: supervisor read access in kernel mode [ 216.576813] #PF: error_code(0x0000) - not-present page ... [ 216.576913] RIP: 0010:trace_event_raw_event_afs_lookup+0x9e/0x1c0 [kafs] If the inode from afs_do_lookup() is an error other than ENOENT, or if it is ENOENT and afs_try_auto_mntpt() returns an error, the trace event will try to dereference the error pointer as a valid pointer. Use IS_ERR_OR_NULL to only pass a valid pointer for the trace, or NULL. Ideally the trace would include the error value, but for now just avoid the oops. Fixes: 80548b03991f ("afs: Add more tracepoints") Signed-off-by: Marc Dionne Signed-off-by: David Howells Signed-off-by: Sasha Levin --- fs/afs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index da9563d62b327..c50cc3f6f4553 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -952,7 +952,8 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, inode ? AFS_FS_I(inode) : NULL); } else { trace_afs_lookup(dvnode, &dentry->d_name, - inode ? AFS_FS_I(inode) : NULL); + IS_ERR_OR_NULL(inode) ? NULL + : AFS_FS_I(inode)); } return d; } -- 2.20.1