<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/git/stable/linux-stable.git/fs/ceph/caps.c, branch linux-3.16.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<id>https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/atom?h=linux-3.16.y</id>
<link rel='self' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/atom?h=linux-3.16.y'/>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/'/>
<updated>2019-12-19T15:58:49+00:00</updated>
<entry>
<title>ceph: fix use-after-free in __ceph_remove_cap()</title>
<updated>2019-12-19T15:58:49+00:00</updated>
<author>
<name>Luis Henriques</name>
<email>lhenriques@suse.com</email>
</author>
<published>2019-10-25T13:05:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=0702f35c5d38f66ac7fb0d247d492818f289951b'/>
<id>urn:sha1:0702f35c5d38f66ac7fb0d247d492818f289951b</id>
<content type='text'>
commit ea60ed6fcf29eebc78f2ce91491e6309ee005a01 upstream.

KASAN reports a use-after-free when running xfstest generic/531, with the
following trace:

[  293.903362]  kasan_report+0xe/0x20
[  293.903365]  rb_erase+0x1f/0x790
[  293.903370]  __ceph_remove_cap+0x201/0x370
[  293.903375]  __ceph_remove_caps+0x4b/0x70
[  293.903380]  ceph_evict_inode+0x4e/0x360
[  293.903386]  evict+0x169/0x290
[  293.903390]  __dentry_kill+0x16f/0x250
[  293.903394]  dput+0x1c6/0x440
[  293.903398]  __fput+0x184/0x330
[  293.903404]  task_work_run+0xb9/0xe0
[  293.903410]  exit_to_usermode_loop+0xd3/0xe0
[  293.903413]  do_syscall_64+0x1a0/0x1c0
[  293.903417]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

This happens because __ceph_remove_cap() may queue a cap release
(__ceph_queue_cap_release) which can be scheduled before that cap is
removed from the inode list with

	rb_erase(&amp;cap-&gt;ci_node, &amp;ci-&gt;i_caps);

And, when this finally happens, the use-after-free will occur.

This can be fixed by removing the cap from the inode list before being
removed from the session list, and thus eliminating the risk of an UAF.

Signed-off-by: Luis Henriques &lt;lhenriques@suse.com&gt;
Reviewed-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Ilya Dryomov &lt;idryomov@gmail.com&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>ceph: don't update importing cap's mseq when handing cap export</title>
<updated>2019-04-04T15:14:07+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zyan@redhat.com</email>
</author>
<published>2018-11-29T03:22:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=7b0464f293218ba89d99f8adad0facd984b9f744'/>
<id>urn:sha1:7b0464f293218ba89d99f8adad0facd984b9f744</id>
<content type='text'>
commit 3c1392d4c49962a31874af14ae9ff289cb2b3851 upstream.

Updating mseq makes client think importer mds has accepted all prior
cap messages and importer mds knows what caps client wants. Actually
some cap messages may have been dropped because of mseq mismatch.

If mseq is left untouched, importing cap's mds_wanted later will get
reset by cap import message.

Signed-off-by: "Yan, Zheng" &lt;zyan@redhat.com&gt;
Signed-off-by: Ilya Dryomov &lt;idryomov@gmail.com&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>mds: check cap ID when handling cap export message</title>
<updated>2014-06-06T01:29:55+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-04-21T07:46:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=ca665e0282ece4f8121ab4de474351f291fa8c2d'/>
<id>urn:sha1:ca665e0282ece4f8121ab4de474351f291fa8c2d</id>
<content type='text'>
handle following sequence of events:
- mds0 exports an inode to mds1. client receives the cap import
  message from mds1. caps from mds0 are removed while handling
  the cap import message.
- mds1 exports an inode to mds0. client receives the cap export
  message from mds1. handle_cap_export() adds placeholder caps
  for mds0
- client receives the first cap export message (for exporting
  inode from mds0 to mds1)

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
<entry>
<title>ceph: handle cap import atomically</title>
<updated>2014-06-06T01:29:53+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-04-18T05:20:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=2cd698be9a3d3a0f8f3c66814eac34144c31954c'/>
<id>urn:sha1:2cd698be9a3d3a0f8f3c66814eac34144c31954c</id>
<content type='text'>
cap import messages are processed by both handle_cap_import() and
handle_cap_grant(). These two functions are not executed in the same
atomic context, so they can races with cap release.

The fix is make handle_cap_import() not release the i_ceph_lock when
it returns. Let handle_cap_grant() release the lock after it finishes
its job.

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
<entry>
<title>ceph: pre-allocate ceph_cap struct for ceph_add_cap()</title>
<updated>2014-06-06T01:29:53+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-04-18T01:57:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=d9df2783507943316b305e177e5b1c157200c76f'/>
<id>urn:sha1:d9df2783507943316b305e177e5b1c157200c76f</id>
<content type='text'>
So that ceph_add_cap() can be used while i_ceph_lock is locked.
This simplifies the code that handle cap import/export.

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
<entry>
<title>ceph: update inode fields according to issued caps</title>
<updated>2014-06-06T01:29:52+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-04-17T00:55:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=f98a128a55ff85d0087de89f304f10bd75e792aa'/>
<id>urn:sha1:f98a128a55ff85d0087de89f304f10bd75e792aa</id>
<content type='text'>
Cap message and request reply from non-auth MDS may carry stale
information (corresponding locks are in LOCK states) even they
have the newest inode version. So client should update inode fields
according to issued caps.

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
<entry>
<title>ceph: queue vmtruncate if necessary when handing cap grant/revoke</title>
<updated>2014-06-06T01:29:51+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-04-11T02:18:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=c6bcda6f525129b1df169f77d96a4b0972e1ecb1'/>
<id>urn:sha1:c6bcda6f525129b1df169f77d96a4b0972e1ecb1</id>
<content type='text'>
cap grant/revoke message from non-auth MDS can update inode's size
and truncate_seq/truncate_size. (the message arrives before auth
MDS's cap trunc message)

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
<entry>
<title>ceph: avoid releasing caps that are being used</title>
<updated>2014-04-28T19:55:01+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-04-17T00:02:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=fd7b95cd1b58171a0b931b2063729a032bec4ac2'/>
<id>urn:sha1:fd7b95cd1b58171a0b931b2063729a032bec4ac2</id>
<content type='text'>
To avoid releasing caps that are being used, encode_inode_release()
should send implemented caps to MDS.

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
Reviewed-by: Sage Weil &lt;sage@inktank.com&gt;
</content>
</entry>
<entry>
<title>ceph: set mds_wanted when MDS reply changes a cap to auth cap</title>
<updated>2014-04-05T04:07:12+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-03-18T02:15:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=d9ffc4f77073e7e1ca731f21804769de9c094b87'/>
<id>urn:sha1:d9ffc4f77073e7e1ca731f21804769de9c094b87</id>
<content type='text'>
When adjusting caps client wants, MDS does not record caps that are
not allowed. For non-auth MDS, it does not record WR caps. So when
a MDS reply changes a non-auth cap to auth cap, client needs to set
cap's mds_wanted according to the reply.

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
<entry>
<title>ceph: make sure write caps are registered with auth MDS</title>
<updated>2014-04-05T04:07:05+00:00</updated>
<author>
<name>Yan, Zheng</name>
<email>zheng.z.yan@intel.com</email>
</author>
<published>2014-03-08T01:51:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=a255060451dcb416c8097218b40d86d613d84bfc'/>
<id>urn:sha1:a255060451dcb416c8097218b40d86d613d84bfc</id>
<content type='text'>
Only auth MDS can issue write caps to clients, so don't consider
write caps registered with non-auth MDS as valid.

Signed-off-by: Yan, Zheng &lt;zheng.z.yan@intel.com&gt;
</content>
</entry>
</feed>
