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=unavailable 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 C59EDCA9EBC for ; Sun, 27 Oct 2019 21:27:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96FB7222BE for ; Sun, 27 Oct 2019 21:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211658; bh=Ylppbfu16KHMXB+7ecukrBDTkQE1TIOrkKxPPDpLHY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vD2MgdcLnxbhhMJFgZBpcc3t9u5xi42Ej70lzq7vnSC7v7ngImPBf444zxy8QdY3N oTzTq04d8duqwBezCXlV0ccGZt5HwkeB1AUiuexV+nuyfssCWzAKMZX86xai+zoCbT sPcBn/43sylLekfV1TbKvW7AFH48xHTb8NWl/xn4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732589AbfJ0VYp (ORCPT ); Sun, 27 Oct 2019 17:24:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:46452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732581AbfJ0VYp (ORCPT ); Sun, 27 Oct 2019 17:24:45 -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 65C39222C2; Sun, 27 Oct 2019 21:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211484; bh=Ylppbfu16KHMXB+7ecukrBDTkQE1TIOrkKxPPDpLHY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmlUvbIxhKsFCq3yvyjorWbkZDsQKgyeBbTqv4MDP1/lrRm5Il3eFD24ceDQ491Vu fZW68+CTpqJIQ3wDq0thNK8hhRhtaNYSay6erwwMZ2VVfCgCOudDSiOa88fPVJOv6W pHHkmuchAPO42zn48Nsnk7FfsLn+I/OhWN2B1uPE= 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 5.3 167/197] CIFS: avoid using MID 0xFFFF Date: Sun, 27 Oct 2019 22:01:25 +0100 Message-Id: <20191027203403.359847100@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -171,6 +171,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.