Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2752532imj; Mon, 11 Feb 2019 07:59:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IZzRPk596qmQaDLlSqC+PEe7mBj8ESL/96D5n4AqarX6i8SLthM0K2u+2F8V+UlGys8F4jj X-Received: by 2002:a62:2ad6:: with SMTP id q205mr22833246pfq.243.1549900756542; Mon, 11 Feb 2019 07:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900756; cv=none; d=google.com; s=arc-20160816; b=F9kYQekyavuz5LQOX/S0s64fJ4Rcv+H5naapOsSbV41Tf4OLYTH/xbbOTka/HafyI+ E8NOUKmXxp1MomSlyFtYPsnX8zQnppblvjnnB3jfRs73KfTSowCXPQ7pp/0IR2RU0v4B TQ2KP2jsYWbbzLcFzQ0/BROtBkzUGBJImacva+XKvIcrWnOmGBGMU15xgx2hQOhGH8at ZgCdmrIaeoUzj5fR9PtkQAK3yw169i9ZVOIE2tac7Ar739xSUrco00Tdp6Nc/06AkFm0 qCFCBkcB0fmbvBhSi0/fplXkmfU3EN4fXlK2Y2Alc7JCJg7BzkSwuKobEQAY334BNPda nWzw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uZHcnPvv0PBpJhYkHR0RwknJKSZ9NWuGHgVDMR/LvAo=; b=xkQP/L6gB1KleTw1e6hu9S3tRRgLpZAYibSAGtiosu2dTRjW4FKqd7wERdmV506Hjg 7v4owpQfscWkBcZcDpeEhFdwJ0dnqYKVv1LGYzk2rSknQcubC4G6te3R2yj6G4QfHWvs bLq6qvMl6lcsnUD3Mjo6aecSdkNB4kn/Xq9QjZaJzO2Ht/2WVtZNV8rHvPY9rXZB2AR6 rl0ZW4b/3Hmj8kW4MfQdsbn4PmC80PO7jByG9ClHP0ZR/YuzzDGW+yJ/8hMCudpdYSBp 8rse1GhRuFBVyq/stTPZmXvf4tkcygt62nCJaML2Y+WJxqGG0Hr3YGbxrQfluNoPVTG4 PD/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gfc+bSob; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si9927682plk.238.2019.02.11.07.58.59; Mon, 11 Feb 2019 07:59:16 -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=gfc+bSob; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730925AbfBKP6H (ORCPT + 99 others); Mon, 11 Feb 2019 10:58:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:40884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729994AbfBKOdM (ORCPT ); Mon, 11 Feb 2019 09:33:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C521218A3; Mon, 11 Feb 2019 14:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895591; bh=b6d8O255nCXmwJuBRwu4m98qo4PkWhtTo90ihypKWqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gfc+bSobaN9KRFrSJD2MTQsze9KpTVWG2ZSFBd7qYGBRBYHDUYqsiMFrAfI1I4PEH tzDSYvkPpf9bEudLs3zJk2mBSsS/DiR74n9p7YF4VviEedaGvV0P7wf/Si7G8VM1g8 xZ6ZPIoQV7exxgo9Zn3shiRjsKXBh06/bWhBMCoE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Steve French , Sasha Levin Subject: [PATCH 4.20 257/352] cifs: check ntwrk_buf_start for NULL before dereferencing it Date: Mon, 11 Feb 2019 15:18:04 +0100 Message-Id: <20190211141903.431384683@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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