From patchwork Thu Sep 12 12:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984637 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=DyoX0HKG; dkim-atps=neutral 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-2753-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 4X4GPg6b5pz1y1y for ; Thu, 12 Sep 2024 22:06:31 +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 A9F8C1F25763 for ; Thu, 12 Sep 2024 12:06:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 495151A3025; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DyoX0HKG" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 152061A2627; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; cv=none; b=tQkiAJgVPkwHYGJmg1f5RZI7EaKzdKVAgELQV0VYi6Zo+LU/hLuADBjhExmxaTlNkcpOjAZgaB3+ATMUkcoDIT/k7rIEGrV+uv1M19znCgLK8844LnxFQftB2vLsqcTq+IyWkdGRcyvT2VSqQjRXcGj0gtKnJXSEzmmf8PVoS6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; c=relaxed/simple; bh=/TUHrLYyzhdm8SLzeAOvb5kYuwHJb1PMCxxItPVMNko=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=qoBWaOK3aw3tWUgZm756PofafTTKOkb7z1+KJuhDeksAZZjYrPap5euytFwh5DfGM56mKGZYxzEQov8cjl37Vh1ETuPpyiPNKDvSqXaKsyFklAhQoXzP9AQnMGpcrZOQ3CsyNWAeJvEou0NSCdP5xwBtqnG7OQqT00VfTiXRkfI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DyoX0HKG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7036AC4CEC4; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142760; bh=/TUHrLYyzhdm8SLzeAOvb5kYuwHJb1PMCxxItPVMNko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DyoX0HKGyKJpuG5CUnDs6SC2D4GP3e4iVMFmPn3G5+VE6mcdNiEpFrLZtpq7aghLc iPIG8eupE0ZWhwb79GF1qxO+zR0UD7QSlwhzUycUBcB5HULhHwzKE/3ZM00G6sKE4y dEa44IKLpqJAZziC8q//4LShEYAdcFpnkYKA5EgJdcKiWKs//ae+Cb/KeppWqC8Dhy 5Dfix8p9pzjBQj66Drkx/xrjflRDWKZPun2flZIDCS9sfkPXD0z2dxwoHt8Q6WVLv/ aNzevqazqkAaj+3uhX1IcULVkrbyb5gCqrbDQYnD15OopMnTjLHTJZ2HlUpgmMgO23 ELx7Sza/+E6qQ== Received: by pali.im (Postfix) id F0338A11; Thu, 12 Sep 2024 14:05:54 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] cifs: Fix recognizing SFU symlinks Date: Thu, 12 Sep 2024 14:05:42 +0200 Message-Id: <20240912120548.15877-2-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SFU symlinks have 8 byte prefix: "IntxLNK\1". So check also the last 8th byte 0x01. Signed-off-by: Pali Rohár --- fs/smb/client/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index 73e2e6c230b7..7d424e769a56 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -612,7 +612,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, cifs_dbg(FYI, "Socket\n"); fattr->cf_mode |= S_IFSOCK; fattr->cf_dtype = DT_SOCK; - } else if (memcmp("IntxLNK", pbuf, 7) == 0) { + } else if (memcmp("IntxLNK\1", pbuf, 8) == 0) { cifs_dbg(FYI, "Symlink\n"); fattr->cf_mode |= S_IFLNK; fattr->cf_dtype = DT_LNK; From patchwork Thu Sep 12 12:05:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984635 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=AckGn0sZ; 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-2751-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 4X4GPX3yMbz1y1y for ; Thu, 12 Sep 2024 22:06:24 +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 9B5B41C234FC for ; Thu, 12 Sep 2024 12:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18CDC1A262D; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AckGn0sZ" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E59781A2567; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; cv=none; b=fAFE5Ha6eE9kRXG3DQs2JqJwdipgtwdb5gIrhPvU6YFkh1xS3K0XTf53WmhT1yaT+h8VWFUVPAMwN8BviRZAThA+QXU6WCLyLa9Hy05m35WkLYwJaHvTcOnkNWijHeevq8La9hvHT0jnCjuxeG94XG+bBVQJP0jxi6Xfxmrek9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; c=relaxed/simple; bh=s9pzhGr6IQGirw9NZ/o8ju+Zf44+KXPQ4IDwtq5jQBs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=MQHDXjE9QdFH2qqcF//iNL2dbhnbg99lds/Em7w5wQTCQ58J3IRnrLh41LvxNdJqO+mnXMx/RnYn1cBAz/iWfkoUYXUucopHWi1tyKh3NLg/SSwanjEbiPaiSVdT3WycIvvY9E1uBQY1QBl1VhSAKYSRY2MKFZrkx4JtN8YHfPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AckGn0sZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6986C4CECC; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142760; bh=s9pzhGr6IQGirw9NZ/o8ju+Zf44+KXPQ4IDwtq5jQBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AckGn0sZ7z2uXuN0jwwS7x3sc/uC2d7+DnySKDz9N1hsWwQJvTV00zgxXi6oi5IU3 GA+71ABPYO/XBPiHvSD+K8Sk11QeHnWjKWfm+PD7qQGpngA4BCtZaijOUlgdXKwV+R GnvZhD/kYDxwIXk0zSYek1/3igDYYF3IT/yMTdijzLsOpT/N/BM48Rfkb7ZMy6uR8D ZqAUuLcTLIooDGR/fJtxGx3P0xlOGd7nWmHqwBjFl6oI0uXEdEVRgKDduykzdcl4CR dqvUIv3zuOJthCKnjuZLKS1SXCA8RsvpFebmhq4R65LMFrWdIUXV9MxtHVMv8L3V4+ 5a7BRb+dEaiwg== Received: by pali.im (Postfix) id 31B80A4E; Thu, 12 Sep 2024 14:05:55 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] cifs: Add support for reading SFU symlink location Date: Thu, 12 Sep 2024 14:05:43 +0200 Message-Id: <20240912120548.15877-3-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently when sfu mount option is specified then CIFS can recognize SFU symlink, but is not able to read symlink target location. readlink() syscall just returns that operation is not supported. Implement this missing functionality in cifs_sfu_type() function. Read target location of SFU-style symlink, parse it and fill into fattr's cf_symlink_target member. SFU-style symlink is file which has system attribute set and file content is buffer "IntxLNK\1" (8th byte is 0x01) followed by the target location encoded in little endian UCS-2/UTF-16. This format was introduced in Interix 3.0 subsystem, as part of the Microsoft SFU 3.0 and is used also by all later versions. Previous versions had no symlink support. Signed-off-by: Pali Rohár --- fs/smb/client/inode.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index 7d424e769a56..e8567ed63f22 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -529,6 +529,8 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, struct cifs_fid fid; struct cifs_open_parms oparms; struct cifs_io_parms io_parms = {0}; + char *symlink_buf_utf16; + unsigned int symlink_len_utf16; char buf[24]; unsigned int bytes_read; char *pbuf; @@ -616,6 +618,33 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, cifs_dbg(FYI, "Symlink\n"); fattr->cf_mode |= S_IFLNK; fattr->cf_dtype = DT_LNK; + if ((fattr->cf_eof > 8) && (fattr->cf_eof % 2 == 0)) { + symlink_buf_utf16 = kmalloc(fattr->cf_eof-8 + 1, GFP_KERNEL); + if (symlink_buf_utf16) { + io_parms.offset = 8; + io_parms.length = fattr->cf_eof-8 + 1; + buf_type = CIFS_NO_BUFFER; + rc = tcon->ses->server->ops->sync_read(xid, &fid, &io_parms, + &symlink_len_utf16, + &symlink_buf_utf16, + &buf_type); + if ((rc == 0) && + (symlink_len_utf16 > 0) && + (symlink_len_utf16 < fattr->cf_eof-8 + 1) && + (symlink_len_utf16 % 2 == 0)) { + fattr->cf_symlink_target = + cifs_strndup_from_utf16(symlink_buf_utf16, + symlink_len_utf16, + true, + cifs_sb->local_nls); + if (!fattr->cf_symlink_target) + rc = -ENOMEM; + } + kfree(symlink_buf_utf16); + } else { + rc = -ENOMEM; + } + } } else if (memcmp("LnxFIFO", pbuf, 8) == 0) { cifs_dbg(FYI, "FIFO\n"); fattr->cf_mode |= S_IFIFO; From patchwork Thu Sep 12 12:05:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984638 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hZ6fDvyI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2754-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::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 4X4GPm12lxz1y1y for ; Thu, 12 Sep 2024 22:06:36 +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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E16B92848EC for ; Thu, 12 Sep 2024 12:06:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6B9D1A3052; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hZ6fDvyI" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EA221A0BFF; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; cv=none; b=tFeDrWpdCdw2GrypYG6q5xFoqyfW1XuS9S5gO7N9/VaSn7EqCTXiLAAEDfGED7ybLM1gBVCXtgw0tYt234WY/YkzojuvWF5Uop9XxFeoLZznF+K4lUMS0dkoCsDu02XOiNnL7LzBqtGafrOP3kfNZbu4z7Dow+EaZXEhWcNOGX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; c=relaxed/simple; bh=cQz+jNq/ftZXX/k+WOGLdN1FFcKYmae9h3VM8SsnEvA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lH9veEuwL9FnnTWGshqYqVxkwNiN7iY7bu5pIbKqjtXJabjsB5Krwb4lF1KoPotfD2CIiS9BxjcV4somSC0Y1BWWuuwi5/pY4smsb9aaR3chdLFarHbxJzOZOhn4TsQmf5R7jtOOJosRClrI9OLowQBDgSsPoxLdnhaSkoNx+Ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hZ6fDvyI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06EB6C4CED0; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142761; bh=cQz+jNq/ftZXX/k+WOGLdN1FFcKYmae9h3VM8SsnEvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZ6fDvyI6Mu7SwMjIFKh0gosTj02P4h5vvQClFPvFuBVNTxIxWiStVKGIxP0T52gU TjtW4sltZcmAsBMmZ8s2UVt/D7lbj+HkQMO3rssHLV273G7P/KYb8W9Tln1q/5iq42 v02t+ex1mYHENrqaaRdoAufnGH3jZLKlrTy0yvW1KcFK19wUpdK3Rf4h82WrBse+nq 70kHOk59iXaEzSauFVLHt8gZ6xN1o5z6a0fD7ywkcfmUBR6eO6ByzxSAPIZCMrxYEo Fygh5AkWmFxgd+9ScLm8NmghrsVFeZujBug3y6bAWojiD5I1q8+e68IElmUpLsQ/RA XoGzUugXfNzMg== Received: by pali.im (Postfix) id 5C15EB9A; Thu, 12 Sep 2024 14:05:55 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] cifs: Put explicit zero byte into SFU block/char types Date: Thu, 12 Sep 2024 14:05:44 +0200 Message-Id: <20240912120548.15877-4-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SFU types IntxCHR and IntxBLK are 8 bytes with zero as last byte. Make it explicit in memcpy and memset calls, so the zero byte is visible in the code (and not hidden as string trailing nul byte). It is important for reader to show the last byte for block and char types because it differs from the last byte of symlink type (which has it 0x01). Also it is important to show that the type is not nul-term string, but rather 8 bytes (with some printable bytes). Signed-off-by: Pali Rohár --- fs/smb/client/inode.c | 4 ++-- fs/smb/client/smb2ops.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index e8567ed63f22..d8c39989840e 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -586,7 +586,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, rc = tcon->ses->server->ops->sync_read(xid, &fid, &io_parms, &bytes_read, &pbuf, &buf_type); if ((rc == 0) && (bytes_read >= 8)) { - if (memcmp("IntxBLK", pbuf, 8) == 0) { + if (memcmp("IntxBLK\0", pbuf, 8) == 0) { cifs_dbg(FYI, "Block device\n"); fattr->cf_mode |= S_IFBLK; fattr->cf_dtype = DT_BLK; @@ -598,7 +598,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); fattr->cf_rdev = MKDEV(mjr, mnr); } - } else if (memcmp("IntxCHR", pbuf, 8) == 0) { + } else if (memcmp("IntxCHR\0", pbuf, 8) == 0) { cifs_dbg(FYI, "Char device\n"); fattr->cf_mode |= S_IFCHR; fattr->cf_dtype = DT_CHR; diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index e6540072ffb0..9c2d065d3cc4 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5072,12 +5072,12 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, switch (mode & S_IFMT) { case S_IFCHR: - strscpy(pdev.type, "IntxCHR"); + memcpy(pdev.type, "IntxCHR\0", 8); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); break; case S_IFBLK: - strscpy(pdev.type, "IntxBLK"); + memcpy(pdev.type, "IntxBLK\0", 8); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); break; From patchwork Thu Sep 12 12:05:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984634 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=tJ9tnwPp; dkim-atps=neutral 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-2750-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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X4GPX4L2Jz1y28 for ; Thu, 12 Sep 2024 22:06:24 +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 F3A38B20DEC for ; Thu, 12 Sep 2024 12:06:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 191261A262F; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tJ9tnwPp" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E59C91A2622; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; cv=none; b=LOPF50jZzONAwQsuYBVebv3FMTy6r0cbDJrOycQ5PYHUkA8gtor+ldkfi7lJGx5xC28ZxKBJAEDjZ2xS2/vh4yec7bHq3Gl7SAVEbRsiC6sRyJK4/u2PSgH6BjgZjZ4xowbQPGHUhAsNS0DzuCyj/sy+sd1zDS1N1uW5v3yIyMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; c=relaxed/simple; bh=Tvx8ty3Re4/zz/tINhZ29nrFM+JFehh/c4aSeICembc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=q1ctZG1ExliZYEl1j9UgbL5fWkBhYzqHPGSa5Fulyvqo5R4YZ3AhKSu51miqxaGMdsLg+9qVtaj4u8vH7dkv2uR6YcFWiRCAIQZMm96FcHStG0pmPerKqeOFvML3buYdO6ODlALCsIDknDcedbM/TV9X+RS9QWLZ09rATSdjcoQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tJ9tnwPp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3D45C4CEC5; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142760; bh=Tvx8ty3Re4/zz/tINhZ29nrFM+JFehh/c4aSeICembc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tJ9tnwPpM2G25d3OmnOAmTtGzM5P3l3CSxCTDInOpkBInXcFQUKlmaOv2kBKhBOfF Zi8APJLcxptc702OSQ9NrnmCGcDuWfyKlAR2YGfWot4QvXPiacXQVkdMqwTeBUJtAg m0oeE8tEoZjdb9rTng2fWxtBqVcQr918w0nybgi5VmZSEcLD3jH/fPbBvzhloAXEpV Ca6PQTJJAH2S40ual5jkHraw0ucZwABlmW2s4Ctp3IWQXKDWLx7dRZwEZYRusMCKQm UKisrwFZltPioNgpc7mNzSPUiDX6CzSq/yq98FTUmProhEIqZ7FMl7cHaSEYtELwtH DsQOXrasPGfkQ== Received: by pali.im (Postfix) id 7FE5CC01; Thu, 12 Sep 2024 14:05:55 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] cifs: Show debug message when SFU Fifo type was detected Date: Thu, 12 Sep 2024 14:05:45 +0200 Message-Id: <20240912120548.15877-5-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For debugging purposes it is a good idea to show detected SFU type also for Fifo. Debug message is already print for all other special types. Signed-off-by: Pali Rohár --- fs/smb/client/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index d8c39989840e..70c32b40ede0 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -541,6 +541,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, fattr->cf_mode &= ~S_IFMT; if (fattr->cf_eof == 0) { + cifs_dbg(FYI, "Fifo\n"); fattr->cf_mode |= S_IFIFO; fattr->cf_dtype = DT_FIFO; return 0; From patchwork Thu Sep 12 12:05:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984639 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ZesqTLJ+; dkim-atps=neutral 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-2755-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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X4GPp69vVz1y1y for ; Thu, 12 Sep 2024 22:06:38 +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 7367A1F25887 for ; Thu, 12 Sep 2024 12:06:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6BEC1A3053; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZesqTLJ+" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EA721A3040; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; cv=none; b=RirQ6bf/SRbtWc/ofrbfDbD9qsVIlOVo4Orxa5jjDVODAMzzzHp14aAXtE2VFO9+iLKIGeqdwoBx6daH3gQnLYQ/Rum4egy6S/9dD1++sYgTt5lQewv01ueOAHCqi1JxoaHXtq/mFtiZU84Gveqv1syq/7pDvpRf8G+aoWn9v+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; c=relaxed/simple; bh=+uNJ9eLwhQVbYHW30+NUBpqazhheNtp4DLIS254FP3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Y/a0Qmi0oK5ubmZr8AwdDwyukgt2XIDh/THMudlIgr7FNFPS6/pYLMXONzrG3UsmyuTc6TPCMm1hIL2yzt8222tk5iOY+vm/6yZd7SsfSl3HA++NgCeDVQpCwcXWtDjkVoQb5KZp49oCpho4UH2LmEmqCEJJvc9P66AcsE30ByQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZesqTLJ+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E69EFC4CECD; Thu, 12 Sep 2024 12:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142761; bh=+uNJ9eLwhQVbYHW30+NUBpqazhheNtp4DLIS254FP3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZesqTLJ+riVA9kTs5RfICgK1X4tslpnA9nUCNYL1OP0/NhjFTsC4sjfHUPUajPQ1a Eyvx9FHsQpNu2/X9+i9aNOGdbbhWfJu9NpxDOdqCoydW3tBl22pNx+igsgty0/CYgd KVias7Li1zaJo6nhHpRL0TND3Xx7ObIvDY/mqtNQ94EdCgNiLU7L/mCoGUDtOryU5e vd9ZiEXrmukl1QEk6XV7+xb5+NPZXFXBddNjr7j8LhIX8hKxH+AF6m8DAkcN2BR9ux CyJVQ30hbDSANYd8qtZEIi+3UrmnBjMroq8TEEd2ca/CDGqLGbU3djbNY2ESy4TMqS xanDPzLe499PA== Received: by pali.im (Postfix) id A69F0C46; Thu, 12 Sep 2024 14:05:55 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] cifs: Recognize SFU socket type Date: Thu, 12 Sep 2024 14:05:46 +0200 Message-Id: <20240912120548.15877-6-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SFU since its (first) version 3.0 supports AF_LOCAL sockets and stores them on filesytem as system file with one zero byte. Add support for detecting this SFU socket type into cifs_sfu_type() function. With this change cifs_sfu_type() would correctly detect all special file types created by SFU: fifo, socket, symlink, block and char. Signed-off-by: Pali Rohár --- fs/smb/client/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index 70c32b40ede0..331a86074ae7 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -545,7 +545,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, fattr->cf_mode |= S_IFIFO; fattr->cf_dtype = DT_FIFO; return 0; - } else if (fattr->cf_eof < 8) { + } else if (fattr->cf_eof > 1 && fattr->cf_eof < 8) { fattr->cf_mode |= S_IFREG; fattr->cf_dtype = DT_REG; return -EINVAL; /* EOPNOTSUPP? */ @@ -655,6 +655,10 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, fattr->cf_dtype = DT_REG; rc = -EOPNOTSUPP; } + } else if ((rc == 0) && (bytes_read == 1) && (pbuf[0] == '\0')) { + cifs_dbg(FYI, "Socket\n"); + fattr->cf_mode |= S_IFSOCK; + fattr->cf_dtype = DT_SOCK; } else { fattr->cf_mode |= S_IFREG; /* then it is a file */ fattr->cf_dtype = DT_REG; From patchwork Thu Sep 12 12:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984640 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=M4EMxvBj; dkim-atps=neutral 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-2756-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 4X4GPv03s3z1y1y for ; Thu, 12 Sep 2024 22:06:43 +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 98388B21DE6 for ; Thu, 12 Sep 2024 12:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAC741A38F1; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M4EMxvBj" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B23601A305E; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; cv=none; b=dNqhJ+WiD8XG98jVS27Y1eKJOcOZRu8ct0UCpjLsSJ4yLMEj3whNPUYxW9dekMJqunk6SwwA7qx3fmL8fww8rB5pgIo+9Sid6u7UAtqGZPstlJYH9NnuYvS7U6KPhfA+GttvCj5N9TN2RtHrj7b/XDRjACwh7g+/8Mfpax1nfaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142761; c=relaxed/simple; bh=Bx2ZfJxux6Lf9+D4Cr93MpDM5P+eKzzLZZK74b1rWys=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ljZ57Th2kizwYjWo42/Vvy9+99lQbcD/+G/8XxKjRonICoNkq5IWUVAcp+E5iySIaQ3eIfMoM2Mgb82OY2Knq4R76OrjF+wboYZwNRT66ATWLUd+HzOm/noQMwWeKotOsIvYQNe+5EykJ+G597QpYTg2e8e2x4XeCMMpYd6Yej8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M4EMxvBj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0844BC4CED1; Thu, 12 Sep 2024 12:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142761; bh=Bx2ZfJxux6Lf9+D4Cr93MpDM5P+eKzzLZZK74b1rWys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M4EMxvBjYRwd1SfkXm6rirhd4QsPwgr3/2E2vsZgdBTzvA66AtQ/VptkHMWRtDNIv 15G3sfljgrw0gdf5QF3CoPhXPf+H6X17fub4XUr0e1eyDors/d/VR4fPYzNOdQjQC9 CBeeFZdUvASd2w/StgeoNn1CWSIhFL0nFBVR/QRhiMtmomx9ZZ6U0TFL0mrNmW0XHR sIOiiqY3FBPQRd7Mb2UgYMmA+7YBb6RrzqkVf9p4grcliV588yOnW32bKJ/Y77skoX tuaR/6HqaYjuEyQIPZVCg+FhjsiMvbBjPeW0gkOIGtW2v4TMpU24GJW4O6ydhI1LIi sC4c+VRTAhl+g== Received: by pali.im (Postfix) id DC2E0C56; Thu, 12 Sep 2024 14:05:55 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] cifs: Fix creating of SFU fifo and socket special files Date: Thu, 12 Sep 2024 14:05:47 +0200 Message-Id: <20240912120548.15877-7-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SFU-style fifo is empty file with system attribute set. This format is used by old Microsoft POSIX subsystem and later also by OpenNT/Interix subsystem (which replaced Microsoft POSIX subsystem and is part of Microsoft SFU). SFU-style socket is file which has system attribute set and file content is one zero byte. This format was introduced in Interix 3.0 subsystem, as part of the Microsoft SFU 3.0 and is used also by all later versions. Previous versions had no UNIX domain socket support. Currently when sfu mount option is specified then CIFS creates fifo and socket special files with some strange LnxSOCK or LnxFIFO content which is not compatible with Microsoft SFU and neither recognized by other SMB implementations which have some SFU support, including older Linux cifs implementations. So when sfu mount option is specified, create all fifo and socket special files compatible with SFU format to achieve SFU interop, as it is expected by sfu mount option. Signed-off-by: Pali Rohár --- fs/smb/client/cifssmb.c | 8 ++++---- fs/smb/client/smb1ops.c | 2 +- fs/smb/client/smb2ops.c | 29 +++++++++++++++++++---------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c index cfae2e918209..0ffc45aa5e2c 100644 --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -1076,8 +1076,8 @@ SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, pSMB->OpenFlags |= cpu_to_le16(REQ_MORE_INFO); pSMB->Mode = cpu_to_le16(access_flags_to_smbopen_mode(access_flags)); pSMB->Mode |= cpu_to_le16(0x40); /* deny none */ - /* set file as system file if special file such - as fifo and server expecting SFU style and + /* set file as system file if special file such as fifo, + * socket, char or block and server expecting SFU style and no Unix extensions */ if (create_options & CREATE_OPTION_SPECIAL) @@ -1193,8 +1193,8 @@ CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock, req->AllocationSize = 0; /* - * Set file as system file if special file such as fifo and server - * expecting SFU style and no Unix extensions. + * Set file as system file if special file such as fifo, socket, char + * or block and server expecting SFU style and no Unix extensions. */ if (create_options & CREATE_OPTION_SPECIAL) req->FileAttributes = cpu_to_le32(ATTR_SYSTEM); diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index e1f2feb56f45..e03c91a49650 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -1078,7 +1078,7 @@ cifs_make_node(unsigned int xid, struct inode *inode, /* * Check if mounted with mount parm 'sfu' mount parm. * SFU emulation should work with all servers, but only - * supports block and char device (no socket & fifo), + * supports block and char device, socket & fifo, * and was used by default in earlier versions of Windows */ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 9c2d065d3cc4..9e90672caf60 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5066,26 +5066,32 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct cifs_fid fid; unsigned int bytes_written; struct win_dev pdev = {}; + size_t pdev_len = 0; struct kvec iov[2]; __u32 oplock = server->oplocks ? REQ_OPLOCK : 0; int rc; switch (mode & S_IFMT) { case S_IFCHR: + pdev_len = sizeof(pdev); memcpy(pdev.type, "IntxCHR\0", 8); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); break; case S_IFBLK: + pdev_len = sizeof(pdev); memcpy(pdev.type, "IntxBLK\0", 8); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); break; case S_IFSOCK: - strscpy(pdev.type, "LnxSOCK"); + /* SFU socket is system file with one zero byte */ + pdev_len = 1; + pdev.type[0] = '\0'; break; case S_IFIFO: - strscpy(pdev.type, "LnxFIFO"); + /* SFU fifo is system file which is empty */ + pdev_len = 0; break; default: return -EPERM; @@ -5100,14 +5106,17 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, if (rc) return rc; - io_parms.pid = current->tgid; - io_parms.tcon = tcon; - io_parms.length = sizeof(pdev); - iov[1].iov_base = &pdev; - iov[1].iov_len = sizeof(pdev); + if (pdev_len > 0) { + io_parms.pid = current->tgid; + io_parms.tcon = tcon; + io_parms.length = pdev_len; + iov[1].iov_base = &pdev; + iov[1].iov_len = pdev_len; + + rc = server->ops->sync_write(xid, &fid, &io_parms, + &bytes_written, iov, 1); + } - rc = server->ops->sync_write(xid, &fid, &io_parms, - &bytes_written, iov, 1); server->ops->close(xid, tcon, &fid); return rc; } @@ -5149,7 +5158,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode, /* * Check if mounted with mount parm 'sfu' mount parm. * SFU emulation should work with all servers, but only - * supports block and char device (no socket & fifo), + * supports block and char device, socket & fifo, * and was used by default in earlier versions of Windows */ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { From patchwork Thu Sep 12 12:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1984641 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=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=WBTo5NIA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2757-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (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 4X4GQp3mBJz1y1y for ; Thu, 12 Sep 2024 22:07: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 F158E1F27082 for ; Thu, 12 Sep 2024 12:07:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E09881A4E65; Thu, 12 Sep 2024 12:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WBTo5NIA" X-Original-To: linux-cifs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B78C41A4AD7; Thu, 12 Sep 2024 12:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142763; cv=none; b=H+X8Hk+kpH7/PfNi9rprPVcTPr1CIrc3PWdpxe6KgTJU0xv7PPLIW//sBTyea+nviEYNDznf1Ow2RPBxp66U8v9m7YuLqrGgIvNxH5op6iy6xfCxKVwy8dc7D5fziNcCkymIH+uMQkcgXITXhKR4fir1l6Xk+pwGTF5FvXJwDo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726142763; c=relaxed/simple; bh=MTk345+qR8QZ1Q7CJWE+QoFTNgIlouwTcgnEBuCnNIs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LUyk21/n/d6c5N4fYqV1yZdLe//0INaFPpFFiOV06kWw+jFqDH9VbNJbYB5P555V6IbbYUK6uDLY0yEPIiGzx1NllG6urV2JfmcB3AxZ8PE5jcK7w4Ku0GDanNCXTDmXOTtxDyAimeXcWfZHZlQDgEr+GNe79sjd67yEJc1wWKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WBTo5NIA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48AAAC4CED0; Thu, 12 Sep 2024 12:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726142763; bh=MTk345+qR8QZ1Q7CJWE+QoFTNgIlouwTcgnEBuCnNIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WBTo5NIA47GECeiYkbqlGmaKRyW/fJRN7p9M6Z8rfuMHcimuFYyDJYckxSRIKqqmX +xbI7itEF0k32MOpJtvJl2tTEeQtH3Mh+vg6U8rXQbVIXbn7yVuWWybKkQcgqmFGiQ Xj2o0qcPlAeBuMciAkYCGsz81mbFf66SR5SB4LKGingF9QBboM4KYOH2w3XWbIKKMk AFw2jME0VH/YtbSHz1PjN+px2zv7Y3Lidz2Hv1yMq9gjNy/cKDdl2m4qoWBosFuG9e iXf78GA/3iITJMwWJefUG89dZ6BNt2HVkMF0QBXalvlUpxQZ+2ByFbjtP6JSho64ZF fq20kRVY+aHTQ== Received: by pali.im (Postfix) id 1FAB1C59; Thu, 12 Sep 2024 14:05:56 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara , Ronnie Sahlberg Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] cifs: Add support for creating SFU symlinks Date: Thu, 12 Sep 2024 14:05:48 +0200 Message-Id: <20240912120548.15877-8-pali@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240912120548.15877-1-pali@kernel.org> References: <20240912120548.15877-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When 'sfu' mount option is specified and 'mfsymlinks' is not specified then create new symlinks in SFU-style. This will provide full SFU compatibility when mounting share with 'sfu' option. 'mfsymlinks' override SFU for better Apple compatibility as explained in fs_context.c smb3_update_mnt_flags() function. Extend __cifs_sfu_make_node() function, which now can handle also S_IFLNK type and refactor structures passed to sync_write() in this function, by splitting SFU type ("IntxCHR\0", "IntxBLK\0", "IntxLNK\1", "\0", "") and SFU data from original combined struct win_dev (which could be used only for block and char devices which had major and minor parts). This is needed because type is variable-length and data is type specific. Signed-off-by: Pali Rohár --- fs/smb/client/cifspdu.h | 6 ---- fs/smb/client/cifsproto.h | 4 +++ fs/smb/client/fs_context.c | 13 ++++--- fs/smb/client/link.c | 3 ++ fs/smb/client/smb2ops.c | 71 +++++++++++++++++++++++++++----------- 5 files changed, 66 insertions(+), 31 deletions(-) diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h index a2072ab9e586..c3b6263060b0 100644 --- a/fs/smb/client/cifspdu.h +++ b/fs/smb/client/cifspdu.h @@ -2573,12 +2573,6 @@ typedef struct { } __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ -struct win_dev { - unsigned char type[8]; /* IntxCHR or IntxBLK or LnxFIFO or LnxSOCK */ - __le64 major; - __le64 minor; -} __attribute__((packed)); - struct fea { unsigned char EA_flags; __u8 name_len; diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 497bf3c447bc..791bddac0396 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -676,6 +676,10 @@ char *extract_sharename(const char *unc); int parse_reparse_point(struct reparse_data_buffer *buf, u32 plen, struct cifs_sb_info *cifs_sb, bool unicode, struct cifs_open_info_data *data); +int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, + struct dentry *dentry, struct cifs_tcon *tcon, + const char *full_path, umode_t mode, dev_t dev, + const char *symname); int cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, const char *full_path, umode_t mode, dev_t dev); diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c index bc926ab2555b..2f0c3894b0f7 100644 --- a/fs/smb/client/fs_context.c +++ b/fs/smb/client/fs_context.c @@ -1896,14 +1896,17 @@ void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb) if (ctx->mfsymlinks) { if (ctx->sfu_emul) { /* - * Our SFU ("Services for Unix" emulation does not allow - * creating symlinks but does allow reading existing SFU - * symlinks (it does allow both creating and reading SFU - * style mknod and FIFOs though). When "mfsymlinks" and + * Our SFU ("Services for Unix") emulation allows now + * creating new and reading existing SFU symlinks. + * Older Linux kernel versions were not able to neither + * read existing nor create new SFU symlinks. But + * creating and reading SFU style mknod and FIFOs was + * supported for long time. When "mfsymlinks" and * "sfu" are both enabled at the same time, it allows * reading both types of symlinks, but will only create * them with mfsymlinks format. This allows better - * Apple compatibility (probably better for Samba too) + * Apple compatibility, compatibility with older Linux + * kernel clients (probably better for Samba too) * while still recognizing old Windows style symlinks. */ cifs_dbg(VFS, "mount options mfsymlinks and sfu both enabled\n"); diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c index 80099bbb333b..47ddeb7fa111 100644 --- a/fs/smb/client/link.c +++ b/fs/smb/client/link.c @@ -606,6 +606,9 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode, /* BB what if DFS and this volume is on different share? BB */ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { rc = create_mf_symlink(xid, pTcon, cifs_sb, full_path, symname); + } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { + rc = __cifs_sfu_make_node(xid, inode, direntry, pTcon, + full_path, S_IFLNK, 0, symname); #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY } else if (pTcon->unix_ext) { rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 9e90672caf60..b77a62ccec5c 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5055,9 +5055,10 @@ static int smb2_next_header(struct TCP_Server_Info *server, char *buf, return 0; } -static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, +int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, - const char *full_path, umode_t mode, dev_t dev) + const char *full_path, umode_t mode, dev_t dev, + const char *symname) { struct TCP_Server_Info *server = tcon->ses->server; struct cifs_open_parms oparms; @@ -5065,36 +5066,61 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); struct cifs_fid fid; unsigned int bytes_written; - struct win_dev pdev = {}; - size_t pdev_len = 0; - struct kvec iov[2]; + u8 type[8]; + int type_len = 0; + struct { + __le64 major; + __le64 minor; + } __packed pdev = {}; + __le16 *symname_utf16 = NULL; + u8 *data = NULL; + int data_len = 0; + struct kvec iov[3]; __u32 oplock = server->oplocks ? REQ_OPLOCK : 0; int rc; switch (mode & S_IFMT) { case S_IFCHR: - pdev_len = sizeof(pdev); - memcpy(pdev.type, "IntxCHR\0", 8); + type_len = 8; + memcpy(type, "IntxCHR\0", type_len); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); + data = (u8 *)&pdev; + data_len = sizeof(pdev); break; case S_IFBLK: - pdev_len = sizeof(pdev); - memcpy(pdev.type, "IntxBLK\0", 8); + type_len = 8; + memcpy(type, "IntxBLK\0", type_len); pdev.major = cpu_to_le64(MAJOR(dev)); pdev.minor = cpu_to_le64(MINOR(dev)); + data = (u8 *)&pdev; + data_len = sizeof(pdev); + break; + case S_IFLNK: + type_len = 8; + memcpy(type, "IntxLNK\1", type_len); + symname_utf16 = cifs_strndup_to_utf16(symname, strlen(symname), + &data_len, cifs_sb->local_nls, + NO_MAP_UNI_RSVD); + if (!symname_utf16) { + rc = -ENOMEM; + goto out; + } + data_len -= 2; /* symlink is without trailing wide-nul */ + data = (u8 *)symname_utf16; break; case S_IFSOCK: /* SFU socket is system file with one zero byte */ - pdev_len = 1; - pdev.type[0] = '\0'; + type_len = 1; + type[0] = '\0'; break; case S_IFIFO: /* SFU fifo is system file which is empty */ - pdev_len = 0; + type_len = 0; break; default: - return -EPERM; + rc = -EPERM; + goto out; } oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, GENERIC_WRITE, @@ -5104,20 +5130,25 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, rc = server->ops->open(xid, &oparms, &oplock, NULL); if (rc) - return rc; + goto out; - if (pdev_len > 0) { + if (type_len + data_len > 0) { io_parms.pid = current->tgid; io_parms.tcon = tcon; - io_parms.length = pdev_len; - iov[1].iov_base = &pdev; - iov[1].iov_len = pdev_len; + io_parms.length = type_len + data_len; + iov[1].iov_base = type; + iov[1].iov_len = type_len; + iov[2].iov_base = data; + iov[2].iov_len = data_len; rc = server->ops->sync_write(xid, &fid, &io_parms, - &bytes_written, iov, 1); + &bytes_written, iov, 2); } server->ops->close(xid, tcon, &fid); + +out: + kfree(symname_utf16); return rc; } @@ -5129,7 +5160,7 @@ int cifs_sfu_make_node(unsigned int xid, struct inode *inode, int rc; rc = __cifs_sfu_make_node(xid, inode, dentry, tcon, - full_path, mode, dev); + full_path, mode, dev, NULL); if (rc) return rc;