gluster / glusterfs

Gluster Filesystem : Build your distributed storage in minutes
https://www.gluster.org
GNU General Public License v2.0
4.54k stars 1.07k forks source link

dht: fix asan use-after-free bug #4248

Closed mohit84 closed 7 months ago

mohit84 commented 7 months ago

The client is throwing below stacktrace while asan is enabled. The client is facing an issue while application is trying to call removexattr in 2x1 subvol and non-mds subvol is down. As we can see in below stacktrace dht_setxattr_mds_cbk is calling dht_setxattr_non_mds_cbk and dht_setxattr_non_mds_cbk is trying to wipe local because call_cnt is 0 but dht_setxattr_mds_cbk is trying to access frame->local that;s why it is crashed.

x621000051c34 is located 1844 bytes inside of 4164-byte region [0x621000051500,0x621000052544) freed by thread T7 here:

Solution: Use switch instead of using if statement to wind a operation, in case of switch the code will not try to access local after wind a operation for last dht subvol.

Fixes: #3732 Change-Id: I031bc814d6df98058430ef4de7040e3370d1c677 (Cherry picke from commit 11ff6f56a1e7ad740ffe46e39a5911c9e7367eb6) (Reviwed on upstream link https://github.com/gluster/glusterfs/pull/4242)

Fixes: #3732 Change-Id: I031bc814d6df98058430ef4de7040e3370d1c677

mohit84 commented 7 months ago

/run regression