From patchwork Fri Aug 16 21:56:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1973394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fXELBpuc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2492-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wlwmh6VcYz1yXb for ; Sat, 17 Aug 2024 07:56:20 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E1B6A1C22017 for ; Fri, 16 Aug 2024 21:56:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38AAE1C57B2; Fri, 16 Aug 2024 21:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fXELBpuc" X-Original-To: linux-cifs@vger.kernel.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A0641C57A2 for ; Fri, 16 Aug 2024 21:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723845376; cv=none; b=Q5LOGOuvl9QCzyN6UyZ6ns48JPrK/JtTtNJJgV7yUkisnvyRbN/M2cD20KsmW6SLyaIWNpW1cKSZ1BV+j852Xu27aUhUjBLC3veGSMbWDwQe/zd8W/wjoiDpmE19oOVGV7+Kj9dzJRkna9IIAmH15MwyDx0f+xrzvzBv2wD5amU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723845376; c=relaxed/simple; bh=DH6G7Do3VNrV4NC1hzSpgWY0xRwpoSEvvnC557TN+4c=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=Svsc8GTjE9J1gp2Ju3Gew0XPzpZNFWJJ1WIodhxM3KYeJk7wcwTemh4oLDM+Bg7u+eSoWJIP09VcfaObRimu55vOOS+fvkvX6/51WyWgFNY7a3O+15qBNJYiOMqXQ9Z+sZcyPE3fp3OinkxxQTXM2MeLAIRB7MKAmXpOucxOQsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fXELBpuc; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52efd08e6d9so2985253e87.1 for ; Fri, 16 Aug 2024 14:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723845372; x=1724450172; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=INqbFCtS7hdtXTA2MpLVGbBQF3MX6s1l66OVT3n4bL8=; b=fXELBpucSK2mKefo7JkG+GpeL8+AsRsi2GQmSmXh14z8GQdzN9rUSe+/gTlTsaMyQl zGsZuo4af6bMZv9EYC8PcCTxxR/PeyRSG0eeJU9dLUbG5ETg56qppWdNXivROttA3V5L 7FVZ8pmUhFtK0kWIiJCMlyXrQRpG0qIOI7kAf4oQXBUa3tzW+99LqTWq2IWbh8feLMOW Z0TUv11vpL83csq0wi8LutDbfBpT/wV7uVKchaBhRGwN/t8aPAsXzAcw/zz00HJEQyxz 98eNPWCVz8Ss+einy9FFR1lNYstlh79WDlYKnIjM+qQJ4vkOqaX7hqkp2ChgxcN1yr8A 90bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723845372; x=1724450172; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=INqbFCtS7hdtXTA2MpLVGbBQF3MX6s1l66OVT3n4bL8=; b=myatA7gM1ArRs69mXoRKf/FrFI/iV2mvLDfPsxYtTrTGvK0Y+pOduxEuwwT+Xw8Ri6 StD2EpesmH20avgIVfOiihI/Ach0SoeyROyrMyhe/JJSlcLwblYlEf3Pg0wfHeeUoUv6 votEV3/JQetzlt+A0wlT4mE62++7LlDOshiwdjdcynOUR9paMej1EFTFTayEHOUVFE+4 2sqIWxU3adYBL7h6ZeZoDWafsaaSzWZgkiNpFLT3XXdRAbOwXWcQKKdAF8Et4ofqME5n 0qtxk7hGROX2AmAmeWuCvIdi2UXByyvn/u8LrDB/LGkqxIA4e9PUsS6ODQ5oDm8ucpe8 RPGQ== X-Gm-Message-State: AOJu0Yzf4TdEA7yuQxllODWu05N2e5OD8H5Ly3CzqRbOHpn+Lp2q1tGX uG347/0vb50P/qKf6RphKSaWEFOPbCHyiKi8mq6S1k6dGhneD18sF8IhEHsNdjlBNikLH00gH6Q m95YLQlUFrThYxGZjJotWiCc/86Xp5bh4 X-Google-Smtp-Source: AGHT+IEeM0mSyThmBLBhahiNK0BRFN90gzP5EYQs9+HEhL+pWyZslh9soOYbi1uNlrPVHr1KgE56c/7Hqu0SVYN/+Cc= X-Received: by 2002:a05:6512:1245:b0:530:b760:92b3 with SMTP id 2adb3069b0e04-5331c6b079dmr2805390e87.31.1723845371745; Fri, 16 Aug 2024 14:56:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Steve French Date: Fri, 16 Aug 2024 16:56:00 -0500 Message-ID: Subject: [PATCH][SMB CLIENT] fix refcount issue that shutdown related xfstests uncovered To: CIFS Cc: David Howells smb3: fix problem unloading module due to leaked refcount on shutdown The shutdown ioctl can leak a refcount on the tlink which can prevent rmmod (unloading the cifs.ko) module from working. Found while debugging xfstest generic/043 Fixes: 69ca1f57555f ("smb3: add dynamic tracepoints for shutdown ioctl") See attached From da35d443deaa64e7072969a413e3769332bc5849 Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 16 Aug 2024 16:47:39 -0500 Subject: [PATCH] smb3: fix problem unloading module due to leaked refcount on shutdown The shutdown ioctl can leak a refcount on the tlink which can prevent rmmod (unloading the cifs.ko) module from working. Found while debugging xfstest generic/043 Fixes: 69ca1f57555f ("smb3: add dynamic tracepoints for shutdown ioctl") Signed-off-by: Steve French --- fs/smb/client/connect.c | 3 +++ fs/smb/client/ioctl.c | 2 ++ fs/smb/client/link.c | 1 + 3 files changed, 6 insertions(+) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index d2307162a2de..c1c14274930a 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -4194,6 +4194,9 @@ tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink) * * If one doesn't exist then insert a new tcon_link struct into the tree and * try to construct a new one. + * + * REMEMBER to call cifs_put_tlink() after successful calls to cifs_sb_tlink, + * to avoid refcount issues */ struct tcon_link * cifs_sb_tlink(struct cifs_sb_info *cifs_sb) diff --git a/fs/smb/client/ioctl.c b/fs/smb/client/ioctl.c index 44dbaf9929a4..9bb5c869f4db 100644 --- a/fs/smb/client/ioctl.c +++ b/fs/smb/client/ioctl.c @@ -229,9 +229,11 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg) shutdown_good: trace_smb3_shutdown_done(flags, tcon->tid); + cifs_put_tlink(tlink); return 0; shutdown_out_err: trace_smb3_shutdown_err(rc, flags, tcon->tid); + cifs_put_tlink(tlink); return rc; } diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c index d86da949a919..80099bbb333b 100644 --- a/fs/smb/client/link.c +++ b/fs/smb/client/link.c @@ -588,6 +588,7 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode, tlink = cifs_sb_tlink(cifs_sb); if (IS_ERR(tlink)) { rc = PTR_ERR(tlink); + /* BB could be clearer if skipped put_tlink on error here, but harmless */ goto symlink_exit; } pTcon = tlink_tcon(tlink); -- 2.43.0