Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2717873imj; Mon, 11 Feb 2019 07:26:57 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia/wMnDGfNJ+61YWNh+20IVx5kfTrWnNqYjJzAta+iqa3r/UQH9pu6CpEIDM83zln+5uiwA X-Received: by 2002:a17:902:50e3:: with SMTP id c32mr38096138plj.318.1549898817589; Mon, 11 Feb 2019 07:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898817; cv=none; d=google.com; s=arc-20160816; b=vN87sMu7Jeo1RM3ayN+9S7BkFNbWAKwPAsOB0Z7+GZknpm27P4x29eCzOzh+IXOtGm 04yAIXgRtulVB9D35wQSJwrDmuCTWkJaUw9yo9q8PI5AoW65mo5uh6hv2eEODoPRclNT cqg2If3KKo+7Erg61gqNf8h8sqDN6/4aD3OTBL5I37hq7gTtpGtYDkWHoKfr5LPEdc6Z NjWwJ+b+1hwstdsNIrb4XRv0uZIMQOCLUtm50fiY1kWW/RYnRI5scvOcMrirzylEbKsE JSOfI5osIGZ+L1/Iivkuwojv1hwEkzukn4e55LtdUsohfv425NjB+vjs0v3wshSrGngT KBJw== 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=f5iCDQ6R09b/0Bh01IBzemEh83SQ437J8eCEdH1wAlE=; b=VLpqrsu6624SrPjyg/TdXAaakY3Xqj4mjYBB07xwjQA9zSM7RVbI1/jJqj3bYYnMQa 8WMJEX3qC0DlKe7YThV6N7Ha9uqQTwrrU6sqsN81PCunbX82AUDl7fPDb8hAqG1gt28k Qa4YG1gSh7Tupe3qUV95R8xGtN2aI08709qajkjK5GzxNpHGgy7ngdCGS9fvYwInLGi0 qd8thyXItCriRNOkUYaffgoycLiYQQzwRQ2Z1EF5y+4x/374HpUXtBEhhnVnzRt48Wef S2OMEyYrFkSN7UvV7X0AQQhKXqBjhfzZ9RxD6TIcUzXGJ6nMDThQjwawH6Zgx9HDZlMn WONw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E+OnUAs6; 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 g10si10344642plq.371.2019.02.11.07.26.42; Mon, 11 Feb 2019 07:26:57 -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=E+OnUAs6; 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 S2390105AbfBKPBC (ORCPT + 99 others); Mon, 11 Feb 2019 10:01:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:48956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390097AbfBKPA7 (ORCPT ); Mon, 11 Feb 2019 10:00:59 -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 91220222A4; Mon, 11 Feb 2019 15:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897259; bh=nFNLTX0R5C+smZTDbQBKQ6nW982cDG4l+SCvVBFbLL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+OnUAs6BnPvCtllFe/Zr2n48t273jE70WVm/Mk/DqLU3mESoBai6drY/VJWTe/C7 AMPMg2RFlSJTmg4IiQPHubOuztQKJvIm+Yi34RvMM1QpsU6Xpi3dnOtg0V4PJHicpt EyZF1bsfkLhMsug6y9wCWmMO2vI8uvYBrHB7x6Iw= 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.14 142/205] cifs: check ntwrk_buf_start for NULL before dereferencing it Date: Mon, 11 Feb 2019 15:19:00 +0100 Message-Id: <20190211141837.664712281@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 ef24b4527459..68183872bf8b 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); -- 2.19.1