Fix panic : free a NULL point in dmu_send_impl #4969
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference issue: ##4967
This issue maybe introduced by commit #47dfff3
[93344.134598] [] dump_stack+0x4d/0x63
[93344.134603] [] spl_dumpstack+0x3d/0x3f [spl]
[93344.134605] [] spl_panic+0xa9/0xdc [spl]
[93344.134608] [] ? vn_rdwr+0x159/0x1b3 [spl]
[93344.134611] [] ? mutex_unlock+0x9/0xb
[93344.134628] [] ? dump_bytes_cb+0x10f/0x123 [zfs]
[93344.134630] [] spl_kmem_free+0x44/0xbf [spl]
[93344.134633] [] fnvlist_pack_free+0x9/0xb [znvpair]
[93344.134644] [] dmu_send_impl+0x529/0x120a [zfs]
[93344.134645] [] ? mutex_unlock+0x9/0xb
[93344.134657] [] dmu_send_obj+0x197/0x1bc [zfs]
[93344.134669] [] zfs_ioc_send+0x1f7/0x236 [zfs]
[93344.134682] [] zfsdev_ioctl+0x40e/0x521 [zfs]
[93344.134684] [] ? check_preempt_curr+0x3e/0x6c
[93344.134686] [] do_vfs_ioctl+0x3f5/0x43d
[93344.134688] [] ? _do_fork+0x229/0x24e
[93344.134689] [] ? __do_page_fault+0x24e/0x367
[93344.134691] [] SyS_ioctl+0x39/0x61
[93344.134692] [] entry_SYSCALL_64_fastpath+0x12/0x6a
Analysis:
If the send stream isn't resume from specified object and offset, we come to dmu_send_impl() with zero input of resumeobj and resumeoff, which means we will not initialize the buffer of payload.
In other words, the address of buffer payload will stay NULL, we shouldn't free it in this situation.
Solution:
Examine the buf len of payload before we decide to free it.