--- zzzz-none-000/linux-4.1.52/fs/overlayfs/super.c 2018-05-28 02:26:45.000000000 +0000 +++ bcm63-7530ax-731/linux-4.1.52/fs/overlayfs/super.c 2022-03-02 11:37:13.000000000 +0000 @@ -42,6 +42,10 @@ long lower_namelen; /* pathnames of lower and upper dirs, for show_options */ struct ovl_config config; +#if defined(CONFIG_BCM_KF_OVERLAYFS_BACKPORTS) + /* creds of process who forced instantiation of super block */ + const struct cred *creator_cred; +#endif }; struct ovl_dir_cache; @@ -202,6 +206,15 @@ return oe->opaque; } +#if defined(CONFIG_BCM_KF_OVERLAYFS_BACKPORTS) +const struct cred *ovl_override_creds(struct super_block *sb) +{ + struct ovl_fs *ofs = sb->s_fs_info; + + return override_creds(ofs->creator_cred); +} +#endif + void ovl_dentry_set_opaque(struct dentry *dentry, bool opaque) { struct ovl_entry *oe = dentry->d_fsdata; @@ -482,6 +495,9 @@ kfree(ufs->config.lowerdir); kfree(ufs->config.upperdir); kfree(ufs->config.workdir); +#if defined(CONFIG_BCM_KF_OVERLAYFS_BACKPORTS) + put_cred(ufs->creator_cred); +#endif kfree(ufs); } @@ -985,10 +1001,20 @@ sb->s_d_op = &ovl_dentry_operations; +#if defined(CONFIG_BCM_KF_OVERLAYFS_BACKPORTS) + ufs->creator_cred = prepare_creds(); + if (!ufs->creator_cred) + goto out_put_lower_mnt; +#endif + err = -ENOMEM; oe = ovl_alloc_entry(numlower); if (!oe) +#if defined(CONFIG_BCM_KF_OVERLAYFS_BACKPORTS) + goto out_put_cred; +#else goto out_put_lower_mnt; +#endif root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, oe)); if (!root_dentry) @@ -1021,6 +1047,10 @@ out_free_oe: kfree(oe); +#if defined(CONFIG_BCM_KF_OVERLAYFS_BACKPORTS) +out_put_cred: + put_cred(ufs->creator_cred); +#endif out_put_lower_mnt: for (i = 0; i < ufs->numlower; i++) mntput(ufs->lower_mnt[i]);