Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2495908pxj; Mon, 10 May 2021 04:30:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAX9lU9mhZmvbHygvPX9yTmmVMAwX/b7Gn4Jgds0qzGlIittv8jy8KdH1fX2bxVDEc+bN6 X-Received: by 2002:a17:907:960b:: with SMTP id gb11mr24875520ejc.123.1620646244409; Mon, 10 May 2021 04:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620646244; cv=none; d=google.com; s=arc-20160816; b=M4Owqu+QZo94cuZ3rBBqhEJ6+4wAsH+dq6s7JrlrV8ISSUX8ziTGnyKh5+ZCItdPXE ztXFv/MyE7t9/7HklP6PrKJtcIg4fWe+9bn5v7NNs2EWr0hsDinYg7uy1FVhC9JtLzer /EzA59jHtmY0jDEuxU5SPGjIuOYYDdQUcZzTyZPOyoYJNjD0kUbKbSRvs7D073h25VEU InYtWMRYyF+vd/pFOgppXw9wqzi2P5rqkr04n2ESAbNlmjKF/oCdblxDAOnP4ZcDmgFE ixx/xp8j3IgEgCUC8z7xDJWpLh/nzEJIeK0oWapRrQk4hm1oWS4tYip7mrAb9hPlydkg jXuA== 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=9HOXeIj3FHgKmRIaO3IMy6Xmc+sQ7rocyRvsprabEqE=; b=EDUqUMkB0UDuSqu5SwcPQ+9t3u5TuA+h/tKuv4A5jN6IjRIweh9ywGCmrbkO72gCkF wYhnbP0Y4uz8ZhJk9DTXjDKhVMqoQKDDa888RJMYjWNngQXPlcK7mOAqd3L41QaJQrrL 7rv5sMCJOQLDOd4pD6j4smEvFkwS47Lx7WHJb9LTB7w6/H6Q6NKt+Z2osmT7sDrr4qQ0 NZVa6wu/zcSM+1q6oPQsy0Oz+b68FkTqRMEQcSbfUAyoONIoe97drtVRjMDLvlSlIDWX LqCbJdcfcHhFjrU+Ssv3PDwZbJLwVSDWSCwEoLjok3AZ3Lud2A0p8pzGDTxqKHCWWPy5 oOhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vM4mxqaC; 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 gx23si12064247ejb.47.2021.05.10.04.30.20; Mon, 10 May 2021 04:30:44 -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=vM4mxqaC; 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 S239228AbhEJL0A (ORCPT + 99 others); Mon, 10 May 2021 07:26:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:53006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234375AbhEJK4S (ORCPT ); Mon, 10 May 2021 06:56:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE8E56198C; Mon, 10 May 2021 10:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643529; bh=Z3zbLFrt1kd0pnZjb2bGHBwq1sjxWyOmHIxibJATDVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vM4mxqaCMPy5cZVgl4N0RDIabfsWpluhUWdhY2q7KOH+ccqPkAQlf3CMrGXQruJYR vaDqLjp/rtayEUxEDRprYz8/vMmY3haAPcDFA5I50y3p91sEBXEp4hd8zZZtkTQ+Kc zG7VOw+IvF3EkBL/tJAgU2NdDBt+12WP5E07eqA8= 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.11 050/342] cifs: fix out-of-bound memory access when calling smb3_notify() at mount point Date: Mon, 10 May 2021 12:17:20 +0200 Message-Id: <20210510102011.782444451@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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 @@ -2201,7 +2201,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;