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 Tue, Nov 23, 2010 at 11:13:02PM +0000, David Holland wrote:
 > However, I discovered today that rumpfs's VOP_LOOKUP implementation
 > relies on being able to access not just the name to be looked up, but
 > also the rest of the pathname namei is working on, specifically
 > including the parts that have already been translated.

Ok, on further inspection it appears that this is overly pessimistic.
It looks, rather, as if rumpfs (specifically the etfs logic) is using
the full namei work buffer and hoping that no such parts actually
appear in it, because if they do it'll fail.

So I think the following change will resolve the problem; can someone
who knows how this is supposed to work check it? (If it's ok, there's
no need to tamper with VOP_LOOKUP.)

Index: rumpfs.c
===================================================================
RCS file: /cvsroot/src/sys/rump/librump/rumpvfs/rumpfs.c,v
retrieving revision 1.74
diff -u -p -r1.74 rumpfs.c
--- rumpfs.c    22 Nov 2010 15:15:35 -0000      1.74
+++ rumpfs.c    24 Nov 2010 04:31:07 -0000
@@ -291,10 +291,9 @@ hft_to_vtype(int hft)
 }
 
 static bool
-etfs_find(const char *key, struct etfs **etp, bool forceprefix)
+etfs_find(const char *key, size_t keylen, struct etfs **etp, bool forceprefix)
 {
        struct etfs *et;
-       size_t keylen = strlen(key);
 
        KASSERT(mutex_owned(&etfs_lock));
 
@@ -381,7 +380,7 @@ doregister(const char *key, const char *
                rn->rn_flags |= RUMPNODE_DIR_ETSUBS;
 
        mutex_enter(&etfs_lock);
-       if (etfs_find(key, NULL, REGDIR(ftype))) {
+       if (etfs_find(key, strlen(key), NULL, REGDIR(ftype))) {
                mutex_exit(&etfs_lock);
                if (et->et_blkmin != -1)
                        rumpblk_deregister(hostpath);
@@ -641,13 +640,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, cnp->cn_namelen, &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