linux/net/ceph
Ilya Dryomov 33419c086e libceph: validate con->state at the top of try_write()
commit 9c55ad1c21 upstream.

ceph_con_workfn() validates con->state before calling try_read() and
then try_write().  However, try_read() temporarily releases con->mutex,
notably in process_message() and ceph_con_in_msg_alloc(), opening the
window for ceph_con_close() to sneak in, close the connection and
release con->sock.  When try_write() is called on the assumption that
con->state is still valid (i.e. not STANDBY or CLOSED), a NULL sock
gets passed to the networking stack:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
  IP: selinux_socket_sendmsg+0x5/0x20

Make sure con->state is valid at the top of try_write() and add an
explicit BUG_ON for this, similar to try_read().

Link: https://tracker.ceph.com/issues/23706
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-10-21 08:45:46 +01:00
..
crush crush: ensuring at most num-rep osds are selected 2015-05-20 13:26:19 +01:00
armor.c libceph: Fix base64-decoding when input ends in newline. 2011-03-15 09:14:02 -07:00
auth.c libceph: make authorizer destruction independent of ceph_auth_client 2016-06-15 21:29:27 +01:00
auth_none.c libceph: make authorizer destruction independent of ceph_auth_client 2016-06-15 21:29:27 +01:00
auth_none.h libceph: make authorizer destruction independent of ceph_auth_client 2016-06-15 21:29:27 +01:00
auth_x.c libceph: make authorizer destruction independent of ceph_auth_client 2016-06-15 21:29:27 +01:00
auth_x.h libceph: make authorizer destruction independent of ceph_auth_client 2016-06-15 21:29:27 +01:00
auth_x_protocol.h ceph: factor out libceph from Ceph file system 2010-10-20 15:37:28 -07:00
buffer.c libceph: add ceph_kv{malloc,free}() and switch to them 2014-01-26 12:34:23 +02:00
ceph_common.c libceph: mon_get_version request infrastructure 2014-06-06 09:29:57 +08:00
ceph_fs.c ceph: fix file mode calculation 2011-07-19 11:25:04 -07:00
ceph_hash.c net: cleanup unsigned to unsigned int 2012-04-15 12:44:40 -04:00
ceph_strings.c libceph: update ceph_osd_op_name() 2013-02-18 12:20:18 -06:00
crypto.c libceph: do not crash on large auth tickets 2014-11-27 11:21:49 +00:00
crypto.h net: 8021q/bluetooth/bridge/can/ceph: Remove extern from function prototypes 2013-10-19 19:12:11 -04:00
debugfs.c libceph: mon_get_version request infrastructure 2014-06-06 09:29:57 +08:00
Kconfig net/ceph: remove depends on CONFIG_EXPERIMENTAL 2013-01-11 11:39:33 -08:00
Makefile libceph: create source file "net/ceph/snapshot.c" 2013-05-01 21:20:08 -07:00
messenger.c libceph: validate con->state at the top of try_write() 2018-10-21 08:45:46 +01:00
mon_client.c libceph: gracefully handle large reply messages from the mon 2014-09-17 09:22:18 -07:00
msgpool.c libceph: initialize msgpool message types 2012-07-30 09:29:50 -07:00
osd_client.c libceph: make authorizer destruction independent of ceph_auth_client 2016-06-15 21:29:27 +01:00
osdmap.c libceph: NULL deref on crush_decode() error path 2017-09-15 18:29:49 +01:00
pagelist.c ceph: use list_move_tail instead of list_del/list_add_tail 2012-10-01 14:30:49 -05:00
pagevec.c ceph_sync_read: stop poking into iov_iter guts 2014-05-06 17:39:42 -04:00
snapshot.c libceph: create source file "net/ceph/snapshot.c" 2013-05-01 21:20:08 -07:00