diff options
author | Sage Weil <sage@inktank.com> | 2012-07-30 19:20:25 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-30 21:15:31 -0400 |
commit | a4107026976f06c9a6ce8cc84a763564ee39d901 (patch) | |
tree | f8f83ffd302b50f9296fb36cc046409feafd597c /net/ceph/messenger.c | |
parent | 6194ea895e447fdf4adfd23f67873a32bf4f15ae (diff) |
libceph: (re)initialize bio_iter on start of message receive
Previously, we were opportunistically initializing the bio_iter if it
appeared to be uninitialized in the middle of the read path. The problem
is that a sequence like:
- start reading message
- initialize bio_iter
- read half a message
- messenger fault, reconnect
- restart reading message
- ** bio_iter now non-NULL, not reinitialized **
- read past end of bio, crash
Instead, initialize the bio_iter unconditionally when we allocate/claim
the message for read.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r-- | net/ceph/messenger.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index e65b15d5d8b9..f1bd3bbb0c46 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -1872,6 +1872,11 @@ static int read_partial_message(struct ceph_connection *con) | |||
1872 | else | 1872 | else |
1873 | con->in_msg_pos.page_pos = 0; | 1873 | con->in_msg_pos.page_pos = 0; |
1874 | con->in_msg_pos.data_pos = 0; | 1874 | con->in_msg_pos.data_pos = 0; |
1875 | |||
1876 | #ifdef CONFIG_BLOCK | ||
1877 | if (m->bio) | ||
1878 | init_bio_iter(m->bio, &m->bio_iter, &m->bio_seg); | ||
1879 | #endif | ||
1875 | } | 1880 | } |
1876 | 1881 | ||
1877 | /* front */ | 1882 | /* front */ |
@@ -1888,10 +1893,6 @@ static int read_partial_message(struct ceph_connection *con) | |||
1888 | if (ret <= 0) | 1893 | if (ret <= 0) |
1889 | return ret; | 1894 | return ret; |
1890 | } | 1895 | } |
1891 | #ifdef CONFIG_BLOCK | ||
1892 | if (m->bio && !m->bio_iter) | ||
1893 | init_bio_iter(m->bio, &m->bio_iter, &m->bio_seg); | ||
1894 | #endif | ||
1895 | 1896 | ||
1896 | /* (page) data */ | 1897 | /* (page) data */ |
1897 | while (con->in_msg_pos.data_pos < data_len) { | 1898 | while (con->in_msg_pos.data_pos < data_len) { |
@@ -1902,7 +1903,7 @@ static int read_partial_message(struct ceph_connection *con) | |||
1902 | return ret; | 1903 | return ret; |
1903 | #ifdef CONFIG_BLOCK | 1904 | #ifdef CONFIG_BLOCK |
1904 | } else if (m->bio) { | 1905 | } else if (m->bio) { |
1905 | 1906 | BUG_ON(!m->bio_iter); | |
1906 | ret = read_partial_message_bio(con, | 1907 | ret = read_partial_message_bio(con, |
1907 | &m->bio_iter, &m->bio_seg, | 1908 | &m->bio_iter, &m->bio_seg, |
1908 | data_len, do_datacrc); | 1909 | data_len, do_datacrc); |