Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2472286pxj; Mon, 10 May 2021 03:57:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWq+f1LFTv7EOogT1oi3ZAHnNB/AtsQUHIXlxF2T2pao75Ar5e7P9bhsppUP6nymoKpToo X-Received: by 2002:a02:9505:: with SMTP id y5mr20882329jah.27.1620644231228; Mon, 10 May 2021 03:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644231; cv=none; d=google.com; s=arc-20160816; b=OO9xnqqjQfXqF6WA2CzIS4sp10NZpd5IBypwybM5JGynNDxxHkwdf3XUJuk8JDlFRx PMHaRN+bKWufX6RdoZ3wOd7iCFF5E9fD64Rao+w2K1shgt0jkbXc2MzMDQtcF5GpbT0X W0YuNKu/Pxy/QSYhc7tD1n2F4IGzRStj5V0xgznljlMzpmL4QaBNaIg5sSrDgjGPmilq 80lpkzSfzlYQcm9zAvkXsYueHsPMeGqLKUt3fhcGDb53qsKdG8Z4m6u6U0AFC5SgAtJw 7HjSkb0h7OS4+gkYxkoYwIkHj2kFqNvn815g7w+krLTcmZrIMOb01eINJM15XyTX2hPB BgeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8xG+RnLGvVekeehmIwpfE7j3uGB3eygjuyzmLB7pMAM=; b=orAw9dYAN7YKy4SHa4IShj4wTUDdbi+CGThlUAChguC4Ranr/ikWfJc8L6XC0jYUDA Rx0WMzYf1aLdbiaAIECT37Di1SJWd2mOfo6+te7FWbo/xfGjNWifvHGIkvWvPOsKf+JX glr1ywWim6Zb2MKN3IKdadXA8lbm2Fg7FKFW9+t5xMdZjtp86mW6LDj6iV9ryBqM5WPX FTI0BlPqWSWyP3KSQH8eVyP/vAHQHzVUGS7br8/wCyIZOUTb7VYZfdRayqVAmbnDooMc qCgF/KWAt3rUsxkgJjN7sI9Jc6Ag6HKQ2G/xVgkD8GEfZqDnZCDI33x0Gr9TCIE7Jv/f 53SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="kK/X/Orj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si18670437iot.35.2021.05.10.03.56.59; Mon, 10 May 2021 03:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="kK/X/Orj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232897AbhEJKyD (ORCPT + 99 others); Mon, 10 May 2021 06:54:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:50010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231690AbhEJKmn (ORCPT ); Mon, 10 May 2021 06:42:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D64561979; Mon, 10 May 2021 10:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642763; bh=8wWYywvsgL4U0PXgBM942fh46+DjDg2z/pPiL1OVAWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kK/X/Orjd439hjizdI9yG7/cXfj8fbIJXVYJa8jFcUbF2yfVldyI7MdVFfHIPq154 0T3mBazkaBF3qXNzy3R5F59yXwUMn7PCWAxjTIB6Rv++OyX6G7esIlHK/M0Gwwcbgb aaedmAohQqtOgdqzHJb194s7XPWePJVN1ryQHVd0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugene Korenevsky , Steve French Subject: [PATCH 5.10 040/299] cifs: fix out-of-bound memory access when calling smb3_notify() at mount point Date: Mon, 10 May 2021 12:17:17 +0200 Message-Id: <20210510102006.172637025@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eugene Korenevsky commit a637f4ae037e1e0604ac008564934d63261a8fd1 upstream. If smb3_notify() is called at mount point of CIFS, build_path_from_dentry() returns the pointer to kmalloc-ed memory with terminating zero (this is empty FileName to be passed to SMB2 CREATE request). This pointer is assigned to the `path` variable. Then `path + 1` (to skip first backslash symbol) is passed to cifs_convert_path_to_utf16(). This is incorrect for empty path and causes out-of-bound memory access. Get rid of this "increase by one". cifs_convert_path_to_utf16() already contains the check for leading backslash in the path. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212693 CC: # v5.6+ Signed-off-by: Eugene Korenevsky Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2174,7 +2174,7 @@ smb3_notify(const unsigned int xid, stru cifs_sb = CIFS_SB(inode->i_sb); - utf16_path = cifs_convert_path_to_utf16(path + 1, cifs_sb); + utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); if (utf16_path == NULL) { rc = -ENOMEM; goto notify_exit;