linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: ebiederm@xmission.com
Cc: linux-fsdevel@vger.kernel.org
Subject: re: vfs: Don't copy mount bind mounts of /proc/<pid>/ns/mnt between namespaces
Date: Mon, 2 Sep 2013 18:20:43 +0300	[thread overview]
Message-ID: <20130902140531.GA5450@elgon.mountain> (raw)

Hello Eric W. Biederman,

This is a semi-automatic email about new static checker warnings.

The patch 4ce5d2b1a8fd: "vfs: Don't copy mount bind mounts of
/proc/<pid>/ns/mnt between namespaces" from Mar 30, 2013, leads to
the following Smatch complaint:

fs/namespace.c:2459 dup_mnt_ns()
	 warn: variable dereferenced before check 'p' (see line 2475)

fs/namespace.c
  2441          new = copy_tree(old, old->mnt.mnt_root, copy_flags);
                                     ^^^^^^^^^^^^^^^^^
Old is dereferenced.

  2442          if (IS_ERR(new)) {
  2443                  namespace_unlock();
  2444                  free_mnt_ns(new_ns);
  2445                  return ERR_CAST(new);
  2446          }
  2447          new_ns->root = new;
  2448          br_write_lock(&vfsmount_lock);
  2449          list_add_tail(&new_ns->list, &new->mnt_list);
  2450          br_write_unlock(&vfsmount_lock);
  2451  
  2452          /*
  2453           * Second pass: switch the tsk->fs->* elements and mark new vfsmounts
  2454           * as belonging to new namespace.  We have already acquired a private
  2455           * fs_struct, so tsk->fs->lock is not needed.
  2456           */
  2457          p = old;
                ^^^^^^^

P is a valid pointer.

  2458		q = new;
  2459		while (p) {
                      ^^^
Existing check for "p".

  2460			q->mnt_ns = new_ns;
  2461			if (fs) {
  2462				if (&p->mnt == fs->root.mnt) {
  2463					fs->root.mnt = mntget(&q->mnt);
  2464					rootmnt = &p->mnt;
  2465				}
  2466				if (&p->mnt == fs->pwd.mnt) {
  2467					fs->pwd.mnt = mntget(&q->mnt);
  2468					pwdmnt = &p->mnt;
  2469				}
  2470			}
  2471			p = next_mnt(p, old);
  2472			q = next_mnt(q, new);
  2473			if (!q)
  2474				break;
  2475			while (p->mnt.mnt_root != q->mnt.mnt_root)
                               ^^^^^^^^^^^^^^^
We dereference "p".

  2476				p = next_mnt(p, old);
  2477		}

regards,
dan carpenter

             reply	other threads:[~2013-09-02 15:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02 15:20 Dan Carpenter [this message]
2013-09-02 20:30 ` vfs: Don't copy mount bind mounts of /proc/<pid>/ns/mnt between namespaces Eric W. Biederman
2013-09-02 20:40   ` Dan Carpenter
2013-09-02 21:52     ` Eric W. Biederman
2013-09-02 23:10       ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130902140531.GA5450@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).