Re: [v3 PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct

From: Yang Shi
Date: Tue Apr 10 2018 - 12:21:42 EST




On 4/10/18 5:28 AM, Cyrill Gorcunov wrote:
On Tue, Apr 10, 2018 at 01:10:01PM +0200, Michal Hocko wrote:
Because do_brk does vma manipulations, for this reason it's
running under down_write_killable(&mm->mmap_sem). Or you
mean something else?
Yes, all we need the new lock for is to get a consistent view on brk
values. I am simply asking whether there is something fundamentally
wrong by doing the update inside the new lock while keeping the original
mmap_sem locking in the brk path. That would allow us to drop the
mmap_sem lock in the proc path when looking at brk values.
Michal gimme some time. I guess we might do so, but I need some
spare time to take more precise look into the code, hopefully today
evening. Also I've a suspicion that we've wracked check_data_rlimit
with this new lock in prctl. Need to verify it again.

I see you guys points. We might be able to move the drop of mmap_sem before setting mm->brk in sys_brk since mmap_sem should be used to protect vma manipulation only, then protect the value modify with the new arg_lock. Then we can eliminate mmap_sem stuff in prctl path, and it also prevents from wrecking check_data_rlimit.

At the first glance, it looks feasible to me. Will look into deeper later.

Thanks,
Yang