Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1943782ybv; Fri, 14 Feb 2020 08:38:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyrhBxhWBBDb8oy8EEha4iksxSEVoyo2dO9TD1FKgjclh9B6EqSPZmZFo8FjGhM8dlVWQKy X-Received: by 2002:aca:190a:: with SMTP id l10mr2559209oii.56.1581698288759; Fri, 14 Feb 2020 08:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698288; cv=none; d=google.com; s=arc-20160816; b=HEvrTxw9iaX+vu/VbnmyAbthCXi8PIUIb6+JpVRBmD6nZg7wKKGU6UtA6sFRctq5pk x2oynZOKx0qovtlkwROIBLD0b5PGCJ9IxoZosC8rI3zIrVAKD8hFNFV4AmM7a8Jx2rVv XeaGqd10N072I/JIg2IG8zX4Ohum2JXOKuX3tsOgjtnAG9cJRQTSke2NkEH5zQG6ri2q aN88+YHSKKaJlKweR/pZANbkloztLkC/UoLkqvQpWK/QQFbEOkpsPTtsyW4VpeAgkyvH eaJJY3IuHsRc24hCDxlbgIe6elYp85UzzZVYoXXbZWGVadQ9Hhmx0HdHz0uvLKrJ2Qdc sLVw== 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=qD6wXBFQ5WEdKVKLfwzJGQppsSAMKaq9EqpGbnUPzHk=; b=RuI3WoYcPSZIyRRqMCBMFhSo6mDViacS2LVOFsX/9pxJx4EAZ+fAFdirgKmLQ89OP6 9cTKP0Uo3Wj6v3nj/uMJK3VO1ealtGd41q/nM3FOzNvffPkuSAbQXRZR26wyTUm+9b+H R0bMLohAfi7aRNt73V4g3HVREBJ0LaU2sJCdsQg80PfZcfWfBabbgoD5T51l4MeQ92NP F1j5LidgiYe9oYcvefvwP/67Ci2D8eCvh92A6qMNdwsT0G+Xx+8BaAAhZ+3CEbxXn51v OEvA14fVBHAAwwMOpo8PuANs1bVMkUoVDNVAcXAH21do97dAX/GQ2sfSuQhG6aaE42RC CYqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zx6olH03; 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 t7si3002135otl.133.2020.02.14.08.37.56; Fri, 14 Feb 2020 08:38:08 -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=Zx6olH03; 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 S1729595AbgBNQhS (ORCPT + 99 others); Fri, 14 Feb 2020 11:37:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:60522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405758AbgBNQX6 (ORCPT ); Fri, 14 Feb 2020 11:23:58 -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 68D9424787; Fri, 14 Feb 2020 16:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697437; bh=wdqrxYPyjy0I0lxc+ygjYYNq7crfOp6Bd9hVxhogQZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zx6olH03uxUb2VpWuUPa1+aPNKD+fLB7ndU9WnDrn7KJ7tV2oz5+MMNUqo8pI/Y5T x1iI4D53PD/lTFCQrtdrfzHmR9FdY9cbaZC7PxWrkre1Oc12kegT0SmS2SksZJtLbV tYptqHtYhdo/+iY9fnfUcLYfVLa+EPE+VsR6xSgE= 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, samba-technical@lists.samba.org Subject: [PATCH AUTOSEL 4.9 123/141] cifs: fix NULL dereference in match_prepath Date: Fri, 14 Feb 2020 11:21:03 -0500 Message-Id: <20200214162122.19794-123-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-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: Ronnie Sahlberg [ Upstream commit fe1292686333d1dadaf84091f585ee903b9ddb84 ] RHBZ: 1760879 Fix an oops in match_prepath() by making sure that the prepath string is not NULL before we pass it into strcmp(). This is similar to other checks we make for example in cifs_root_iget() Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 751bdde6515d5..961fcb40183a4 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2927,8 +2927,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data) { struct cifs_sb_info *old = CIFS_SB(sb); struct cifs_sb_info *new = mnt_data->cifs_sb; - bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH; - bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH; + bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) && + old->prepath; + bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) && + new->prepath; if (old_set && new_set && !strcmp(new->prepath, old->prepath)) return 1; -- 2.20.1