lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241222154340.24104-3-pali@kernel.org>
Date: Sun, 22 Dec 2024 16:43:38 +0100
From: Pali Rohár <pali@...nel.org>
To: Steve French <sfrench@...ba.org>,
	Paulo Alcantara <pc@...guebit.com>,
	Ronnie Sahlberg <ronniesahlberg@...il.com>
Cc: linux-cifs@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 2/4] cifs: Add a new xattr system.reparse for querying repase point from SMB server

Currently SMB client fetches and parses only few reparse point types,
those which directly maps to Linux file types.

This change introduce a new xattr system.reparse which allows userspace
application to query reparse point buffer and then let application to parse
and handle it as needed.

Currently only get xattr is implemented. Setting new reparse point,
changing it or deleting via set xattr is not implemented yet.

Signed-off-by: Pali Rohár <pali@...nel.org>
---
 fs/smb/client/xattr.c | 46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/fs/smb/client/xattr.c b/fs/smb/client/xattr.c
index b88fa04f5792..7fb7662afaea 100644
--- a/fs/smb/client/xattr.c
+++ b/fs/smb/client/xattr.c
@@ -39,7 +39,10 @@
 #define SMB3_XATTR_CREATETIME "smb3.creationtime"  /* user.smb3.creationtime */
 /* BB need to add server (Samba e.g) support for security and trusted prefix */
 
+#define SMB_XATTR_REPARSE "system.reparse"
+
 enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
+	XATTR_REPARSE,
 	XATTR_CIFS_NTSD_SACL, XATTR_CIFS_NTSD_OWNER,
 	XATTR_CIFS_NTSD, XATTR_CIFS_NTSD_FULL };
 
@@ -162,6 +165,11 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
 		}
 		break;
 
+	case XATTR_REPARSE:
+		/* TODO: Implementing setting, changing and deleting reparse point */
+		rc = -EOPNOTSUPP;
+		break;
+
 	case XATTR_CIFS_ACL:
 	case XATTR_CIFS_NTSD_SACL:
 	case XATTR_CIFS_NTSD_OWNER:
@@ -319,6 +327,36 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
 				full_path, name, value, size, cifs_sb);
 		break;
 
+	case XATTR_REPARSE: {
+		struct reparse_data_buffer *reparse_buf;
+		int rsp_buftype = CIFS_NO_BUFFER;
+		struct kvec rsp_iov = {};
+		u32 reparse_len;
+		u32 tag;
+
+		if (!pTcon->ses->server->ops->query_reparse_point)
+			goto out;
+
+		rc = pTcon->ses->server->ops->query_reparse_point(xid, pTcon,
+			cifs_sb, full_path, &tag, &rsp_iov, &rsp_buftype);
+		if (rc)
+			goto out;
+
+		reparse_buf = pTcon->ses->server->ops->get_reparse_point_buffer(&rsp_iov,
+										&reparse_len);
+
+		if (value) {
+			if (reparse_len > size)
+				reparse_len = -ERANGE;
+			else
+				memcpy(value, reparse_buf, reparse_len);
+		}
+		rc = reparse_len;
+
+		free_rsp_buf(rsp_buftype, rsp_iov.iov_base);
+		break;
+	}
+
 	case XATTR_CIFS_ACL:
 	case XATTR_CIFS_NTSD_SACL:
 	case XATTR_CIFS_NTSD_OWNER:
@@ -448,6 +486,13 @@ static const struct xattr_handler cifs_os2_xattr_handler = {
 	.set = cifs_xattr_set,
 };
 
+static const struct xattr_handler cifs_reparse_xattr_handler = {
+	.name = SMB_XATTR_REPARSE,
+	.flags = XATTR_REPARSE,
+	.get = cifs_xattr_get,
+	.set = cifs_xattr_set,
+};
+
 static const struct xattr_handler cifs_cifs_acl_xattr_handler = {
 	.name = CIFS_XATTR_CIFS_ACL,
 	.flags = XATTR_CIFS_ACL,
@@ -525,6 +570,7 @@ static const struct xattr_handler smb3_ntsd_full_xattr_handler = {
 const struct xattr_handler * const cifs_xattr_handlers[] = {
 	&cifs_user_xattr_handler,
 	&cifs_os2_xattr_handler,
+	&cifs_reparse_xattr_handler,
 	&cifs_cifs_acl_xattr_handler,
 	&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
 	&smb3_ntsd_sacl_xattr_handler,
-- 
2.20.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ