Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9095226pxu; Mon, 28 Dec 2020 06:31:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw49If2eX/gQ5iTfUBVkBfF1FPlytX7ZU4K56HOkn48V16iX2SOrJs1GCo5uVGdvBGfggBt X-Received: by 2002:a17:906:3111:: with SMTP id 17mr12117091ejx.152.1609165887343; Mon, 28 Dec 2020 06:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165887; cv=none; d=google.com; s=arc-20160816; b=NdOWqfnUuSBqHWVrssvLX91q+k+zNTk1WAtsqky/N/VOYYcqsVsVjmCtiejepXjAzx PSfymAYNLUSdMrCo/NXFGHWhaH/hfUDdvhjAj0sQCz+/FzGMfa/Wgwvdy6eqa6ufi576 GypCbpUjv3Ju0nAPc8uFSoy0EH9ibCYq4xa8WjEEcjuP9JRyMTjTDcz8Y7Nof0MYudXz om5+xfG3p2TnZcCQa8ttOIaKwYGrRPKjfXWjglaExXs2wAiOsf46HctHw7uKU1/wwcUW RZQSDyOi3ljMbLr+dB9fztKOymp8ErZvFl2mjp+JbfFgv1t3Q9Md0bpRothDdSAShXWJ YrQQ== 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=uiIJh8kUrCvnY0NwDDOubQI5ajw5mAV4l6jw6UBpkdI=; b=ctsa6+0/rSRcGWvmR/NRbYSskZpQHT3+wrxM3qzl+Oc8a2EIZXUfqyh327GgZRqsDl n873c/V6j0B+ST9Ao1hq9Y3UgF/iIr8JOLWATUHBOadYMeW2pdWhsUJY3yeY+rzhax1G jigP0Dyau/asgMmMgwDpPw6IQSipiISb+y4RR/T5dZK2gouLZT/dj3z7rOqVgJ0lyC8i hdrMZSjNheyFQmvMC4k2W0JJhtpOm5TresOSoF33neyVChDQEVCKCtUn0xAuxTwaqRnp M55mcjB08KH0je5IxyGV1qrEAUD8oOOoeJJBWVm3UozpZMFBm88VJn+uR8yGPBTKnrWJ Y4ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qfGxchV9; 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 g21si19743479edp.95.2020.12.28.06.31.05; Mon, 28 Dec 2020 06:31:27 -0800 (PST) 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=qfGxchV9; 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 S2502502AbgL1O2j (ORCPT + 99 others); Mon, 28 Dec 2020 09:28:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:36226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502477AbgL1O2f (ORCPT ); Mon, 28 Dec 2020 09:28:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8F4F22583; Mon, 28 Dec 2020 14:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165699; bh=2eT1tiFrlrdnQyphbP6Kozpy3B250w82TeHZUqxlaJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfGxchV9Sd3J3Bc/HeGzCFPFTm+vrrHvCvFCxN9cjD9NTJCS1DxHxyCSRLggDjuk+ rb+OWeObHudOV9hiNU7+mcHCsPq8JyXbJEILA3kTL/C9fEtuwSSp3MwoCWmi2kiiVh 9TB8jaarKX3nFjTIQnmMuKL0Vo4Nb6P1tfuGsm+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Shilovsky , Steve French Subject: [PATCH 5.10 624/717] SMB3.1.1: remove confusing mount warning when no SPNEGO info on negprot rsp Date: Mon, 28 Dec 2020 13:50:22 +0100 Message-Id: <20201228125050.815411013@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Steve French commit bc7c4129d4cdc56d1b5477c1714246f27df914dd upstream. Azure does not send an SPNEGO blob in the negotiate protocol response, so we shouldn't assume that it is there when validating the location of the first negotiate context. This avoids the potential confusing mount warning: CIFS: Invalid negotiate context offset CC: Stable Reviewed-by: Pavel Shilovsky Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2misc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -94,6 +94,8 @@ static const __le16 smb2_rsp_struct_size /* SMB2_OPLOCK_BREAK */ cpu_to_le16(24) }; +#define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_sync_hdr) + sizeof(struct smb2_negotiate_rsp)) + static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len, __u32 non_ctxlen) { @@ -109,11 +111,17 @@ static __u32 get_neg_ctxt_len(struct smb /* Make sure that negotiate contexts start after gss security blob */ nc_offset = le32_to_cpu(pneg_rsp->NegotiateContextOffset); - if (nc_offset < non_ctxlen) { - pr_warn_once("Invalid negotiate context offset\n"); + if (nc_offset + 1 < non_ctxlen) { + pr_warn_once("Invalid negotiate context offset %d\n", nc_offset); return 0; - } - size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen; + } else if (nc_offset + 1 == non_ctxlen) { + cifs_dbg(FYI, "no SPNEGO security blob in negprot rsp\n"); + size_of_pad_before_neg_ctxts = 0; + } else if (non_ctxlen == SMB311_NEGPROT_BASE_SIZE) + /* has padding, but no SPNEGO blob */ + size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen + 1; + else + size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen; /* Verify that at least minimal negotiate contexts fit within frame */ if (len < nc_offset + (neg_count * sizeof(struct smb2_neg_context))) {