tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: misuse of pathnames in rump (and portalfs?)



On Wed, Nov 24, 2010 at 08:30:18PM +0200, Antti Kantee wrote:
 > > I think it makes more sense for doregister to check for at least one
 > > leading '/' and remove the leading slashes before storing the key.
 > > Then the key will match the name passed by lookup; otherwise the
 > > leading slash won't be there and it won't match. (What I suggested
 > > last night is broken because it doesn't do this.)
 > 
 > Ah, yea, the leading slashes will be stripped for lookup, so we can't
 > get an exact match for those anyway.
 > 
 > So, let's define it as "string beginning with /, leading /'s collapsed
 > to 1".

Ok. See below (replaces the patch upthread):

 > > All users I can find pass an absolute path.
 > 
 > ok, good

diff -r 66985053a079 sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Wed Nov 24 01:34:10 2010 -0500
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Wed Nov 24 15:41:26 2010 -0500
@@ -324,6 +324,13 @@ doregister(const char *key, const char *
        devminor_t dmin = -1;
        int hft, error;
 
+       if (key[0] != '/') {
+               return EINVAL;
+       }
+       while (key[0] == '/') {
+               key++;
+       }
+
        if (rumpuser_getfileinfo(hostpath, &fsize, &hft, &error))
                return error;
 
@@ -396,7 +403,7 @@ doregister(const char *key, const char *
 
        if (ftype == RUMP_ETFS_BLK) {
                format_bytes(buf, sizeof(buf), size);
-               aprint_verbose("%s: hostpath %s (%s)\n", key, hostpath, buf);
+               aprint_verbose("/%s: hostpath %s (%s)\n", key, hostpath, buf);
        }
 
        return 0;
@@ -641,13 +648,15 @@ rump_vop_lookup(void *v)
        if (dvp == rootvnode && cnp->cn_nameiop == LOOKUP) {
                bool found;
                mutex_enter(&etfs_lock);
-               found = etfs_find(cnp->cn_pnbuf, &et, false);
+               found = etfs_find(cnp->cn_nameptr, &et, false);
                mutex_exit(&etfs_lock);
 
                if (found) {
-                       char *offset;
+                       const char *offset;
 
-                       offset = strstr(cnp->cn_pnbuf, et->et_key);
+                       /* pointless as et_key is always the whole string */
+                       /*offset = strstr(cnp->cn_nameptr, et->et_key);*/
+                       offset = cnp->cn_nameptr;
                        KASSERT(offset);
 
                        rn = et->et_rn;


-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index