From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 385DECA9EAF for ; Sun, 27 Oct 2019 21:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A3F520873 for ; Sun, 27 Oct 2019 21:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210702; bh=YcKemW8hN6xN1mCdmzEDpotHmlwhqjkayGEgTz247TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KbdF7wPsXLbmUo8J08/WcRA19iYju8SbEBBz3Vh1zfIw13XLTp0BkYG/x1G+9pWkT AQZVj0Qs/l9fUPb7PTHqzFZJ8mVkEFV72DzMQR6XG7rd3OyC/Dmnf9sR3/7SjNduMZ pl8+Yuxz208uhUNMoPgycfJLelBFQrJBK6GOm5bs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729936AbfJ0VLk (ORCPT ); Sun, 27 Oct 2019 17:11:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729068AbfJ0VLh (ORCPT ); Sun, 27 Oct 2019 17:11:37 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (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 E212420873; Sun, 27 Oct 2019 21:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210697; bh=YcKemW8hN6xN1mCdmzEDpotHmlwhqjkayGEgTz247TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1+mIoZz+3ApQZ+rilKn8P+7Jfrd86N6+pZRNywMXkBT4+oJ35CRrlizRXGXCqde6 DcPznqKwhUchdDVwmq9KfZYtZB/zInpT1EVZJ5I7o6XnytAYQwAiJSQVDC5OaT68hG PYFoFiqI72euiFo0hnMqEEpw10hxXeIzkzYolETg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roberto Bergantinos Corpas , Ronnie Sahlberg , Aurelien Aptel , Steve French Subject: [PATCH 4.14 106/119] CIFS: avoid using MID 0xFFFF Date: Sun, 27 Oct 2019 22:01:23 +0100 Message-Id: <20191027203349.292777908@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203259.948006506@linuxfoundation.org> References: <20191027203259.948006506@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Roberto Bergantinos Corpas commit 03d9a9fe3f3aec508e485dd3dcfa1e99933b4bdb upstream. According to MS-CIFS specification MID 0xFFFF should not be used by the CIFS client, but we actually do. Besides, this has proven to cause races leading to oops between SendReceive2/cifs_demultiplex_thread. On SMB1, MID is a 2 byte value easy to reach in CurrentMid which may conflict with an oplock break notification request coming from server Signed-off-by: Roberto Bergantinos Corpas Reviewed-by: Ronnie Sahlberg Reviewed-by: Aurelien Aptel Signed-off-by: Steve French CC: Stable Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb1ops.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c @@ -181,6 +181,9 @@ cifs_get_next_mid(struct TCP_Server_Info /* we do not want to loop forever */ last_mid = cur_mid; cur_mid++; + /* avoid 0xFFFF MID */ + if (cur_mid == 0xffff) + cur_mid++; /* * This nested loop looks more expensive than it is.