1
0
Fork 0
alistair23-linux/net/ceph
Ilya Dryomov 4aac9228d1 libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive()
con_fault() can transition the connection into STANDBY right after
ceph_con_keepalive() clears STANDBY in clear_standby():

    libceph user thread               ceph-msgr worker

ceph_con_keepalive()
  mutex_lock(&con->mutex)
  clear_standby(con)
  mutex_unlock(&con->mutex)
                                mutex_lock(&con->mutex)
                                con_fault()
                                  ...
                                  if KEEPALIVE_PENDING isn't set
                                    set state to STANDBY
                                  ...
                                mutex_unlock(&con->mutex)
  set KEEPALIVE_PENDING
  set WRITE_PENDING

This triggers warnings in clear_standby() when either ceph_con_send()
or ceph_con_keepalive() get to clearing STANDBY next time.

I don't see a reason to condition queue_con() call on the previous
value of KEEPALIVE_PENDING, so move the setting of KEEPALIVE_PENDING
into the critical section -- unlike WRITE_PENDING, KEEPALIVE_PENDING
could have been a non-atomic flag.

Reported-by: syzbot+acdeb633f6211ccdf886@syzkaller.appspotmail.com
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Tested-by: Myungho Jung <mhjungk@gmail.com>
2019-01-21 14:53:12 +01:00
..
crush crush: fix using plain integer as NULL warning 2018-08-13 17:55:44 +02:00
Kconfig ceph: fix whitespace 2018-08-02 21:33:21 +02:00
Makefile ceph: fix whitespace 2018-08-02 21:33:21 +02:00
armor.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
auth.c libceph: add authorizer challenge 2018-08-02 21:33:24 +02:00
auth_none.c ceph: fix whitespace 2018-08-02 21:33:21 +02:00
auth_none.h ceph: fix whitespace 2018-08-02 21:33:21 +02:00
auth_x.c libceph: weaken sizeof check in ceph_x_verify_authorizer_reply() 2018-08-02 21:33:26 +02:00
auth_x.h ceph: fix whitespace 2018-08-02 21:33:21 +02:00
auth_x_protocol.h libceph: add authorizer challenge 2018-08-02 21:33:24 +02:00
buffer.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ceph_common.c libceph: allow setting abort_on_full for rbd 2019-01-07 22:47:48 +01:00
ceph_fs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ceph_hash.c ceph: mark expected switch fall-throughs 2017-11-13 12:11:39 +01:00
ceph_strings.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cls_lock_client.c libceph: use timespec64 in for keepalive2 and ticket validity 2018-08-02 21:26:12 +02:00
crypto.c libceph: Remove VLA usage of skcipher 2018-09-28 12:46:07 +08:00
crypto.h libceph: Remove VLA usage of skcipher 2018-09-28 12:46:07 +08:00
debugfs.c libceph: allow setting abort_on_full for rbd 2019-01-07 22:47:48 +01:00
messenger.c libceph: avoid KEEPALIVE_PENDING races in ceph_con_keepalive() 2019-01-21 14:53:12 +01:00
mon_client.c ceph: fix whitespace 2018-08-02 21:33:21 +02:00
msgpool.c libceph: preallocate message data items 2018-10-22 10:28:22 +02:00
osd_client.c libceph: allow setting abort_on_full for rbd 2019-01-07 22:47:48 +01:00
osdmap.c The main piece is a set of libceph changes that revamps how OSD 2018-06-15 07:24:58 +09:00
pagelist.c libceph: introduce ceph_pagelist_alloc() 2018-10-22 10:28:21 +02:00
pagevec.c ceph: fix whitespace 2018-08-02 21:33:21 +02:00
snapshot.c libceph: convert ceph_snap_context.nref from atomic_t to refcount_t 2017-05-04 09:19:18 +02:00
string_table.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
striper.c libceph, ceph: move ceph_calc_file_object_mapping() to striper.c 2018-04-02 10:12:43 +02:00