Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3636711imu; Mon, 28 Jan 2019 08:12:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN72tKVxUHXkyYbfvw9Td333xgjPrPnrDXSNW3Nq0qk4BLOZ2c91at8wOmpx2+jEnvQTUDot X-Received: by 2002:a63:1444:: with SMTP id 4mr20540407pgu.430.1548691975077; Mon, 28 Jan 2019 08:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691975; cv=none; d=google.com; s=arc-20160816; b=t3XtUQMdCp9RJ9KVe/KVVYONw76sE2GmVfSkzsIOcV12qsDI8cmwy1ThYGli0nu7iU xvu/56iAzwwl8HOzhSjpItgPRHN2iOpCEKEKvvhbslGqKcvM4oNf6n8e70QdV2LucjfL UcbBbzKki938+hWu+97kviWCMbFZpzUNL22eoh6NSXTc+C0QKs+UwUXuHrBD7SL5H+4p ZkRvxfpw92J/jXwZhyjlcgHtb7AMX8T+FXnPrT/nzsfinw8YEq1XZy125TbnipFGeUF/ F/Xw9R1SCdLejdOyM6WYJr+gtOud0PUwDkPIaDB/Km6j9/cs7Q85EBRz9ac1J4W2RiF5 40Sg== 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=XBSgzarDcyOMfCo6MizQ/m8v2Kqvg9AmcswEjmYPosk=; b=GZxDrlbdMbfCdRaETjdEIbTZDD982YToiYy4tTqHOVPVJ+JSdcEvhbA72nR5b6o5hy eTeLdcVpWk7yBXaKVnb5SoV/zm2O8UAjeY8z4vmSWInnCrqBDayO2P50n33Lhvr77yBQ 6mRX9a2DpwmTI0CWKYJc6EhIq31A3WPxJdyHCg3dCZ8VTzJl/oQHcrBh3GhooLd0inEI ezKOwDk3eYbyAnf5Rmh0MZ85RKc65Da6SfGh351Q1yiec7P9A2I4QmVnxOvFH8DeS7NY AycNkMmpqD566i4kO3/eb7TlWRDJZm2xiYfW1j0kP+OLe/3rsM9SWciEpF5oJsUX1nFK TB3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOYTJW+C; 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 x73si11638519pfk.53.2019.01.28.08.12.40; Mon, 28 Jan 2019 08:12:55 -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=@kernel.org header.s=default header.b=YOYTJW+C; 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 S1732767AbfA1QKU (ORCPT + 99 others); Mon, 28 Jan 2019 11:10:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:35928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732747AbfA1QKP (ORCPT ); Mon, 28 Jan 2019 11:10:15 -0500 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 5EDB62184D; Mon, 28 Jan 2019 16:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691814; bh=yG1I47SHAW1Y9veuNv5imVcFdG2h60Ym3uH0MJ8ZrW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOYTJW+CFUAZOm4OQWpJBOpPUfdy6ph+oNPkilAYTkegamU6l+PKkhc9l8Jy051AY PdZQSlA3td6DdtQva2wdWUzxYxYaZ39SHUXFjpMuKQv3jaiDnYzAW0lonWeIqcGbn6 1sYD2jf2DXXfQcD5+lyreYMt/+DSxc4/Pr+iWcU4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ronnie Sahlberg , Steve French , Sasha Levin , linux-cifs@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 226/258] cifs: check ntwrk_buf_start for NULL before dereferencing it Date: Mon, 28 Jan 2019 10:58:52 -0500 Message-Id: <20190128155924.51521-226-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 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: Ronnie Sahlberg [ Upstream commit 59a63e479ce36a3f24444c3a36efe82b78e4a8e0 ] RHBZ: 1021460 There is an issue where when multiple threads open/close the same directory ntwrk_buf_start might end up being NULL, causing the call to smbCalcSize later to oops with a NULL deref. The real bug is why this happens and why this can become NULL for an open cfile, which should not be allowed. This patch tries to avoid a oops until the time when we fix the underlying issue. Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/readdir.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index e169e1a5fd35..3925a7bfc74d 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -655,7 +655,14 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos, /* scan and find it */ int i; char *cur_ent; - char *end_of_smb = cfile->srch_inf.ntwrk_buf_start + + char *end_of_smb; + + if (cfile->srch_inf.ntwrk_buf_start == NULL) { + cifs_dbg(VFS, "ntwrk_buf_start is NULL during readdir\n"); + return -EIO; + } + + end_of_smb = cfile->srch_inf.ntwrk_buf_start + server->ops->calc_smb_size( cfile->srch_inf.ntwrk_buf_start, server); -- 2.19.1