linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 2 error cases in sid_to_id are ignored
@ 2021-06-21 20:57 Steve French
  2021-06-22 10:18 ` Aurélien Aptel
  0 siblings, 1 reply; 4+ messages in thread
From: Steve French @ 2021-06-21 20:57 UTC (permalink / raw)
  To: Shyam Prasad N; +Cc: CIFS

There are two cases (see below) in sid_to_id where errors occur
mapping the uid but the rc  which is set is overwritten (reset to 0
before return).

        saved_cred = override_creds(root_cred);
        sidkey = request_key(&cifs_idmap_key_type, sidstr, "");
        if (IS_ERR(sidkey)) {
                rc = -EINVAL;
                cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n",
                         __func__, sidstr, sidtype == SIDOWNER ? 'u' : 'g');
                goto out_revert_creds;
        }

        /*
         * FIXME: Here we assume that uid_t and gid_t are same size. It's
         * probably a safe assumption but might be better to check based on
         * sidtype.
         */
        BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t));
        if (sidkey->datalen != sizeof(uid_t)) {
                rc = -EIO;
                cifs_dbg(FYI, "%s: Downcall contained malformed key
(datalen=%hu)\n",
                         __func__, sidkey->datalen);
                key_invalidate(sidkey);
                goto out_key_put;
        }



since later in the function we do:



out_key_put:
        key_put(sidkey);
out_revert_creds:
        revert_creds(saved_cred);
        kfree(sidstr);

        /*
         * Note that we return 0 here unconditionally. If the mapping
         * fails then we just fall back to using the ctx->linux_uid/linux_gid.
         */
got_valid_id:
        rc = 0;
        if (sidtype == SIDOWNER)
                fattr->cf_uid = fuid;
        else
                fattr->cf_gid = fgid;
        return rc;
}


Any thoughts on whether it would be better to return the errors, or
continue the current strategy of simply using the default uid/gid for
the mount and returning 0 (and removing the two places above where we
set rc to non zero values, since rc will be overwritten with 0)?


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-22 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 20:57 2 error cases in sid_to_id are ignored Steve French
2021-06-22 10:18 ` Aurélien Aptel
2021-06-22 19:05   ` Steve French
2021-06-22 19:16     ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).