When you mount a CIFS folder, the permissions get masked by the user created in the SMB server.
So, let’s say you have the Samba server on TrueNAS Core running under the user media. You then connect on Ubuntu from the linux root user, using the SMB user media, to the CIFS share. On the mount point, i.e. in Ubuntu, you will see ownership as root, but in the backend, on TrueNAS, it will still be the user media.
If you unmount the CIFS from Ubuntu and mount it on the same Ubuntu box, but under a different user, like say pi, using the same credentials (media), the ownership of the files in the CIFS mount will now appear as pi, instead of root, but in the backend, the owner is still media on TrueNAS.
This is the opposite of NFS mounts, where the ownership uid:gid stays the same on both the client and the server. This makes Samba quite nice and not have to worry about a lot of stuff, despite it being a bit of a bigger and more (network) talkative piece of software. On NFS, I have to use the same UID and GID when creating users, because if I would have a user with UID 1000 on Ubuntu, say foo, and creating a file on a NFS share, on the NFS server, I’d either see ownership as 1000 if there is no user with that UID, or I’d see, say, bar, as the owner, but the UID is the same for both of them.
Yeah, SMB just masks the ownership on the backend, so as long as you use the same SMB user to login to the TrueNAS Core server, you won’t see permission issues.