ceph: Fix error handling in ceph_read_iter
PATCH 1/1 ceph: Fix error handling in ceph_read_iter
In case __ceph_do_getattr returns an error and the retry_op in ceph_read_iter is not READ_INLINE, then it's possible to invoke __free_page on a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.
Fix this by explicitly checking whether the page is set or not.
--- fs/ceph/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/file.c +2 -1
@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (!page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;
Signature · 1 line
2.5.0
PATCH v2 1/1 ceph: Fix error handling in ceph_read_iter
In case __ceph_do_getattr returns an error and the retry_op in ceph_read_iter is not READ_INLINE, then it's possible to invoke __free_page on a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.
Fix this by explicitly checking whether the page is set or not.
---
Inverted the condition, so resending with correct condition this time.
fs/ceph/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/file.c +2 -1
@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;
Signature · 1 line
2.5.0
Quoted 35 lines · Nikolay Borisov
In case
__ceph_do_getattrreturns an error and theretry_opinceph_read_iteris notREAD_INLINE, then it's possible to invoke__free_pageon a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.Fix this by explicitly checking whether the page is set or not.
Signed-off-by Nikolay Borisov <[email protected]>---
Inverted the condition, so resending with correct condition this time.
fs/ceph/file.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)fs/ceph/file.c +2
-1@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;
Quoted 1 line
—
Quoted 2 lines
2.5.0
Quoted 21 lines · Zheng
Quoted 21 lines · Nikolay Borisov
In case
__ceph_do_getattrreturns an error and theretry_opinceph_read_iteris notREAD_INLINE, then it's possible to invoke__free_pageon a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.Fix this by explicitly checking whether the page is set or not.
Signed-off-by Nikolay Borisov <[email protected]>---
Inverted the condition, so resending with correct condition this time.
fs/ceph/file.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 14 lines
fs/ceph/file.c +2
-1@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;Quoted 1 line
—
Reviewed-by Yan, Zheng <[email protected]>
I believe this needs to also be tagged as stable. To whomever is going to merge it: can you please do that?
Quoted 4 lines
Quoted 3 lines
2.5.0
Quoted 44 lines · Nikolay Borisov
Quoted 21 lines · Zheng
Quoted 21 lines · Nikolay Borisov
In case
__ceph_do_getattrreturns an error and theretry_opinceph_read_iteris notREAD_INLINE, then it's possible to invoke__free_pageon a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.Fix this by explicitly checking whether the page is set or not.
Signed-off-by Nikolay Borisov <[email protected]>---
Inverted the condition, so resending with correct condition this time.
fs/ceph/file.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)Quoted 16 lines
Quoted 14 lines
fs/ceph/file.c +2
-1@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;Quoted 1 line
—
Reviewed-by Yan, Zheng <[email protected]>
Quoted 3 lines
I believe this needs to also be tagged as stable. To whomever is going to merge it: can you please do that?
need to get it upstream first
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
2.5.0
Ilya Dryomov
maintainerQuoted 41 lines · Nikolay Borisov
Quoted 21 lines · Zheng
Quoted 21 lines · Nikolay Borisov
In case
__ceph_do_getattrreturns an error and theretry_opinceph_read_iteris notREAD_INLINE, then it's possible to invoke__free_pageon a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.Fix this by explicitly checking whether the page is set or not.
Signed-off-by Nikolay Borisov <[email protected]>---
Inverted the condition, so resending with correct condition this time.
fs/ceph/file.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)Quoted 16 lines
Quoted 14 lines
fs/ceph/file.c +2
-1@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;Quoted 1 line
—
Reviewed-by Yan, Zheng <[email protected]>
Quoted 2 lines
I believe this needs to also be tagged as stable. To whomever is going to merge it: can you please do that?
I'll do that. Zheng, do you see any other issues with the killable wait here?
Thanks,
Ilya
Quoted 45 lines · Ilya Dryomov
Quoted 41 lines · Nikolay Borisov
Quoted 37 lines · Zheng
Quoted 35 lines · Nikolay Borisov
In case
__ceph_do_getattrreturns an error and theretry_opinceph_read_iteris notREAD_INLINE, then it's possible to invoke__free_pageon a page which is NULL, this naturally leads to a crash. This can happen when, for example, a process waiting on a MDS reply receives sigterm.Fix this by explicitly checking whether the page is set or not.
Signed-off-by Nikolay Borisov <[email protected]>---
Inverted the condition, so resending with correct condition this time.
fs/ceph/file.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)fs/ceph/file.c +2
-1@@ -929,7 +929,8 @@ again: statret =__ceph_do_getattr (inode, page,CEPH_STAT_CAP_INLINE_DATA , !!page);if (statret <0 ) { -__free_page (page); +if (page) +__free_page (page);if (statret == -ENODATA ) {BUG_ON (retry_op !=READ_INLINE ); goto again;Quoted 1 line
—
Reviewed-by Yan, Zheng <[email protected]>
Quoted 5 lines
Quoted 2 lines
I believe this needs to also be tagged as stable. To whomever is going to merge it: can you please do that?
I'll do that. Zheng, do you see any other issues with the killable wait here?
No. this change is obvious, what’s your concern?
Regards
Yan, Zheng
Quoted 4 lines
Thanks,
Ilya