From patchwork Fri Jul 26 06:18:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 13742389 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 909A52B9C4 for ; Fri, 26 Jul 2024 06:18:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721974710; cv=none; b=UT3kmg3QTO5d6rq6qL56N1gw94A5IplTJAoVaNDxljs1IbzvFKCARDExOy4KrDSfhih4LichlY8x2lWqmyxUKn5K6py59Uui17+0wt3B2C+Pn0obUtm19S1G8pZ5BVqWkVAr9lR3YrdKx4hPq0FrVMcc9y34qw9iEDH8XM0q7i0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721974710; c=relaxed/simple; bh=0VhCKA5jfvo/H6WtQvJYtTKpd2FcUTAm6ezVN5h3o5g=; h=MIME-Version:From:Date:Message-ID:Subject:To:Content-Type; b=aBlNYFlxTizSgO2Akhlh5/gClBoYg+gi5Wtm6U680H+zBe1i4wNMFfC84P+QF99Q+qvduTDpcoHRCdWJuvx/TqhfQ2TnWT2xWdTXC0scuZWmaAUEayLdpAshdCMav+lE/nwrxcM4zVYb4YUwr4XGl5GFfdi6JoUM5xQYbDcE+kE= 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=hImA1DYm; arc=none smtp.client-ip=209.85.208.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hImA1DYm" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2f0271b0ae9so10479781fa.1 for ; Thu, 25 Jul 2024 23:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721974706; x=1722579506; darn=vger.kernel.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=wGIDKTYm6T97Ux4wAeKYKfGvhOaNuObEt2k58ikX804=; b=hImA1DYmF20A228T39gUlzDt44FbX4xfAgJmXJRyEhWnsNACUth1mNOpT+89zK0eId YwVnTOPFB7hhWuAna3ffCY9t5RWKuhDGPceZ0kiS3k3H1fZmap2vnPwfF4NyPyT0+un8 1cS1M6bIfG0Gj89P33zGyMNYewdOfMopHQ3Ctsl4+d9ge3gLBy4MQX+vpb7V0xYSQo1g fOnfKimJbRo3nRWluoZcWDX8wS2+RTzqvnZXVyH4Ug3TWoTeyRMMeH5uB9Nra4MzLZgx EWbuZXFrteB+s5C6lb8uMBCJ082O0THTmd+NVn9Iogx8GMQaxGxzGgzi7ByP52Ea0Cud E5jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721974706; x=1722579506; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wGIDKTYm6T97Ux4wAeKYKfGvhOaNuObEt2k58ikX804=; b=o5MradhbxjUCVmKGDaxnyzrRhqnislIEF3svSXgtyqUg0hYfiwBMnULwcWQHRTsJja NyzgLJGGnoGr4HeGjELVo825i8XViaFLUBzT30mZAEWMZMD+f91q72L5mHYTTYWI2wdm jt9i6nQ84PzBv69okskOc0KTYgISQmBdrG/I2k2XAqhGaQyD48241z0JD6aVP1FkUrqd zrLYXBI1Kxgdane6mlvsqvpMg5uKogiB9Q4/4qsxrSxTyIicBAQKurOrJPLYpLnvtCBg X7mZ+pwq4hfSFLTzvjdZL+C7kloa1G67zXprxnViErSWNRP4E2oyx3djv4CvoBeUsUDL u69Q== X-Gm-Message-State: AOJu0YzhdFz6Uzp6coKp2WqHyAc9GsyDaN0unToiwZ6FXj+09SZIUBdB Yo2O0wuTQABznuOtrrina08kGu8eN32qV/3HyIaFmNmD86J0l8Smaq4+/ymL+/eIGtx0aC2DJjH qNdoXIedL6nY6b2IysHtROh9QtG4MNnCD X-Google-Smtp-Source: AGHT+IHuSVGIPgoir0qJy9dE2hUgH/MtP26+Qi7TWjyRTu/JXBqokHny1zuL0UVOM/3C8gyPSrUqYu5ynH6M3cORJe4= X-Received: by 2002:a2e:9ed9:0:b0:2ee:5ed4:792f with SMTP id 38308e7fff4ca-2f039c8f224mr36506011fa.2.1721974706015; Thu, 25 Jul 2024 23:18:26 -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, 26 Jul 2024 01:18:14 -0500 Message-ID: Subject: [PATCH][SMB3 client] add dynamic trace point for session setup password expired failures To: CIFS There are cases where services need to remount (or change their credentials files) when keys have expired, but it can be helpful to have a dynamic trace point to make it easier to notify the service to refresh the storage account key. Here is sample output, one from mount with bad password, one from a reconnect where the password has been changed or expired and reconnect fails (requiring remount with new storage account key) TASK-PID CPU# ||||| TIMESTAMP FUNCTION | | | ||||| | | mount.cifs-11362 [000] ..... 6000.241620: smb3_key_expired: rc=-13 user=testpassu conn_id=0x2 server=localhost addr=127.0.0.1:445 kworker/4:0-8458 [004] ..... 6044.892283: smb3_key_expired: rc=-13 user=testpassu conn_id=0x3 server=localhost addr=127.0.0.1:445 See attached patch From d942133cc0a8fae6bddab3a194b00686b85a1d44 Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 26 Jul 2024 01:06:20 -0500 Subject: [PATCH] smb3: add dynamic trace point for session setup key expired failures There are cases where services need to remount (or change their credentials files) when keys have expired, but it can be helpful to have a dynamic trace point to make it easier to notify the service to refresh the storage account key. Here is sample output, one from mount with bad password, one from a reconnect where the password has been changed or expired and reconnect fails (requiring remount with new storage account key) TASK-PID CPU# ||||| TIMESTAMP FUNCTION | | | ||||| | | mount.cifs-11362 [000] ..... 6000.241620: smb3_key_expired: rc=-13 user=testpassu conn_id=0x2 server=localhost addr=127.0.0.1:445 kworker/4:0-8458 [004] ..... 6044.892283: smb3_key_expired: rc=-13 user=testpassu conn_id=0x3 server=localhost addr=127.0.0.1:445 Signed-off-by: Steve French --- fs/smb/client/smb2pdu.c | 8 +++++++- fs/smb/client/trace.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c index 9fc5b11c0b6c..3dd5a7a02288 100644 --- a/fs/smb/client/smb2pdu.c +++ b/fs/smb/client/smb2pdu.c @@ -1562,8 +1562,14 @@ SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data) cifs_small_buf_release(sess_data->iov[0].iov_base); if (rc == 0) sess_data->ses->expired_pwd = false; - else if ((rc == -EACCES) || (rc == -EKEYEXPIRED) || (rc == -EKEYREVOKED)) + else if ((rc == -EACCES) || (rc == -EKEYEXPIRED) || (rc == -EKEYREVOKED)) { + if (sess_data->ses->expired_pwd == false) + trace_smb3_key_expired(sess_data->server->hostname, + sess_data->ses->user_name, + sess_data->server->conn_id, + &sess_data->server->dstaddr, rc); sess_data->ses->expired_pwd = true; + } memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec)); diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h index bc4f8b3ad6ff..25e29c662672 100644 --- a/fs/smb/client/trace.h +++ b/fs/smb/client/trace.h @@ -1281,6 +1281,46 @@ DEFINE_EVENT(smb3_connect_err_class, smb3_##name, \ DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err); +DECLARE_EVENT_CLASS(smb3_sess_setup_err_class, + TP_PROTO(char *hostname, char *username, __u64 conn_id, + const struct __kernel_sockaddr_storage *dst_addr, int rc), + TP_ARGS(hostname, username, conn_id, dst_addr, rc), + TP_STRUCT__entry( + __string(hostname, hostname) + __string(username, username) + __field(__u64, conn_id) + __array(__u8, dst_addr, sizeof(struct sockaddr_storage)) + __field(int, rc) + ), + TP_fast_assign( + struct sockaddr_storage *pss = NULL; + + __entry->conn_id = conn_id; + __entry->rc = rc; + pss = (struct sockaddr_storage *)__entry->dst_addr; + *pss = *dst_addr; + __assign_str(hostname); + __assign_str(username); + ), + TP_printk("rc=%d user=%s conn_id=0x%llx server=%s addr=%pISpsfc", + __entry->rc, + __get_str(username), + __entry->conn_id, + __get_str(hostname), + __entry->dst_addr) +) + +#define DEFINE_SMB3_SES_SETUP_ERR_EVENT(name) \ +DEFINE_EVENT(smb3_sess_setup_err_class, smb3_##name, \ + TP_PROTO(char *hostname, \ + char *username, \ + __u64 conn_id, \ + const struct __kernel_sockaddr_storage *addr, \ + int rc), \ + TP_ARGS(hostname, username, conn_id, addr, rc)) + +DEFINE_SMB3_SES_SETUP_ERR_EVENT(key_expired); + DECLARE_EVENT_CLASS(smb3_reconnect_class, TP_PROTO(__u64 currmid, __u64 conn_id, -- 2.43.0