From patchwork Sat Oct 22 07:19:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1095399wrr; Sat, 22 Oct 2022 01:02:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EmuJ/oMsGknAGXBbUuNQjqMHbhpja9HzqW4F41fzoAc+Mk72H1N2+7z3JRxpvFh6tUuiE X-Received: by 2002:a17:902:f552:b0:17f:92d7:98f5 with SMTP id h18-20020a170902f55200b0017f92d798f5mr22502941plf.143.1666425756198; Sat, 22 Oct 2022 01:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425756; cv=none; d=google.com; s=arc-20160816; b=n/U208tYItK5/9Bnov8r77TJDJYhb+R/RlhPwKPSljEeM7W/H/Htx4GdIvbw0OR30b Clqdh3+ObH4nP63XpggP2/v+9vQBbVX5AZQtCqUZ52Gb2CxbG7tdC4w3ZaRUpjQGZsET gtupzcKKg5karx9nN/UAYWj9HDAnd2i7j95AlJFA83IC/5aPV4tRD/ycZel6jmaEnHot jPPDqr6DKHKije10woog4CQ2tsZDBEcuz6C/A7qlzEV4JPg7upVqCp4d3k1TD+kdiWbM WuHL6tOvlCsJEZPZvpJkgQiZ2xEAmGAlYq15B4AVgmpIF2u2rzLmzZhZe1nU6xG6Vvdv R5Tg== 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=NZE3t0lv0c8apM3E3tIiBsi/ch0S8D0XvC6yZyXaCTM=; b=b8CzewFfV3Sj7AY3+6S4Ab45tpd4SoWsT1KJOvyDOoNHRlEKGN7lK32YJZDRfkKiym uRA74PFTrIUkm4NIoTp79Rg9qGIu+AJMRJZdelOtDPv8WEeqAjc6kHj/+HdJ6E4euS3X 1w95oBR/TrUbyEMRDPLT+C58G0cGPiippIB4wFwBa1Fz2Arn8JeuIc58ckkXZwnfdxj6 gC7DYe28WVKBB34BjAcfBz3sEc1O3IFK9VH9KJB5C8KBQfk3lQBYD2s0eTb7FbR7HvhK QJPsM09LzhndtdQaJQX5+pSy6ngOZrazlWBLBG4muQRacgCKinzCLHA846PVnFKyv4x1 1/4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ltPkDYxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a17090302c900b0017f5ea214a8si27819107plk.462.2022.10.22.01.02.02; Sat, 22 Oct 2022 01:02:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ltPkDYxy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232426AbiJVIBg (ORCPT + 99 others); Sat, 22 Oct 2022 04:01:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232209AbiJVHyY (ORCPT ); Sat, 22 Oct 2022 03:54:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13FAC66F33; Sat, 22 Oct 2022 00:47:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EACE460B45; Sat, 22 Oct 2022 07:40:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0531EC433B5; Sat, 22 Oct 2022 07:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424402; bh=6eiZPDlPDFL9lPpruiqEd6DS7gA4Z9UNc9hLlk9WAvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ltPkDYxy8d00zeFpLfTolBhw0JMDIGxsrVY8bvdV69fBCPVmimLZLvQHnPm7HdKI8 A3Xc4sNKTuEHJPjpdzsCbrs6rQl+tpCy5xB9CbhWf6l6sNr5d2cFtK+GzfBnN3LwYj fLxKa55HER9GpkZ0rb/1JN/fHgQFFKE/7ZOnfSL8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Paulo Alcantara (SUSE)" , Steve French Subject: [PATCH 5.19 101/717] smb3: do not log confusing message when server returns no network interfaces Date: Sat, 22 Oct 2022 09:19:40 +0200 Message-Id: <20221022072433.276045308@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747374053978133101?= X-GMAIL-MSGID: =?utf-8?q?1747374053978133101?= From: Steve French commit 4659f01e3cd94f64d9bd06764ace2ef8fe1b6227 upstream. Some servers can return an empty network interface list so, unless multichannel is requested, no need to log an error for this, and when multichannel is requested on mount but no interfaces, log something less confusing. For this case change parse_server_interfaces: malformed interface info to empty network interface list returned by server localhost Also do not relog this error every ten minutes (only log on mount, once) Cc: Reviewed-by: Paulo Alcantara (SUSE) Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/cifsproto.h | 2 +- fs/cifs/connect.c | 2 +- fs/cifs/smb2ops.c | 23 ++++++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -642,7 +642,7 @@ cifs_chan_is_iface_active(struct cifs_se int cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server); int -SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon); +SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount); void extract_unc_hostname(const char *unc, const char **h, size_t *len); int copy_path_name(char *dst, const char *src); --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -155,7 +155,7 @@ static void smb2_query_server_interfaces /* * query server network interfaces, in case they change */ - rc = SMB3_request_interfaces(0, tcon); + rc = SMB3_request_interfaces(0, tcon, false); if (rc) { cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", __func__, rc); --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -511,8 +511,7 @@ smb3_negotiate_rsize(struct cifs_tcon *t static int parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf, - size_t buf_len, - struct cifs_ses *ses) + size_t buf_len, struct cifs_ses *ses, bool in_mount) { struct network_interface_info_ioctl_rsp *p; struct sockaddr_in *addr4; @@ -542,6 +541,20 @@ parse_server_interfaces(struct network_i } spin_unlock(&ses->iface_lock); + /* + * Samba server e.g. can return an empty interface list in some cases, + * which would only be a problem if we were requesting multichannel + */ + if (bytes_left == 0) { + /* avoid spamming logs every 10 minutes, so log only in mount */ + if ((ses->chan_max > 1) && in_mount) + cifs_dbg(VFS, + "empty network interface list returned by server %s\n", + ses->server->hostname); + rc = -EINVAL; + goto out; + } + while (bytes_left >= sizeof(*p)) { memset(&tmp_iface, 0, sizeof(tmp_iface)); tmp_iface.speed = le64_to_cpu(p->LinkSpeed); @@ -672,7 +685,7 @@ out: } int -SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) +SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount) { int rc; unsigned int ret_data_len = 0; @@ -692,7 +705,7 @@ SMB3_request_interfaces(const unsigned i goto out; } - rc = parse_server_interfaces(out_buf, ret_data_len, ses); + rc = parse_server_interfaces(out_buf, ret_data_len, ses, in_mount); if (rc) goto out; @@ -1022,7 +1035,7 @@ smb3_qfs_tcon(const unsigned int xid, st if (rc) return; - SMB3_request_interfaces(xid, tcon); + SMB3_request_interfaces(xid, tcon, true /* called during mount */); SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_ATTRIBUTE_INFORMATION);