From patchwork Sat Apr 20 00:43:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 1925784 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=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-cifs+bounces-1881-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLt7c48z6z1yPJ for ; Sat, 20 Apr 2024 10:44:28 +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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A5FEBB21352 for ; Sat, 20 Apr 2024 00:44:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C78D238F; Sat, 20 Apr 2024 00:44:21 +0000 (UTC) X-Original-To: linux-cifs@vger.kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 6E21F38B for ; Sat, 20 Apr 2024 00:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713573861; cv=none; b=nsO8QrzH5uhg5chVsZgVNNmWTUSuqIq40KV6QXEj2br8eT06t07aVAouvHjzBlynfWfabKdljZpruuqrbkof99CuMal9R1l8esfD5MCBLz6GVJWqRTeMCj29+8qs/up1yQjNdWnKJAtuolaB3fVdyy1MSwbAj48LSjt3A8gLiQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713573861; c=relaxed/simple; bh=NW+P8PTL7FI5UKU3OM9gWwMGzvD0sG4o/qkWPl8czJY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=M9UHORaJ0jBJ9Sk4DRWsXQyOIuPYmg+vlGL5rn2WpE4e/BiOvYXK2s7RNFSVrHS3nYHNFS7f6U+ig2wVSsBHA1fOlxONtWRvhvmYgOQ3WnSqhnFtJVw/biJ33lbaGED0ArDNkvKx83uGbSwzVFBH6GdodCrSUwsKdsnu+FOBj78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e4bf0b3e06so25090985ad.1 for ; Fri, 19 Apr 2024 17:44:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713573859; x=1714178659; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kClqf59vhRPbaijRUW+m9DbgufhofG2WdcwyTgCW9QE=; b=tY2OCSkZXkJck/9o9x4T/8Fjj9/rW+PeH+y4FTFtT6rejdHLg6GDA/UfiyCxOfP2BJ NioW9Y7p0TE5BUeMB+EMyAq5taBqO3colYPtCF3PA9hQDVaErvR3ieoL82pd2OVm13Bs TtBRzvHBAuJUgygbdvjd2UefyReZjjxaGjyXJCwALxNKBToysJF4z2sJQlwIS0/wKJw+ TuSaS/XNQCu+CIm1fUB/LaTah4/7hW9p6CWXyfXHxQPYmrXSsp4o6WYwmgq/nHJbd5hs h7mMVzVfgST1vbiMixWU2fXYFzzYKldpuNrdZKNQNuz9lfDz52NCVcJ1UIzLHOzOknXh bb7w== X-Gm-Message-State: AOJu0Yxu30MdniMjBqNRXhu/9tO66xt1myzDP61rLot2/Xsk2L24B0ap RbojWPhP1BInlRKsi0i1v+FSXJZ1lqIi7/UpKoyCcyeIEB8250v37fLgWg== X-Google-Smtp-Source: AGHT+IGF0/lKwIZ+iyiP1jodwhwr1zJeVFNkpjZlcjxTkKXnwabOmMGf/FWBH5/cFQn5n9NmSGXjjg== X-Received: by 2002:a17:903:2308:b0:1e3:cd8c:d370 with SMTP id d8-20020a170903230800b001e3cd8cd370mr5064040plh.44.1713573859381; Fri, 19 Apr 2024 17:44:19 -0700 (PDT) Received: from localhost.localdomain ([110.14.71.32]) by smtp.gmail.com with ESMTPSA id e7-20020a17090a77c700b002a55d8a99d5sm5405317pjs.22.2024.04.19.17.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 17:44:19 -0700 (PDT) From: Namjae Jeon To: linux-cifs@vger.kernel.org Cc: smfrench@gmail.com, senozhatsky@chromium.org, tom@talpey.com, atteh.mailbox@gmail.com, Namjae Jeon Subject: [PATCH 1/2] ksmbd: common: use struct_group_attr instead of struct_group for network_open_info Date: Sat, 20 Apr 2024 09:43:47 +0900 Message-Id: <20240420004348.4907-1-linkinjeon@kernel.org> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 4byte padding cause the connection issue with the applications of MacOS. smb2_close response size increases by 4 bytes by padding, And the smb client of MacOS check it and stop the connection. This patch use struct_group_attr instead of struct_group for network_open_info to use __packed to avoid padding. Fixes: 0015eb6e1238 ("smb: client, common: fix fortify warnings") Signed-off-by: Namjae Jeon --- fs/smb/common/smb2pdu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h index 1b594307c9d5..202ff9128156 100644 --- a/fs/smb/common/smb2pdu.h +++ b/fs/smb/common/smb2pdu.h @@ -711,7 +711,7 @@ struct smb2_close_rsp { __le16 StructureSize; /* 60 */ __le16 Flags; __le32 Reserved; - struct_group(network_open_info, + struct_group_attr(network_open_info, __packed, __le64 CreationTime; __le64 LastAccessTime; __le64 LastWriteTime; From patchwork Sat Apr 20 00:43:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 1925785 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=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-cifs+bounces-1882-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLt7f4tTSz1yPJ for ; Sat, 20 Apr 2024 10:44:30 +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 am.mirrors.kernel.org (Postfix) with ESMTPS id 410A51F216CC for ; Sat, 20 Apr 2024 00:44:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF20B38B; Sat, 20 Apr 2024 00:44:24 +0000 (UTC) X-Original-To: linux-cifs@vger.kernel.org Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 7C59663E for ; Sat, 20 Apr 2024 00:44:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713573864; cv=none; b=mmjQqP1WxU/um+a3oZqCr34AH7G0aNecqIVpTCpd5BgZOXn0JMVrdeFl5nNn3Hpbnk1dkITz4d2xn7Tb9rpB5DJwBXpHNvKQxNsGAJQj3eNGYDnB87AUdmydarZ0hDgWwfRSk8i0+be/F3Ym2XGCatVI4LVkvI9/pyx/cNNoeXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713573864; c=relaxed/simple; bh=j2pcebCxufoux91u2reVH/Wn9XVZUHTOC9BYSU8FbZw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LCc8otiE79t9sN4p1H9aEgi+LrQ4BVJg1VMu685AJc/ynJCf/FRp/qNgaSsrC8I8NyjVtujrpnE8qp5Xdwid5mrXf6sMysPNILU1uumaDC2bExZ6Zg59u9PD5/FSvXVPj45M69ngdJnuFWxqceZxJzFygX0qvkyeEUUX3djL1+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2a3095907ffso2078347a91.0 for ; Fri, 19 Apr 2024 17:44:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713573863; x=1714178663; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3c/n/KZbWxE5eabbcvmudSmxIL6Xk6nK3s0o+32vEeE=; b=ZA+oLWnDnffTBzyZ2sgtZfrIIII0qjUSJy4yFoB9kMkQVkWDquGEu52YMMm6ytAWJ5 KY6oKnxmHeQu/waCxjdXdjjxJIpfuAck5Ju/KVI+9K/ZRtb9fJ/ZsskZz10XTR5+W/jl WStxLKjoIIcsudL2P1CiTEz00+pJjku9O5r78Q+r/6mFGfGtv2S73InGYh+7HFNJibji M9myPzKU29t+h8ZNRtyAtFzNHc+ePflZsel/ud/9msZbDcJwDQRymEhq7zb/42kzcvkj 15+iO7vmSLZbtsZiXbmXzNEFeFqntaeE1oZaUDbblGOVACSTjDvGgYZlg+JltIwaZHV0 2O1g== X-Gm-Message-State: AOJu0YyyzteD0fLyLvVauLIlLcxpS3Y+uUz/N1Agp/mzr6cqHu89XdGy dMCjVVoIimV4WPdIOIoVUOrnNAN/4g6W7JeIWZQDJ8s0rtzk1ltppAwgTA== X-Google-Smtp-Source: AGHT+IHS5576GXgrl98Y0fPOEb8Ow3N1Vyzhr7ZU4pwIlqoAeW68obg2UtL3xz23XCHaP/ejzIVqPw== X-Received: by 2002:a17:90b:88f:b0:2ac:40c8:1ed3 with SMTP id bj15-20020a17090b088f00b002ac40c81ed3mr3812901pjb.5.1713573862545; Fri, 19 Apr 2024 17:44:22 -0700 (PDT) Received: from localhost.localdomain ([110.14.71.32]) by smtp.gmail.com with ESMTPSA id e7-20020a17090a77c700b002a55d8a99d5sm5405317pjs.22.2024.04.19.17.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 17:44:22 -0700 (PDT) From: Namjae Jeon To: linux-cifs@vger.kernel.org Cc: smfrench@gmail.com, senozhatsky@chromium.org, tom@talpey.com, atteh.mailbox@gmail.com, Namjae Jeon Subject: [PATCH 2/2] ksmbd: add continuous availability share parameter Date: Sat, 20 Apr 2024 09:43:48 +0900 Message-Id: <20240420004348.4907-2-linkinjeon@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240420004348.4907-1-linkinjeon@kernel.org> References: <20240420004348.4907-1-linkinjeon@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If capabilities of the share is not SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY, ksmbd should not grant a persistent handle to the client. This patch add continuous availability share parameter to control it. Signed-off-by: Namjae Jeon --- fs/smb/server/ksmbd_netlink.h | 35 ++++++++++++++++++----------------- fs/smb/server/smb2pdu.c | 11 +++++++++-- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/fs/smb/server/ksmbd_netlink.h b/fs/smb/server/ksmbd_netlink.h index 686b321c5a8b..f4e55199938d 100644 --- a/fs/smb/server/ksmbd_netlink.h +++ b/fs/smb/server/ksmbd_netlink.h @@ -340,23 +340,24 @@ enum KSMBD_TREE_CONN_STATUS { /* * Share config flags. */ -#define KSMBD_SHARE_FLAG_INVALID (0) -#define KSMBD_SHARE_FLAG_AVAILABLE BIT(0) -#define KSMBD_SHARE_FLAG_BROWSEABLE BIT(1) -#define KSMBD_SHARE_FLAG_WRITEABLE BIT(2) -#define KSMBD_SHARE_FLAG_READONLY BIT(3) -#define KSMBD_SHARE_FLAG_GUEST_OK BIT(4) -#define KSMBD_SHARE_FLAG_GUEST_ONLY BIT(5) -#define KSMBD_SHARE_FLAG_STORE_DOS_ATTRS BIT(6) -#define KSMBD_SHARE_FLAG_OPLOCKS BIT(7) -#define KSMBD_SHARE_FLAG_PIPE BIT(8) -#define KSMBD_SHARE_FLAG_HIDE_DOT_FILES BIT(9) -#define KSMBD_SHARE_FLAG_INHERIT_OWNER BIT(10) -#define KSMBD_SHARE_FLAG_STREAMS BIT(11) -#define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS BIT(12) -#define KSMBD_SHARE_FLAG_ACL_XATTR BIT(13) -#define KSMBD_SHARE_FLAG_UPDATE BIT(14) -#define KSMBD_SHARE_FLAG_CROSSMNT BIT(15) +#define KSMBD_SHARE_FLAG_INVALID (0) +#define KSMBD_SHARE_FLAG_AVAILABLE BIT(0) +#define KSMBD_SHARE_FLAG_BROWSEABLE BIT(1) +#define KSMBD_SHARE_FLAG_WRITEABLE BIT(2) +#define KSMBD_SHARE_FLAG_READONLY BIT(3) +#define KSMBD_SHARE_FLAG_GUEST_OK BIT(4) +#define KSMBD_SHARE_FLAG_GUEST_ONLY BIT(5) +#define KSMBD_SHARE_FLAG_STORE_DOS_ATTRS BIT(6) +#define KSMBD_SHARE_FLAG_OPLOCKS BIT(7) +#define KSMBD_SHARE_FLAG_PIPE BIT(8) +#define KSMBD_SHARE_FLAG_HIDE_DOT_FILES BIT(9) +#define KSMBD_SHARE_FLAG_INHERIT_OWNER BIT(10) +#define KSMBD_SHARE_FLAG_STREAMS BIT(11) +#define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS BIT(12) +#define KSMBD_SHARE_FLAG_ACL_XATTR BIT(13) +#define KSMBD_SHARE_FLAG_UPDATE BIT(14) +#define KSMBD_SHARE_FLAG_CROSSMNT BIT(15) +#define KSMBD_SHARE_FLAG_CONTINUOUS_AVAILABILITY BIT(16) /* * Tree connect request flags. diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index ee4b2875a021..355824151c2d 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -1988,7 +1988,12 @@ int smb2_tree_connect(struct ksmbd_work *work) write_unlock(&sess->tree_conns_lock); rsp->StructureSize = cpu_to_le16(16); out_err1: - rsp->Capabilities = 0; + if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE && + test_share_config_flag(share, + KSMBD_SHARE_FLAG_CONTINUOUS_AVAILABILITY)) + rsp->Capabilities = SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY; + else + rsp->Capabilities = 0; rsp->Reserved = 0; /* default manual caching */ rsp->ShareFlags = SMB2_SHAREFLAG_MANUAL_CACHING; @@ -3502,7 +3507,9 @@ int smb2_open(struct ksmbd_work *work) memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE); if (dh_info.type == DURABLE_REQ_V2 || dh_info.type == DURABLE_REQ) { - if (dh_info.type == DURABLE_REQ_V2 && dh_info.persistent) + if (dh_info.type == DURABLE_REQ_V2 && dh_info.persistent && + test_share_config_flag(work->tcon->share_conf, + KSMBD_SHARE_FLAG_CONTINUOUS_AVAILABILITY)) fp->is_persistent = true; else fp->is_durable = true;