Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp36421imu; Tue, 15 Jan 2019 16:03:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN6EBLRCu1B6ayP5OHjtAsQkfpxIn3XOJ8rUeFWyLrYYAjNw5StO54uoPi4hQTFCASgAZ9+L X-Received: by 2002:a63:db48:: with SMTP id x8mr5917484pgi.365.1547596987628; Tue, 15 Jan 2019 16:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547596987; cv=none; d=google.com; s=arc-20160816; b=o5smaQ+oyMOELexRl+Yp6xF5G/Pocf+3Pm2oWcZopJM3yMQH8dSTV2vWcESk8lRRhh FbkP7uC0YZkB+7sJ9HbAcchdscgZoxWY1Z+EhU6xJ83S2XrO7I5kKInTujskU1QKPTZZ doC11be+FsccbBBPOTFFFHZ4JTBxeq8wML4hpjtLDgXZcc2PTGjZtMdCO0jdcR/tvpVx TGs0MCqwsOuPC4BPjZAP3TfATsk1iewKWSBz9NjFp5+4rlA5mbeS2L7kn9+gFKtP8zJ0 0Gkik2i8uI05U9umeXVedzk8iUrd8a0ZJDfifffaXiPlkUvQJ0ekmYk5gk+JzX7hHpiU 2ECw== 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=L5Bzw1QxtQyEayJYoM3kmKbayaxl5xN4PLR14pVM71I=; b=0lqTfTD5u8I4+GDdil3BgKei8/H7S86khmhJjJQdCIc0VIoyxPX3btFnwiBfQBrySg KT5Msgta9jsvFGA68nIXiUNM9jP+f+1lVpQgM43Wsl0SXF+8uBV4wEMxdjsyYfaFILpw /o2Z9x19WStD6OxHH2K3Uln2OvLy0ene3bdOanz2fA4h03Jpbj2+XOa/RT9BgsQ124bL OzZZswgyEASccpTIK1o/aM8LvZrzxY5R+maTI9qGxW40FohJefxPRTIf/LgAtJoa0vpi QhQUCKhlgvztHXFPURp7I4dGMtMIao02Pjhtag2QuehfoPL51TM6FzFh9Rxc7O3Rrtxv KhTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1AylTMYH; 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 c11si4014501pgj.255.2019.01.15.16.02.44; Tue, 15 Jan 2019 16:03:07 -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=1AylTMYH; 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 S1731007AbfAOQxG (ORCPT + 99 others); Tue, 15 Jan 2019 11:53:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:33448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387417AbfAOQnz (ORCPT ); Tue, 15 Jan 2019 11:43:55 -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 4A6F72054F; Tue, 15 Jan 2019 16:43:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570634; bh=5ncq41RYGvHr9PvVIHoGKoKImc2WcR6TlPwNKqVhmVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1AylTMYHPfZAqWUOO0z/aM7tbiNqo+L4z1FE9eWyjSqWUJq1sOxpH2gSU4oRJhdng VEXQ9HkyTwBjljU3c1L8mYiFxLEoi+N5MqIhRg2vtt1nF/4r4NZUDgwcCVm4uMCqnc 81GDC5SmnHcZVSIVEsut1XE5RlQfmMJUZxGfYYhQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ross Lagerwall , Steve French Subject: [PATCH 4.20 16/57] cifs: Fix potential OOB access of lock element array Date: Tue, 15 Jan 2019 17:35:57 +0100 Message-Id: <20190115154911.634403832@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154910.734892368@linuxfoundation.org> References: <20190115154910.734892368@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. ------------------ From: Ross Lagerwall commit b9a74cde94957d82003fb9f7ab4777938ca851cd upstream. If maxBuf is small but non-zero, it could result in a zero sized lock element array which we would then try and access OOB. Signed-off-by: Ross Lagerwall Signed-off-by: Steve French CC: Stable Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 8 ++++---- fs/cifs/smb2file.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1131,10 +1131,10 @@ cifs_push_mandatory_locks(struct cifsFil /* * Accessing maxBuf is racy with cifs_reconnect - need to store value - * and check it for zero before using. + * and check it before using. */ max_buf = tcon->ses->server->maxBuf; - if (!max_buf) { + if (max_buf < (sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE))) { free_xid(xid); return -EINVAL; } @@ -1471,10 +1471,10 @@ cifs_unlock_range(struct cifsFileInfo *c /* * Accessing maxBuf is racy with cifs_reconnect - need to store value - * and check it for zero before using. + * and check it before using. */ max_buf = tcon->ses->server->maxBuf; - if (!max_buf) + if (max_buf < (sizeof(struct smb_hdr) + sizeof(LOCKING_ANDX_RANGE))) return -EINVAL; max_num = (max_buf - sizeof(struct smb_hdr)) / --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -122,10 +122,10 @@ smb2_unlock_range(struct cifsFileInfo *c /* * Accessing maxBuf is racy with cifs_reconnect - need to store value - * and check it for zero before using. + * and check it before using. */ max_buf = tcon->ses->server->maxBuf; - if (!max_buf) + if (max_buf < sizeof(struct smb2_lock_element)) return -EINVAL; max_num = max_buf / sizeof(struct smb2_lock_element);