From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754082AbdJaXs3 (ORCPT ); Tue, 31 Oct 2017 19:48:29 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:49943 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752859AbdJaXs1 (ORCPT ); Tue, 31 Oct 2017 19:48:27 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Christian Brauner Cc: linux-kernel@vger.kernel.org, serge@hallyn.com, tycho@tycho.ws, Linux Containers References: <20171024220441.10235-1-christian.brauner@ubuntu.com> <20171024220441.10235-2-christian.brauner@ubuntu.com> <871sliubhj.fsf_-_@xmission.com> Date: Tue, 31 Oct 2017 18:48:17 -0500 In-Reply-To: <871sliubhj.fsf_-_@xmission.com> (Eric W. Biederman's message of "Tue, 31 Oct 2017 18:46:32 -0500") Message-ID: <87k1zaswu6.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1e9gGb-0000cL-A7;;;mid=<87k1zaswu6.fsf_-_@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=174.19.78.123;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/H/oAz6qiw9jb+NMqAwstInbFS++2dHpk= X-SA-Exim-Connect-IP: 174.19.78.123 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4980] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Christian Brauner X-Spam-Relay-Country: X-Spam-Timing: total 5557 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 3.3 (0.1%), b_tie_ro: 2.3 (0.0%), parse: 1.18 (0.0%), extract_message_metadata: 24 (0.4%), get_uri_detail_list: 1.45 (0.0%), tests_pri_-1000: 10 (0.2%), tests_pri_-950: 2.2 (0.0%), tests_pri_-900: 1.77 (0.0%), tests_pri_-400: 24 (0.4%), check_bayes: 22 (0.4%), b_tokenize: 8 (0.1%), b_tok_get_all: 5 (0.1%), b_comp_prob: 3.1 (0.1%), b_tok_touch_all: 2.4 (0.0%), b_finish: 0.84 (0.0%), tests_pri_0: 440 (7.9%), check_dkim_signature: 0.88 (0.0%), check_dkim_adsp: 4.7 (0.1%), tests_pri_500: 5045 (90.8%), poll_dns_idle: 5035 (90.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 3/5] userns: Don't read extents twice in m_start X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is important so reading /proc//{uid_map,gid_map,projid_map} while the map is being written does not do strange things. Signed-off-by: "Eric W. Biederman" --- kernel/user_namespace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 563a2981d7c7..4f7e357ac1e2 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -683,11 +683,13 @@ static void *m_start(struct seq_file *seq, loff_t *ppos, struct uid_gid_map *map) { loff_t pos = *ppos; + unsigned extents = map->nr_extents; + smp_rmb(); - if (pos >= map->nr_extents) + if (pos >= extents) return NULL; - if (map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS) + if (extents <= UID_GID_MAP_MAX_BASE_EXTENTS) return &map->extent[pos]; return &map->forward[pos]; -- 2.14.1