<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/fuse/dev.c, branch v4.4.93</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>fuse: fix use after free issue in fuse_dev_do_read()</title>
<updated>2017-02-23T16:43:09+00:00</updated>
<author>
<name>Sahitya Tummala</name>
<email>stummala@codeaurora.org</email>
</author>
<published>2017-02-08T15:00:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d7b146c692297734dddfbc9bddfc61a9da49beab'/>
<id>d7b146c692297734dddfbc9bddfc61a9da49beab</id>
<content type='text'>
commit 6ba4d2722d06960102c981322035239cd66f7316 upstream.

There is a potential race between fuse_dev_do_write()
and request_wait_answer() contexts as shown below:

TASK 1:
__fuse_request_send():
  |--spin_lock(&amp;fiq-&gt;waitq.lock);
  |--queue_request();
  |--spin_unlock(&amp;fiq-&gt;waitq.lock);
  |--request_wait_answer():
       |--if (test_bit(FR_SENT, &amp;req-&gt;flags))
       &lt;gets pre-empted after it is validated true&gt;
                                   TASK 2:
                                   fuse_dev_do_write():
                                     |--clears bit FR_SENT,
                                     |--request_end():
                                        |--sets bit FR_FINISHED
                                        |--spin_lock(&amp;fiq-&gt;waitq.lock);
                                        |--list_del_init(&amp;req-&gt;intr_entry);
                                        |--spin_unlock(&amp;fiq-&gt;waitq.lock);
                                        |--fuse_put_request();
       |--queue_interrupt();
       &lt;request gets queued to interrupts list&gt;
            |--wake_up_locked(&amp;fiq-&gt;waitq);
       |--wait_event_freezable();
       &lt;as FR_FINISHED is set, it returns and then
       the caller frees this request&gt;

Now, the next fuse_dev_do_read(), see interrupts list is not empty
and then calls fuse_read_interrupt() which tries to access the request
which is already free'd and gets the below crash:

[11432.401266] Unable to handle kernel paging request at virtual address
6b6b6b6b6b6b6b6b
...
[11432.418518] Kernel BUG at ffffff80083720e0
[11432.456168] PC is at __list_del_entry+0x6c/0xc4
[11432.463573] LR is at fuse_dev_do_read+0x1ac/0x474
...
[11432.679999] [&lt;ffffff80083720e0&gt;] __list_del_entry+0x6c/0xc4
[11432.687794] [&lt;ffffff80082c65e0&gt;] fuse_dev_do_read+0x1ac/0x474
[11432.693180] [&lt;ffffff80082c6b14&gt;] fuse_dev_read+0x6c/0x78
[11432.699082] [&lt;ffffff80081d5638&gt;] __vfs_read+0xc0/0xe8
[11432.704459] [&lt;ffffff80081d5efc&gt;] vfs_read+0x90/0x108
[11432.709406] [&lt;ffffff80081d67f0&gt;] SyS_read+0x58/0x94

As FR_FINISHED bit is set before deleting the intr_entry with input
queue lock in request completion path, do the testing of this flag and
queueing atomically with the same lock in queue_interrupt().

Signed-off-by: Sahitya Tummala &lt;stummala@codeaurora.org&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Fixes: fd22d62ed0c3 ("fuse: no fc-&gt;lock for iqueue parts")
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 6ba4d2722d06960102c981322035239cd66f7316 upstream.

There is a potential race between fuse_dev_do_write()
and request_wait_answer() contexts as shown below:

TASK 1:
__fuse_request_send():
  |--spin_lock(&amp;fiq-&gt;waitq.lock);
  |--queue_request();
  |--spin_unlock(&amp;fiq-&gt;waitq.lock);
  |--request_wait_answer():
       |--if (test_bit(FR_SENT, &amp;req-&gt;flags))
       &lt;gets pre-empted after it is validated true&gt;
                                   TASK 2:
                                   fuse_dev_do_write():
                                     |--clears bit FR_SENT,
                                     |--request_end():
                                        |--sets bit FR_FINISHED
                                        |--spin_lock(&amp;fiq-&gt;waitq.lock);
                                        |--list_del_init(&amp;req-&gt;intr_entry);
                                        |--spin_unlock(&amp;fiq-&gt;waitq.lock);
                                        |--fuse_put_request();
       |--queue_interrupt();
       &lt;request gets queued to interrupts list&gt;
            |--wake_up_locked(&amp;fiq-&gt;waitq);
       |--wait_event_freezable();
       &lt;as FR_FINISHED is set, it returns and then
       the caller frees this request&gt;

Now, the next fuse_dev_do_read(), see interrupts list is not empty
and then calls fuse_read_interrupt() which tries to access the request
which is already free'd and gets the below crash:

[11432.401266] Unable to handle kernel paging request at virtual address
6b6b6b6b6b6b6b6b
...
[11432.418518] Kernel BUG at ffffff80083720e0
[11432.456168] PC is at __list_del_entry+0x6c/0xc4
[11432.463573] LR is at fuse_dev_do_read+0x1ac/0x474
...
[11432.679999] [&lt;ffffff80083720e0&gt;] __list_del_entry+0x6c/0xc4
[11432.687794] [&lt;ffffff80082c65e0&gt;] fuse_dev_do_read+0x1ac/0x474
[11432.693180] [&lt;ffffff80082c6b14&gt;] fuse_dev_read+0x6c/0x78
[11432.699082] [&lt;ffffff80081d5638&gt;] __vfs_read+0xc0/0xe8
[11432.704459] [&lt;ffffff80081d5efc&gt;] vfs_read+0x90/0x108
[11432.709406] [&lt;ffffff80081d67f0&gt;] SyS_read+0x58/0x94

As FR_FINISHED bit is set before deleting the intr_entry with input
queue lock in request completion path, do the testing of this flag and
queueing atomically with the same lock in queue_interrupt().

Signed-off-by: Sahitya Tummala &lt;stummala@codeaurora.org&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Fixes: fd22d62ed0c3 ("fuse: no fc-&gt;lock for iqueue parts")
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: clear FR_PENDING flag when moving requests out of pending queue</title>
<updated>2017-01-26T07:23:48+00:00</updated>
<author>
<name>Tahsin Erdogan</name>
<email>tahsin@google.com</email>
</author>
<published>2017-01-12T20:04:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=dc4e372f9a4732ad3ef3270cdb8a08f1a0b70890'/>
<id>dc4e372f9a4732ad3ef3270cdb8a08f1a0b70890</id>
<content type='text'>
commit a8a86d78d673b1c99fe9b0064739fde9e9774184 upstream.

fuse_abort_conn() moves requests from pending list to a temporary list
before canceling them. This operation races with request_wait_answer()
which also tries to remove the request after it gets a fatal signal. It
checks FR_PENDING flag to determine whether the request is still in the
pending list.

Make fuse_abort_conn() clear FR_PENDING flag so that request_wait_answer()
does not remove the request from temporary list.

This bug causes an Oops when trying to delete an already deleted list entry
in end_requests().

Fixes: ee314a870e40 ("fuse: abort: no fc-&gt;lock needed for request ending")
Signed-off-by: Tahsin Erdogan &lt;tahsin@google.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit a8a86d78d673b1c99fe9b0064739fde9e9774184 upstream.

fuse_abort_conn() moves requests from pending list to a temporary list
before canceling them. This operation races with request_wait_answer()
which also tries to remove the request after it gets a fatal signal. It
checks FR_PENDING flag to determine whether the request is still in the
pending list.

Make fuse_abort_conn() clear FR_PENDING flag so that request_wait_answer()
does not remove the request from temporary list.

This bug causes an Oops when trying to delete an already deleted list entry
in end_requests().

Fixes: ee314a870e40 ("fuse: abort: no fc-&gt;lock needed for request ending")
Signed-off-by: Tahsin Erdogan &lt;tahsin@google.com&gt;
Signed-off-by: Miklos Szeredi &lt;mszeredi@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fuse: fix ioctl type confusion</title>
<updated>2015-08-16T19:35:44+00:00</updated>
<author>
<name>Jann Horn</name>
<email>jann@thejh.net</email>
</author>
<published>2015-08-16T18:27:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8ed1f0e22f49ef42e63875fd2529389a32ff3566'/>
<id>8ed1f0e22f49ef42e63875fd2529389a32ff3566</id>
<content type='text'>
fuse_dev_ioctl() performed fuse_get_dev() on a user-supplied fd,
leading to a type confusion issue. Fix it by checking file-&gt;f_op.

Signed-off-by: Jann Horn &lt;jann@thejh.net&gt;
Acked-by: Miklos Szeredi &lt;miklos@szeredi.hu&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
fuse_dev_ioctl() performed fuse_get_dev() on a user-supplied fd,
leading to a type confusion issue. Fix it by checking file-&gt;f_op.

Signed-off-by: Jann Horn &lt;jann@thejh.net&gt;
Acked-by: Miklos Szeredi &lt;miklos@szeredi.hu&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: separate pqueue for clones</title>
<updated>2015-07-01T14:26:09+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c3696046beb3a4479715b48f67f6a8a3aef4b3bb'/>
<id>c3696046beb3a4479715b48f67f6a8a3aef4b3bb</id>
<content type='text'>
Make each fuse device clone refer to a separate processing queue.  The only
constraint on userspace code is that the request answer must be written to
the same device clone as it was read off.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Make each fuse device clone refer to a separate processing queue.  The only
constraint on userspace code is that the request answer must be written to
the same device clone as it was read off.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: introduce per-instance fuse_dev structure</title>
<updated>2015-07-01T14:26:08+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=cc080e9e9be16ccf26135d366d7d2b65209f1d56'/>
<id>cc080e9e9be16ccf26135d366d7d2b65209f1d56</id>
<content type='text'>
Allow fuse device clones to refer to be distinguished.  This patch just
adds the infrastructure by associating a separate "struct fuse_dev" with
each clone.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Allow fuse device clones to refer to be distinguished.  This patch just
adds the infrastructure by associating a separate "struct fuse_dev" with
each clone.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: device fd clone</title>
<updated>2015-07-01T14:26:08+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=00c570f4ba43ae73b41fa0a2269c3b0ac20386ef'/>
<id>00c570f4ba43ae73b41fa0a2269c3b0ac20386ef</id>
<content type='text'>
Allow an open fuse device to be "cloned".  Userspace can create a clone by:

      newfd = open("/dev/fuse", O_RDWR)
      ioctl(newfd, FUSE_DEV_IOC_CLONE, &amp;oldfd);

At this point newfd will refer to the same fuse connection as oldfd.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Allow an open fuse device to be "cloned".  Userspace can create a clone by:

      newfd = open("/dev/fuse", O_RDWR)
      ioctl(newfd, FUSE_DEV_IOC_CLONE, &amp;oldfd);

At this point newfd will refer to the same fuse connection as oldfd.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: abort: no fc-&gt;lock needed for request ending</title>
<updated>2015-07-01T14:26:08+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ee314a870e402f4e63b8a651bc96c740ed69cb31'/>
<id>ee314a870e402f4e63b8a651bc96c740ed69cb31</id>
<content type='text'>
In fuse_abort_conn() when all requests are on private lists we no longer
need fc-&gt;lock protection.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In fuse_abort_conn() when all requests are on private lists we no longer
need fc-&gt;lock protection.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: no fc-&gt;lock for pqueue parts</title>
<updated>2015-07-01T14:26:07+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=46c34a348b0ac74fc9646de8ef0c5b8b29f09da9'/>
<id>46c34a348b0ac74fc9646de8ef0c5b8b29f09da9</id>
<content type='text'>
Remove fc-&gt;lock protection from processing queue members, now protected by
fpq-&gt;lock.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove fc-&gt;lock protection from processing queue members, now protected by
fpq-&gt;lock.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: no fc-&gt;lock in request_end()</title>
<updated>2015-07-01T14:26:07+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=efe2800facb4505696e602ec4ed1fc947bf114dd'/>
<id>efe2800facb4505696e602ec4ed1fc947bf114dd</id>
<content type='text'>
No longer need to call request_end() with the connection lock held.  We
still protect the background counters and queue with fc-&gt;lock, so acquire
it if necessary.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
No longer need to call request_end() with the connection lock held.  We
still protect the background counters and queue with fc-&gt;lock, so acquire
it if necessary.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fuse: cleanup request_end()</title>
<updated>2015-07-01T14:26:07+00:00</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2015-07-01T14:26:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1e6881c36ebbfd47298c42fa82b544c4988933fa'/>
<id>1e6881c36ebbfd47298c42fa82b544c4988933fa</id>
<content type='text'>
Now that we atomically test having already done everything we no longer
need other protection.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that we atomically test having already done everything we no longer
need other protection.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Reviewed-by: Ashish Samant &lt;ashish.samant@oracle.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
