From patchwork Tue Oct 20 07:08:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11845861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5293C433E7 for ; Tue, 20 Oct 2020 07:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A5F42237B for ; Tue, 20 Oct 2020 07:08:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qxvLq8tX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728313AbgJTHIw (ORCPT ); Tue, 20 Oct 2020 03:08:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbgJTHIv (ORCPT ); Tue, 20 Oct 2020 03:08:51 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAE6C061755 for ; Tue, 20 Oct 2020 00:08:51 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id a28so880993ljn.3 for ; Tue, 20 Oct 2020 00:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Jxa0yeBUMZBSJbdC+QO/5jCPZ5PnwioZbq+aJtj5Y/g=; b=qxvLq8tXoy21swqT2UFOusLm8SW85WMEGJqXAvLbmIGy1h3qAC9N1Lo6b/xuWf0J64 JQT3OxG839980w1/3cBhZFcyWz7ezr0UBYE/SDYz3IEihwXI4wjzRqKsLRkeuAdBYIbk FrnVuPaD7YGDHwp+NnXkKhvy5s2YrNz7RUXBYPB2Eix3uXKBctznEtx87UB4vdPVqzbx 1T4/f7vSoGHQVO48IGPhtxqrb/R1hWz2LbGi/JaliArlRX4AVFbuQtP5FNhEMwZDVWDE Y7j+pmcf6I2Z5kVF9Y+1KQZ6jkZKs0cKIC1AlFAo/ndDSFQlpwPwZlW/taA1hkkzMbcN MzlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Jxa0yeBUMZBSJbdC+QO/5jCPZ5PnwioZbq+aJtj5Y/g=; b=pycXMux9gA0zWABQEm+UrdUUQrNLAiBsOCvqu3hmyZGhFYU+K8CNyDZQVwFfr1mKiM Qu1Z7tSQoeH6MLKqQXrdVACFeR7XcYJVAeJH3dc5GjfAH4AA4iKaabqICLZHvKJiRJ8f TaOhySuZ4wpHN+a/TZoXrUXncQ0Yy4kvipE/iDkGtgtqY9FEOthJf9ElZt+8vA1AzKSy lpV9Cj9Rj6mVnQmM72ju5VRqigu6aTwqELtXKgRZvpOMLRtE+WA49HHcj+SHBLPyOfui OtwweLwUtX7wsQkK5RDDwhnyryrmsbQ/M78l11xbKsRmgirsr45RQy6j4lCa927QR9cS /cGg== X-Gm-Message-State: AOAM532guod9HABNed0VJcZzYfAp6IC0d0zlsmN8zkv5sGdzsTnrbiR5 Lh1NN8bduhVXj8p/3Qlf/5gkn+s2kQ6HlwXMHsP/Gd0MDob20Q== X-Google-Smtp-Source: ABdhPJwRHJPtCoNdL5PiVqoSI5GOrSkNEmfk/1UfamnexzPrwPFouFPBkprjcp/dkfwiZXl4WR008ivkl2b7S4nErrI= X-Received: by 2002:a05:651c:2db:: with SMTP id f27mr525013ljo.394.1603177729518; Tue, 20 Oct 2020 00:08:49 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 20 Oct 2020 02:08:38 -0500 Message-ID: Subject: [SMB3.1.1][PATCH] SMB3.1.1: Fix ids returned in POSIX query dir To: CIFS Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We were setting the uid/gid to the default in each dir entry in the parsing of the POSIX query dir response, rather than attempting to map the user and group SIDs returned by the server to well known SIDs (or upcall if not found). I noticed that Samba server (Jeremy's POSIX branch) returns well known sid for the group but not for the owner (e.g. S-1-22-2-1000 for the group but a complex SID for the user owner) but at least even if cifs upcall is not configured we still get the group owner displayed correctly. Reviewed-by: Aurelien Aptel From b9b8a181a05d384ec92bd2ef415dea0665811a8b Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 20 Oct 2020 02:02:02 -0500 Subject: [PATCH] SMB3.1.1: Fix ids returned in POSIX query dir We were setting the uid/gid to the default in each dir entry in the parsing of the POSIX query dir response, rather than attempting to map the user and group SIDs returned by the server to well known SIDs (or upcall if not found). CC: Stable Signed-off-by: Steve French --- fs/cifs/cifsacl.c | 5 +++-- fs/cifs/cifsproto.h | 2 ++ fs/cifs/readdir.c | 5 ++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index fcff14ef1c70..23b21e943652 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -338,7 +338,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct cifs_sid *ssid) goto out_key_put; } -static int +int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, struct cifs_fattr *fattr, uint sidtype) { @@ -359,7 +359,8 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, return -EIO; } - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) { + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) || + (cifs_sb_master_tcon(cifs_sb)->posix_extensions)) { uint32_t unix_id; bool is_group; diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index bb68cbf81074..24c6f36177ba 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -209,6 +209,8 @@ extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs, extern int cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, const unsigned int xid); +extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, + struct cifs_fattr *fattr, uint sidtype); extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, struct inode *inode, bool get_mode_from_special_sid, diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 31a18aae5e64..5abf1ea21abe 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -267,9 +267,8 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info, if (reparse_file_needs_reval(fattr)) fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; - /* TODO map SIDs */ - fattr->cf_uid = cifs_sb->mnt_uid; - fattr->cf_gid = cifs_sb->mnt_gid; + sid_to_id(cifs_sb, &parsed.owner, fattr, SIDOWNER); + sid_to_id(cifs_sb, &parsed.group, fattr, SIDGROUP); } static void __dir_info_to_fattr(struct cifs_fattr *fattr, const void *info) -- 2.25.1