From patchwork Sun Feb 11 23:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 13552651 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (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 E020D14A96 for ; Sun, 11 Feb 2024 23:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707694216; cv=pass; b=LHtPb9542jAGdtr1uaYJEkm5svgO4+kWnByKJRoNW+kejafDQn9IabsjV0aMOtintUwG4JLqQWX3ruf5hlGw/3RLOOgwbEiKXmZCHVLH4gF/+9EFOw/Q/fcDngmBf5UE0B9PWFW0EQ6Ysf5mXqu6LNSx7GwdFlrBshnRDTAHHMQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707694216; c=relaxed/simple; bh=IqiVs3gKh7IoGULlKYd1iA7e5jyHG0Na7Y/l7OB4hxY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AU6gejIabuWThUfWIVBstUs8GsdOs7gGwqUG/68k4ZCZBvTKg9ArlBNs1SDZ4XiexQKpiFeO3XGhu2IuUZBZYXVP+I/Kf1vHwwgz3k0R8Wugl0PXxj/g/LFQ8pIB6TBKAYctmqN1lL/F86eOUn1l/CFS9cpiJc3zxLlF/EPy9XM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=QzYzwGXi; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="QzYzwGXi" From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1707693645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CCeY2cxRdpkSGSfnNxsw6DBIuq4vr/0ARrZcgwVVxPs=; b=QzYzwGXidfPANV08bIT+rqWYYRzt47MDVX7WPDwRj3/b9pML/0nidsb+PrJnzA0KnrcjJ7 n8Ng7ZEZQChDN5R3Eupx5v3CM1yheBuEnHWp7tEDJSBWjbUkWkB7bAEjUuGzhmXzqlup+z SZayxcpuMhD1R62dWI8OzUfw+EXGKqrSbMq9E3cMPOfqR9cyKUIQWPlxbUsxV5ts0yiZUR UEvhbw+CbTkhSzEAzAjyoxG+WRbbrQ38sQ32V/1T5MTdIn2EhhxDFGZM1rR6WL4B4P2BIX iC02YSV9zJ89Kyl6tw5Gpwx0ghfpIZPMS6T5AKcA4e3Rf4oc3ilb8+L80lW38g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1707693645; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=CCeY2cxRdpkSGSfnNxsw6DBIuq4vr/0ARrZcgwVVxPs=; b=LNMFMNf0Bs6Orh7Hx0xHAaj+3nX/qqpeKcrP9SLOZnEcnfiiLw/8lyiAT2a5o2JEwhd6dX x+xZ22sn25hcaYXIV3CsTVaVgd9WLeyrGJs/0Nu7U8l6Tuf8ro1R5KsGvwuVjq7ORYxylj oB2WPiFb7FCL3vdLQEsHZZIDq6fqeMMzD0b4OWl2VwVjA44e2mEV5JpbItf/Vj1sjrOdNq m5vzqxq/Lu40hYwjgVLxZ864GIO/I2atg4zmfcyTEtH8Y3HvkNKbvt5UsLbs758I9mk2sl 11mPWThxOBC/ylzkWgZheFRaUL3v+dMvOGHsDgM5t+MzgqJlFSk57+skJUMEgQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1707693645; a=rsa-sha256; cv=none; b=X6DNWoD+pVz2R9wOeb09jvu3juGY6wZak5HaBG53q0mElbQNdlCqCcC7JhdAld4aj73pF9 jWJkFvHe4g12yI0n9PNZG9wIwfwmQQCeMeTI1c7HdMtR/hMNmqHQ/vhl/STMYEfF1sbqwF M2iLprUn98w9M7qRgRYxR0h/4+VpwUidN/GOnsFJ+hSi9n/PiLaplJ6+OYhzeAf6g7Xxaa kSZs6ND2Q18Q2ZCvR+T5bFfLoipC1Lg8Cyfk4BJt785sD9GhiXPbZRN7eQogmuDb8AjED1 iEIjcbK+eKeGGXX9NAY4olwOgULOTtkbTJlgF+L80XSH/CVcTohwuS2j90cajg== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara , Shane Nehring Subject: [PATCH 1/2] smb: client: set correct id, uid and cruid for multiuser automounts Date: Sun, 11 Feb 2024 20:19:30 -0300 Message-ID: <20240211231931.185193-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When uid, gid and cruid are not specified, we need to set dynamically set them into the filesystem context used for automounting otherwise they'll end up reusing the values from the parent mount. Fixes: 9fd29a5bae6e ("cifs: use fs_context for automounts") Reported-by: Shane Nehring Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2259257 Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/namespace.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/smb/client/namespace.c b/fs/smb/client/namespace.c index a6968573b775..4a517b280f2b 100644 --- a/fs/smb/client/namespace.c +++ b/fs/smb/client/namespace.c @@ -168,6 +168,21 @@ static char *automount_fullpath(struct dentry *dentry, void *page) return s; } +static void fs_context_set_ids(struct smb3_fs_context *ctx) +{ + kuid_t uid = current_fsuid(); + kgid_t gid = current_fsgid(); + + if (ctx->multiuser) { + if (!ctx->uid_specified) + ctx->linux_uid = uid; + if (!ctx->gid_specified) + ctx->linux_gid = gid; + } + if (!ctx->cruid_specified) + ctx->cred_uid = uid; +} + /* * Create a vfsmount that we can automount */ @@ -205,6 +220,7 @@ static struct vfsmount *cifs_do_automount(struct path *path) tmp.leaf_fullpath = NULL; tmp.UNC = tmp.prepath = NULL; tmp.dfs_root_ses = NULL; + fs_context_set_ids(&tmp); rc = smb3_fs_context_dup(ctx, &tmp); if (rc) { From patchwork Sun Feb 11 23:19:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Alcantara X-Patchwork-Id: 13552650 Received: from mx.manguebit.com (mx.manguebit.com [167.235.159.17]) (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 E01D712E52 for ; Sun, 11 Feb 2024 23:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=167.235.159.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707694215; cv=pass; b=E1vaiE7rqJ+U4GJ0nPsQwvfHBf28rJgUnwN8WmvqT2t8nsmFivGU6MeOu2ujln71W8WOdOPV7uSmsIYSnxk9PeswRhtKzHsWa3kiIfmRLLru9qLBQQ5THgxXsboViL6E0AjyKTnpR+P5fXeMkOdHNtEQYXtqV4F3D0CqX8Al0S8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707694215; c=relaxed/simple; bh=k3K6did4C2wW4aUWpXJhkdUZ/iT2GFKmHTfeHOxA62A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nxWNTsoXglm/hGqj0TiLzN4h16TJ/7iIRMFULVKQDNrd5z+wlM6k/vYippifaT+6MVBIXdxGdBtY0Ic9kfkzCIGYqyTzxnOwsRA2oELAZqiKxIhj9jadt+ibdUQTvvMoJQ3FbTo9xNvnsaUEEHXQrK5KUGyb+sdMrqb3Q1iLI9M= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com; spf=pass smtp.mailfrom=manguebit.com; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b=A5F5DuMX; arc=pass smtp.client-ip=167.235.159.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.com header.i=@manguebit.com header.b="A5F5DuMX" From: Paulo Alcantara DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1707693647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iZ0Bf7d9JLDl+KIPMEGMvlf2V54ODdk/m17lSJiWIDI=; b=A5F5DuMXKESBaDyp0XwCdi63Ixj56LOsG3VirXzGHq0GBiDtm+VsM0tDs8PPQVs67KDz4D hrGpHiHAJ7kCpC8nbQiwBggbTHVOQ2CVCqyQBpe43VLmx7ND3CgYvQrSDAJ2ZFlSyyADD8 mmmWeLyp8RN9sq2y5w2TzJAXA0ztoFooLB/rDpB+NUmjzLuDIvgl/pn2tMi+jfnOz3WH9e SmZQF1d02+6E9AvS/uPZEpXqM7UNnH3LqPiQFsRf+xtke7JIrEKWO0/kMm/ek5v8TSowbP nZ2InA9z71mD0fRzu6ZTn0m55+a93xY8lDw2drfsTCxiVd++C/q4rFIH8SiguA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=manguebit.com; s=dkim; t=1707693647; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iZ0Bf7d9JLDl+KIPMEGMvlf2V54ODdk/m17lSJiWIDI=; b=hgcSzTmy5vemmrIPaAH62W5VTU/kZBG3TIVQjqJPGyzXL/JUFt3FYPWLLIlDNFT1xGnnan WSboBq52yolPpvknlBFK6XMhdfeWHYA2Uv9aa0A5v76i4Ed082gWnK/k7EKfIyBq8ST0Ph GlIMW7zCe6C3mD10YKhahuUUZVFqkhqEo//bAi7TxOL+bVzSTBYdDOfUKf6dBtyJmnifjf fYzU8CSzLhe2Py1+bJZuuiLvPWBTeh/A6rhviEyIodtvSKes5iIlA0Rpzq4cAePKBNu5t1 d/X1/c8sxUeQs00eEQGR3K3gRtGt1wQX+90ERrL6tTckXDGynaxqlXBaACt4zQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.mailfrom=pc@manguebit.com ARC-Seal: i=1; s=dkim; d=manguebit.com; t=1707693647; a=rsa-sha256; cv=none; b=d92t79y6f18zWVQ/2L6/xLQiCNqYbU43oOKeHzSQUhoPwFP5wdejDhZzqI+0DeHi7HeyPX z+/aEHZ9Pq+G2RsW8ZWRLygFZRhGYB+r3QKk8QODj2oxW7aGKqsFhoSBeOOMsVmjTAja97 6j6VRghi74z9VWW2S/JDT9UloNNSbYDmO35Zb9Hn3liJ8LeGJJoAJ4GlaXlDUCw0RWaK5Q Gpja+52lizR1uKzV3yiZMru3hLAwe31Xfhd98DkYTcSrTKskWWR3SaVKo+ylCDNQGgYWIg 5QUZG7anejFFfFuY4WLpK/RF8joHz/66HfDCPt2e/nF2Uxe+xMENCpHbXLnxjA== To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Paulo Alcantara Subject: [PATCH 2/2] smb: client: handle path separator of created SMB symlinks Date: Sun, 11 Feb 2024 20:19:31 -0300 Message-ID: <20240211231931.185193-2-pc@manguebit.com> In-Reply-To: <20240211231931.185193-1-pc@manguebit.com> References: <20240211231931.185193-1-pc@manguebit.com> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert path separator to CIFS_DIR_SEP(cifs_sb) from symlink target before sending it over the wire otherwise the created SMB symlink may become innaccesible from server side. Fixes: 514d793e27a3 ("smb: client: allow creating symlinks via reparse points") Signed-off-by: Paulo Alcantara (Red Hat) --- fs/smb/client/smb2ops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 6b3c384ead0d..4695433fcf39 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -5217,7 +5217,7 @@ static int smb2_create_reparse_symlink(const unsigned int xid, struct inode *new; struct kvec iov; __le16 *path; - char *sym; + char *sym, sep = CIFS_DIR_SEP(cifs_sb); u16 len, plen; int rc = 0; @@ -5231,7 +5231,8 @@ static int smb2_create_reparse_symlink(const unsigned int xid, .symlink_target = sym, }; - path = cifs_convert_path_to_utf16(symname, cifs_sb); + convert_delimiter(sym, sep); + path = cifs_convert_path_to_utf16(sym, cifs_sb); if (!path) { rc = -ENOMEM; goto out; @@ -5254,7 +5255,10 @@ static int smb2_create_reparse_symlink(const unsigned int xid, buf->PrintNameLength = cpu_to_le16(plen); memcpy(buf->PathBuffer, path, plen); buf->Flags = cpu_to_le32(*symname != '/' ? SYMLINK_FLAG_RELATIVE : 0); + if (*sym != sep) + buf->Flags = cpu_to_le32(SYMLINK_FLAG_RELATIVE); + convert_delimiter(sym, '/'); iov.iov_base = buf; iov.iov_len = len; new = smb2_get_reparse_inode(&data, inode->i_sb, xid,