From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753427AbcGLRB0 (ORCPT ); Tue, 12 Jul 2016 13:01:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39783 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbcGLRBY (ORCPT ); Tue, 12 Jul 2016 13:01:24 -0400 Date: Tue, 12 Jul 2016 19:01:45 +0200 From: Oleg Nesterov To: Stanislav Kinsburskiy Cc: peterz@infradead.org, mingo@redhat.com, mhocko@suse.com, keescook@chromium.org, linux-kernel@vger.kernel.org, mguzik@redhat.com, bsegall@google.com, john.stultz@linaro.org, ebiederm@xmission.com, gorcunov@openvz.org, matthltc@us.ibm.com, akpm@linux-foundation.org, luto@amacapital.net, vbabka@suse.cz, xemul@virtuozzo.com Subject: Re: [PATCH] prctl: remove one-shot limitation for changing exe link Message-ID: <20160712170144.GC4557@redhat.com> References: <20160712152940.24895.61315.stgit@localhost.localdomain> <20160712164233.GA4557@redhat.com> <69b3bfd5-02aa-51ad-12b4-dc8d330b6c67@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <69b3bfd5-02aa-51ad-12b4-dc8d330b6c67@virtuozzo.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 12 Jul 2016 17:01:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12, Stanislav Kinsburskiy wrote: > > 12.07.2016 18:42, Oleg Nesterov пишет: >> But I would like to ack it in any case. I never understood why do we >> want/need this MMF_EXE_FILE_CHANGED check, I suggested to remove it >> many times. >> >> And can't resist, please note the xchg() below. Currently (before this >> patch) we do not need it. I was specially added to ensure that we can >> just remove this test_and_set_bit(MMF_EXE_FILE_CHANGED) without adding >> a race. > > Thanks, Oleg. I'll take a look. > But should this be addressed in this patch? Especially if it's not > needed even now (before this patch)? Sorry for confusion... Yes, it is not needed now (before this patch). Because only one caller of prctl_set_mm_exe_file() can succced and update mm->exe_file. So we could just do fput(mm->exe_file); mm->exe_file = get_file(exe.file); But after this patch we do need this xchg(), otherwise 2 callers of prctl_set_mm_exe_file() can race with each other. And this was the actual reason for xchg: simplify the MMF_EXE_FILE_CHANGED removal in future. Oleg.