From patchwork Wed Mar 29 20:14:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1762983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=AZBtvbcm; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PmySz43dcz1yYr for ; Thu, 30 Mar 2023 07:14:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjC2UOm (ORCPT ); Wed, 29 Mar 2023 16:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjC2UOl (ORCPT ); Wed, 29 Mar 2023 16:14:41 -0400 Received: from mx.manguebit.com (mx.manguebit.com [IPv6:2a01:4f8:1c1e:a2ae::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4D8C4ED5 for ; Wed, 29 Mar 2023 13:14:39 -0700 (PDT) From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=R1xP26q+B0iKEnLoXzJoz3Z/hIUQJdqBUNJ4ookh6c4=; b=AZBtvbcmP0wMRGwN7W+bU+0dwJ5OHeFHmm9PokI1/MBQ4YQZwctEd1J0pYshedVp6Sq+gw EuzpJWIaVXr6QOc/AGfXiuQZ0Wr58TXHWudzpLTYsILkFgSsO16B7jKD6CUNZfXLeHqzLF Z58tvzNaUigLcEmmP9aKP9ogd2E6YYyoKLbBUySHa68cznbSrmSnIJdXmSdBmci2pmBGmX ktSoTTMsdEyDLNm5+Nobugqwy4Qmdo1aj9unUhM2/XbnNqM7byyWrBn5qdZxA+i07iW6cT XseHptCsMs05CrYPbqsRFLHzmRQghPDwL3Gt9DSAVsPB3KPZKjRITgFdODh/+g== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1680120877; a=rsa-sha256; cv=none; b=dCuFe9Rz45sWRPtpDiVFuzvMaoJGKuqT8lVyAdr3RfeavwpAOe17MrNRGhHqe1YzBiZigT 7sctq7Tg6ueYn8n1X3tuQAZnDtMpLfWlcg4s+HJsYqikRC2yXYm8SehPPQWK7JO4WDHpKH uiZO9ET9dmoQUBfiL8BRj9CmDmp/IDv4hCchT/1qO/K+HzmgoqHNWb8KBw03QrkceLL95R jPfido4RNGg8VQPnoHAE8CZRhVd9XUBu15JXnKFMsQJ76TTG+0I3kLYrZILOewx+3odWDx PhpEWjaTkXKlQiMr5Rk0ZJDcOg29Vn7k4OSXiTGIb6IfXErP9eD32o5UF0HW/g== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=R1xP26q+B0iKEnLoXzJoz3Z/hIUQJdqBUNJ4ookh6c4=; b=obKOFToe/mRa/JfwF8sgkztsVuT2P97c3f4Kltmpfd+boya+Yx+yKMugcR+WaUIuHg/0JA PqkWxZZhCmNeDlJBcXMQ+j44jX/iwfg1zUrFoXHDbqjRQF8GpeBhpCD0/v6CoE1LiIcaJr 2AfR9JmaVSaumtPfj1GWpW0SLwhRxPxSg5LzJpvhFb/dV7Fgvochs5AwwPKjAwcJZS8Bds W8OShmDJcL/e+DcFGK60ihoHMdia7ttV5QzYkmNrbJ53tQ2BLdPWJOfEA3a6V7SjTlo/3p jDmHqE8auG0uGk7fh9n4ho4VXuG1rliNrgQXJjkjBxXuWXEeHyQxN8UiBNPHeA== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 1/5] cifs: get rid of cifs_mount_ctx::{origin,leaf}_fullpath Date: Wed, 29 Mar 2023 17:14:19 -0300 Message-Id: <20230329201423.32134-1-pc@manguebit.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-cifs@vger.kernel.org leaf_fullpath is now part of smb3_fs_context structure, while origin_fullpath is just a variable in __dfs_mount_share() that is used when final tcon is available. Get rid of those fields in cifs_mount_ctx structure and no-op kfree()'s. Signed-off-by: Paulo Alcantara (SUSE) --- fs/cifs/cifsglob.h | 1 - fs/cifs/connect.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 08a73dcb7786..c5e3a0fc7983 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1750,7 +1750,6 @@ struct cifs_mount_ctx { struct TCP_Server_Info *server; struct cifs_ses *ses; struct cifs_tcon *tcon; - char *origin_fullpath, *leaf_fullpath; struct list_head dfs_ses_list; }; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1cbb90587995..ef50f603e640 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -3454,8 +3454,6 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) error: dfs_put_root_smb_sessions(&mnt_ctx.dfs_ses_list); - kfree(mnt_ctx.origin_fullpath); - kfree(mnt_ctx.leaf_fullpath); cifs_mount_put_conns(&mnt_ctx); return rc; } From patchwork Wed Mar 29 20:14:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1762984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=kIBkhh5i; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PmyT0197lz1yZ0 for ; Thu, 30 Mar 2023 07:14:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjC2UOn (ORCPT ); Wed, 29 Mar 2023 16:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjC2UOm (ORCPT ); Wed, 29 Mar 2023 16:14:42 -0400 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A5430C7 for ; Wed, 29 Mar 2023 13:14:41 -0700 (PDT) From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BEJhsKVZeUmeNNn/UZQ/VeSRgg2sJxpZrzuIpDMTNaY=; b=kIBkhh5ik7Rz+uQzni7QndNp3btnF76OhdxfuJL6NO/gRP+gy4vA40/UqkJ7C8r5LyFuXj ajAat9YyjWcuGvHLzOvfqe1O2BGqyNft6qz4Hm+dMquwEa7nn06IlQ31xAz7TligUOS8iv ZG9Rxu6vQYrexMKLFOdSRjjh4qCIsV3BXkkwQqjvvEFYGRYNLx6MH5Cvv/E8ay+preN2Bh 7ztOGgPccIy+hlmFnQsmvi2vx4I0ubppteGMipS8TtuLj9+YqTBIjQYArKmSB53I33MAsE D/oeKgxZ/Txi1CoUVz4QZXYvmVLe2C6W05jqv/C0PVmLD7N+fGED3czdKwfAMw== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1680120880; a=rsa-sha256; cv=none; b=NQJvJwTTdxVcpAe0ynbcXiV+PS7D32l/TXL5dNSeJPLTjoG4x335tlD+1EN4AXi5K/o5iz bvYdkULpIFKyDV7XDapHZwPyTmr2mrkZrzZYNnuMnzxpI5piIC2ekqUjfJyN9P9gWCr2dp PenB61rvfD60qYIAouXkOl/G9XP7gmkniX8XH0Q/CP49Cc1v8R/TNMHG+/UbztVcxUM3L6 VUwqzz/QSdn1xuvLVrq0gr+3wEwAq726Sjs/OcVrCYM7jt2HXFgkoxeRiQc5V0x9387GTy maH7P5AIDqjNcAlYy2HURrTenVH+QDq9u0OS4BQgmhiKVSCtCDmNJmoVjaziaQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BEJhsKVZeUmeNNn/UZQ/VeSRgg2sJxpZrzuIpDMTNaY=; b=BCpAFBD6MJ/UGKLmzTplxex5mX0vR/BY/PlsA/+LBEv7RIKOd6B1p313wgAoFXEgkOK7Eg XNkeZOinJUphdGnyTL0/lBeJZX0YZtoyPhhBbOxwKup5AacXEC3yS9v6UGXd1Ih6Rn08Ki OA5tn54MBxOBJ3fiklNRX29n8BQ1qYAvz4S661Z39TAqjd34sE/s3B5eeX/fm6WyzN0aZQ V3enVK12cfZpjq0Jbah4eTKitzG3/JUcZnf/r8vcviyqMsIa4IY+shWQ5bZ47kO2EKSk/n Imn6WRYkjcrFA8IZ/bAN2+8tmqaPUTrtrQzWiX54NyDhVKhJQ3C1we3XkKqD5g== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 2/5] cifs: get rid of unnecessary ifdef Date: Wed, 29 Mar 2023 17:14:20 -0300 Message-Id: <20230329201423.32134-2-pc@manguebit.com> In-Reply-To: <20230329201423.32134-1-pc@manguebit.com> References: <20230329201423.32134-1-pc@manguebit.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-cifs@vger.kernel.org No need to ifdef around TCP_Server_Info::{origin,leaf}_fullpath as they're declared regardless CONFIG_CIFS_DFS_UPCALL. Signed-off-by: Paulo Alcantara (SUSE) --- fs/cifs/connect.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index ef50f603e640..7c3e090a0f13 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -993,10 +993,8 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server) */ } -#ifdef CONFIG_CIFS_DFS_UPCALL kfree(server->origin_fullpath); kfree(server->leaf_fullpath); -#endif kfree(server); length = atomic_dec_return(&tcpSesAllocCount); From patchwork Wed Mar 29 20:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1762985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=Egd2Zw0I; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PmyT13xZCz1yYr for ; Thu, 30 Mar 2023 07:14:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229623AbjC2UOo (ORCPT ); Wed, 29 Mar 2023 16:14:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjC2UOo (ORCPT ); Wed, 29 Mar 2023 16:14:44 -0400 Received: from mx.manguebit.com (mx.manguebit.com [IPv6:2a01:4f8:1c1e:a2ae::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A8B4ED5 for ; Wed, 29 Mar 2023 13:14:43 -0700 (PDT) From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ApBFYKjUkyC5IY65UbHkiGfR1ySS2y4rREOzpnyUlbA=; b=Egd2Zw0IhCPG7Ra5w9I0XGwVQ9Sp/wAxbOkaHUCrTegjK3i2NMdFxKMypg2cl6HIpnMt9m r6KbebYOz5fiNwMQLv2LAA/JqezTsi2yUSnJDG+V3qQIBXLiE4DkGRzFPkXsC6KvyDlprv d38KiVfpxnmhIQSVhCwmWOoAyMdL2wE9SKPpUoynDTDY8phWV4/p4qO0ebJ0DajMWNoZUc ZH5Ec4zNy3NkMQoFM5TZEeA2SRqwJJOX6UxnQT/EBo9H8ZozDvsRrsDXObppn6En5MREp8 5aeNGC+bNCNe+MyMlicJ9bPhrlmsVuQRhennbADpHM977utcJgHGmP6xjRjubQ== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1680120882; a=rsa-sha256; cv=none; b=LTYCn7hA/3CwuMGQ9XALAVRG+EC301V+3wqNNpkrGo81cxovGDOawAYMdqh8z9oOc5De+D y6029c0YnrHmmCvex/L5Fps1QVGPyjozBwXN9FK3QDqSu/WqTLBl3bXk7TUizPhe7dTTjj o+Gffgqn2RIEDuM9KkYl4QIWhSDAVMvcw9bXImd+ZtiUrkz6nM6FnewIHDawOQ2XPqBxXv mS31og2aQca9tLZ1opOlyj0zhMetGDDpkd95lCZClAZrfnffceiTS+WuNQtOeNal43Xbhq gFKJnXq7/URNkjgfiMgWaU3Q3JhD+XxyGKv2GwKJtqxgUniQEJBfzUo1BqkMGA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ApBFYKjUkyC5IY65UbHkiGfR1ySS2y4rREOzpnyUlbA=; b=NVUzxnuqX8/kE8bmTMnMxjK/rSGz7MZ8D4amgAQvP6P91mpo98Zc1059NxPIObzkDgKeQP 3/sTWySErcX+6BeA4Bs1bLytNA+M/4C3ux4zzRbt+9PT2jzeqJAK8g9rIb2GEhDCBj3dWX mFCpsSyHKjb+x4Qg/L360RGb98/dRxiZEVavxBfANvAyn+PAQZv+5AbBVocD/vXoesUNRz 9YV4wN2jZx9xnvF8KSZ/3LDNXgdwdezZWqkw8kEVY7qkDuL0Lf9qdCI4f2PgDOREflPAGV 40JXnFV1CxKFN3+SvDfS6JdEmx9VtqHjVr/WyJAb7V5oZyirI2HBbE/EvC2Zzw== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 3/5] cifs: avoid races in parallel reconnects in smb1 Date: Wed, 29 Mar 2023 17:14:21 -0300 Message-Id: <20230329201423.32134-3-pc@manguebit.com> In-Reply-To: <20230329201423.32134-1-pc@manguebit.com> References: <20230329201423.32134-1-pc@manguebit.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-cifs@vger.kernel.org Prevent multiple threads of doing negotiate, session setup and tree connect by holding @ses->session_mutex in cifs_reconnect_tcon() while reconnecting session and tcon. Signed-off-by: Paulo Alcantara (SUSE) --- fs/cifs/cifssmb.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 38a697eca305..c9d57ba84be4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -71,7 +71,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command) int rc; struct cifs_ses *ses; struct TCP_Server_Info *server; - struct nls_table *nls_codepage; + struct nls_table *nls_codepage = NULL; /* * SMBs NegProt, SessSetup, uLogoff do not have tcon yet so check for @@ -99,6 +99,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command) } spin_unlock(&tcon->tc_lock); +again: rc = cifs_wait_for_server_reconnect(server, tcon->retry); if (rc) return rc; @@ -110,8 +111,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command) } spin_unlock(&ses->chan_lock); - nls_codepage = load_nls_default(); - + mutex_lock(&ses->session_mutex); /* * Recheck after acquire mutex. If another thread is negotiating * and the server never sends an answer the socket will be closed @@ -120,29 +120,38 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command) spin_lock(&server->srv_lock); if (server->tcpStatus == CifsNeedReconnect) { spin_unlock(&server->srv_lock); + mutex_lock(&ses->session_mutex); + + if (tcon->retry) + goto again; rc = -EHOSTDOWN; goto out; } spin_unlock(&server->srv_lock); + nls_codepage = load_nls_default(); + /* * need to prevent multiple threads trying to simultaneously * reconnect the same SMB session */ + spin_lock(&ses->ses_lock); spin_lock(&ses->chan_lock); - if (!cifs_chan_needs_reconnect(ses, server)) { + if (!cifs_chan_needs_reconnect(ses, server) && + ses->ses_status == SES_GOOD) { spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); /* this means that we only need to tree connect */ if (tcon->need_reconnect) goto skip_sess_setup; - rc = -EHOSTDOWN; + mutex_unlock(&ses->session_mutex); goto out; } spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); - mutex_lock(&ses->session_mutex); rc = cifs_negotiate_protocol(0, ses, server); if (!rc) rc = cifs_setup_session(0, ses, server, nls_codepage); From patchwork Wed Mar 29 20:14:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1762986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=fyfElq5O; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PmyT36tFTz1yYr for ; Thu, 30 Mar 2023 07:14:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbjC2UOr (ORCPT ); Wed, 29 Mar 2023 16:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjC2UOq (ORCPT ); Wed, 29 Mar 2023 16:14:46 -0400 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498B930C7 for ; Wed, 29 Mar 2023 13:14:45 -0700 (PDT) From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VvcK8pPKGoMb+e/vJ530ayb6XTxEW5G8XyoQ83G4DZA=; b=fyfElq5OBbtu7HIv2q0rN7jVnWaAKS3Pmh4SYCk2d50o5mtqq0LjdJVQWbX/lDa12LvCWw 0SdotpVGYKnDhGvlWM7NXjGAKfjMF3TcjLd5KaFmn8VLT/ujkKSsFfOdrs6/7pFXEGBzFI /1NTwJ/kA/GFRv8Pj7v8mGcQcUKp6IInjf6VN9zt5SfwcrUomWLF7insWwy8OB819U1n7U nqHW4hGu9YkI09qWFvxd5k0PfxCaQIYjFhul8qoxaW8SZSZXvMWU50dJTQZoGc9XgWaT1x UNTgD/1KaaUk0PHseHhlZUlHuy6kRBLRcUP/sFK1p1ie+dgIo8Q6l+aHed9nDg== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1680120884; a=rsa-sha256; cv=none; b=rvnu4FrxUfJRTYeEUu5DB8WncX7R2U5LgbXeZseDKv00eT/1aHYoVaIUj23KWJNiPNiHDj vG+qMUvXs9jGHW6OAHFgZTxVlVv5LJbKfcJR89qovqPi9307iRgBJMNETZzl4VxbzaIsu/ 4KsF6FwdVZt09bmYCm3T8BpeHd6V7kf12q/fRlJ19XIGGdHHsT0Gg4hZbHp98444cyEozi EFkwR1sFJZ/C87Xw6u+FZBqZe+W4iLKZYGUGnC+XQPeLUUKB8EhJ4D/7GLPSJ4T0G0C44X +EyayzERRWrVQd2HFHGv2qtzD/lS8uT7VlQSZGwgMy+Jm2aB8Hv9jxMQAxlcfw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VvcK8pPKGoMb+e/vJ530ayb6XTxEW5G8XyoQ83G4DZA=; b=kpEyYBdNfnW+Ry2nZG27vKxAZv0uJHh3FA91WRM51QUhl84f8J2u7IQAKneE5L0YBdO5BZ Ah1ybZ7IZXNdtwmkuhBRCIYJRG66ZfsvYA0cFgu16ZGmJZ8DFOqKvUivLPYzAYOL8NyHY5 uIDlaerdKicEl2qeoXTLipNiI++5tSm5DMw12Kupn4lP1HQNmO5xETVou+5zniUTPoeylq MAk8yFEg2BYxr2l2oSrjffN1Q+sRqc5dHv3UY2Ctgj8uhd85S4xibIGcVdj6DPq6RNceT7 6rSj71cXo5GsGNThr+3bEpsvz1nrKuJXYy6vYrZZCWEi1nzQa+2hfJVP4C+zRg== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 4/5] cifs: prevent infinite recursion in CIFSGetDFSRefer() Date: Wed, 29 Mar 2023 17:14:22 -0300 Message-Id: <20230329201423.32134-4-pc@manguebit.com> In-Reply-To: <20230329201423.32134-1-pc@manguebit.com> References: <20230329201423.32134-1-pc@manguebit.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-cifs@vger.kernel.org We can't call smb_init() in CIFSGetDFSRefer() as cifs_reconnect_tcon() may end up calling CIFSGetDFSRefer() again to get new DFS referrals and thus causing an infinite recursion. Signed-off-by: Paulo Alcantara (SUSE) --- fs/cifs/cifssmb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index c9d57ba84be4..0d30b17494e4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -4382,8 +4382,13 @@ CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses, return -ENODEV; getDFSRetry: - rc = smb_init(SMB_COM_TRANSACTION2, 15, ses->tcon_ipc, (void **) &pSMB, - (void **) &pSMBr); + /* + * Use smb_init_no_reconnect() instead of smb_init() as + * CIFSGetDFSRefer() may be called from cifs_reconnect_tcon() and thus + * causing an infinite recursion. + */ + rc = smb_init_no_reconnect(SMB_COM_TRANSACTION2, 15, ses->tcon_ipc, + (void **)&pSMB, (void **)&pSMBr); if (rc) return rc; From patchwork Wed Mar 29 20:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 1762987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=manguebit.com header.i=@manguebit.com header.a=rsa-sha256 header.s=dkim header.b=bA/NuiII; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4PmyT61HLdz1yYr for ; Thu, 30 Mar 2023 07:14:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbjC2UOs (ORCPT ); Wed, 29 Mar 2023 16:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjC2UOs (ORCPT ); Wed, 29 Mar 2023 16:14:48 -0400 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D7E30C7 for ; Wed, 29 Mar 2023 13:14:47 -0700 (PDT) From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2+sWfQUUU6ZOWnURaxnFXP8CMHOEh2Xs0bYQLq6uVss=; b=bA/NuiII6zzuMV8ZwSbgzmeM6SyPpgT/4JdaCjsy8t1czkt4WRiaX11EbkHpfb/ovfpMcf QFeWzWjLL8CXj2OxzkGYc+41TUUrnOgLL0Bwr2kLEtYeYFAfLUKszHLWNNPXn6ubogPJtx UGYxsu4WrhE6RvRPw5m7p93xcIFOc2AdctootSHvB3cp8XnoCCbU2jtMz6w7PSd7M+Bx6g VDmEGJseuWYZE4IsvkAfeAUlSqlpOB2TRK8SKpKWFHNipQ7hVIgQ8wP8QEFIcrwMnKsyIR +oYU4afasKCeL0cOQm+DegNv0pSCGIc3jnR0OVTaTw1n+XycjVfe0X3slHh8Dg== ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1680120886; a=rsa-sha256; cv=none; b=fn1wzRMdIU98JrFM+YXt9vUEwSji0DVHTWgMRZLK1XTTLCc3WSLpJqOysw5u2AkRJfP8eR WjKzuzNZfwN0GlDsOcWe6mAXcTmYc2tZ0awiSsKEe53yXpXHLCTKhhhjR8c9ftx2ONkWge hoJiHChVVx75lHoLZlAOQB+shzDk2C1H3RggM77oHPKG54qrN81hNo5Rrw7lf+njj0AfoU WR3qtN31JFAZJLRAMcn/Z66ZNWTKlxatRUsiYJxIw7Zl19EzqCtfTEj8/YAv6yquiagCki 0dY+xxAGU9UgfT24C+c8Oi1Xz9BWgBA7iQ9cE2moqhJMWqKvlJZxOUlzj/q/wg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pc@manguebit.com smtp.mailfrom=pc@manguebit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1680120886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2+sWfQUUU6ZOWnURaxnFXP8CMHOEh2Xs0bYQLq6uVss=; b=R2e9BDD2UfEWek9NfJ2Kix/djKsCal95lBF3XLfKg9pgtKww57Aq1dlwx7D2MUSuYb/5jm pQi53fjHkw+4Ja/FlUgJH2ndpvKNyq3SoHJW1D8FriQEiQRERTkoniPF3ZRRjmU+dv0JK6 5T/7/zdOc6wYelHGUjMyR+eYo+0xfATNssfVl/k9iMkyYxIDS4FOGW1yr6wLHpC45t8KEV lMXbgm6y+UVJrwqgeekVcFJbPwGgIJcitkgtugT6VYte30t2sLu7Dp4diifaiUmbFT4a3F paV8LqjioxMXoFWaqc4cP3jajINdd6WiT0FyJpJncGYHZn1bKJ+0iXeEcvdXIQ== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 5/5] cifs: get rid of dead check in smb2_reconnect() Date: Wed, 29 Mar 2023 17:14:23 -0300 Message-Id: <20230329201423.32134-5-pc@manguebit.com> In-Reply-To: <20230329201423.32134-1-pc@manguebit.com> References: <20230329201423.32134-1-pc@manguebit.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-cifs@vger.kernel.org The SMB2_IOCTL check in the switch statement will never be true as we return earlier from smb2_reconnect() if @smb2_command == SMB2_IOCTL. Signed-off-by: Paulo Alcantara (SUSE) --- fs/cifs/smb2pdu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 6bd2aa6af18f..2b92132097dc 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -310,7 +310,6 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, case SMB2_READ: case SMB2_WRITE: case SMB2_LOCK: - case SMB2_IOCTL: case SMB2_QUERY_DIRECTORY: case SMB2_CHANGE_NOTIFY: case SMB2_QUERY_INFO: