Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2098211ybv; Fri, 21 Feb 2020 08:51:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxw4L+N9dCALVEN/HFtwk/KkdsflOBaztdLVrVUZsr1LdxfCibfJgDnuZE8B0I73mZytGwp X-Received: by 2002:aca:4c11:: with SMTP id z17mr2660652oia.104.1582303901718; Fri, 21 Feb 2020 08:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582303901; cv=none; d=google.com; s=arc-20160816; b=eJiATusSywtUJZEGlZUrC6lMCU2wkcfR6EvcQQYtYRuWPw4AUAiPirIYa4aoEJ7sEH AIGFYFXva59WrExbdu7xIVzaVlzDYxAntZxZ0B5poAR0OcqRTPUJWpVvhKiReB1zNBNl weXKfXQjZ7GVSQVuxrkKqdiGc91q1Qr3K5HQJiG5W5WrjoQbMgCTa6n1SlqtcLDPYRaM l8wt2LbzWnf8g70e2EZweoeXyas6dtJSi2oci0gfK3MMdtfg/1R3bq+T5dLYMK5+/hSF RQTUZyaoyHDGopRJDgCgtj2m55BYXZY9RcgnPVhX18EdTYis5RlBW4ja6Du20BZa14GM UE2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4h82rv0PoKdnsyNmTUn/xy7ivRxE79f7MGtv9RQvsxs=; b=T1hwewNyD6sZUbU0Cc60dU8SpsJrQO9OWC7J156YK2gwkJhEBZw+9j6fRY9luPSMkw M1Gebb5mdUhU1xxYRekAIACQCunzHtghCcH22g+AC/bQ6Xo9NAO7bzAIBGO+VgOt5kOW 1xn0C5Yj63loFBBG38KRDsRYvvflzSUfVSHqGCcL9vvesZpExUrG06KMw+pGR0sJ1567 U1a7rkL4bA1MuZ3Nffn84utofAYdCeYMpdAwdjD4raALJXOgRjbrExCWs8UIeYvSbYXr sczqFc/UeamqeOe33dBVVWNYHJjylJq7OjmpakBmwqPOPgFojubU/1ED+f22GUw+nCof +06g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K1shmBu8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si1055572oic.220.2020.02.21.08.51.28; Fri, 21 Feb 2020 08:51:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K1shmBu8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727987AbgBUQuv (ORCPT + 99 others); Fri, 21 Feb 2020 11:50:51 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:44799 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727799AbgBUQuv (ORCPT ); Fri, 21 Feb 2020 11:50:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582303850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4h82rv0PoKdnsyNmTUn/xy7ivRxE79f7MGtv9RQvsxs=; b=K1shmBu8+u1/EsmCeJcLOaIF0aoRRyv11djXs6M4qTDQnYzkGX9nfNXZ9iN8RNF2H0Geqx rhLBJHFP4V21MftI7Z0FB/e2f+X8aWlloY8W5R8ppMf7/Ef+syM8Q0q/5B1X78Y5bOVIDf dKba6K/A0nDhzTG3K4b5gihJ92t+a3Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-NEfudibLOf2BUHT9bNEyZQ-1; Fri, 21 Feb 2020 11:50:46 -0500 X-MC-Unique: NEfudibLOf2BUHT9bNEyZQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C638119057C2; Fri, 21 Feb 2020 16:50:42 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.70]) by smtp.corp.redhat.com (Postfix) with SMTP id 229DC1001B0B; Fri, 21 Feb 2020 16:50:37 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 21 Feb 2020 17:50:42 +0100 (CET) Date: Fri, 21 Feb 2020 17:50:37 +0100 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Linus Torvalds , Al Viro , LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Daniel Micay , Djalal Harouni , "Dmitry V . Levin" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Kees Cook , Solar Designer Subject: Re: [PATCH 7/7] proc: Ensure we see the exit of each process tid exactly once Message-ID: <20200221165036.GB16646@redhat.com> References: <20200212200335.GO23230@ZenIV.linux.org.uk> <20200212203833.GQ23230@ZenIV.linux.org.uk> <20200212204124.GR23230@ZenIV.linux.org.uk> <87lfp7h422.fsf@x220.int.ebiederm.org> <87pnejf6fz.fsf@x220.int.ebiederm.org> <871rqpaswu.fsf_-_@x220.int.ebiederm.org> <87r1yp7zhc.fsf_-_@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r1yp7zhc.fsf_-_@x220.int.ebiederm.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/20, Eric W. Biederman wrote: > > +void exchange_tids(struct task_struct *ntask, struct task_struct *otask) > +{ > + /* pid_links[PIDTYPE_PID].next is always NULL */ > + struct pid *npid = READ_ONCE(ntask->thread_pid); > + struct pid *opid = READ_ONCE(otask->thread_pid); > + > + rcu_assign_pointer(opid->tasks[PIDTYPE_PID].first, &ntask->pid_links[PIDTYPE_PID]); > + rcu_assign_pointer(npid->tasks[PIDTYPE_PID].first, &otask->pid_links[PIDTYPE_PID]); > + rcu_assign_pointer(ntask->thread_pid, opid); > + rcu_assign_pointer(otask->thread_pid, npid); this breaks has_group_leader_pid()... proc_pid_readdir() can miss a process doing mt-exec but this looks fixable, just we need to update ntask->thread_pid before updating ->first. The more problematic case is __exit_signal() which does if (unlikely(has_group_leader_pid(tsk))) posix_cpu_timers_exit_group(tsk); Oleg.