From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 749DD21D5B0 for ; Wed, 12 Aug 2026 01:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786497444; cv=none; b=GouH6aC0acs35qRz2zwAw09Wkhhyy7TVlwDfB5zbRk+cDpWbVrRFgeNxbqEdjd3AtP26O3eLgSumZs4wcdbfYsxVGgApgSavTcqUiarwLriM1ixqWvLQri8TVqK+UZT4R0YiygNsguJcV+7+kciM9VW4DKkGWk0ZBol76t3T0tc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786497444; c=relaxed/simple; bh=LYKaHmQ78R2hfa+iTvaCSsvDTEDxqxbI4Px+ls8mvvo=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ond16j6J0STC9EZ9SUrxn1IXIvmIaq4BZCzp07RMZf0IDfa89+wQ7nTaqAZxyI3ehzt1E5gZq579bHceRR5UtKGoqVN/GREcVxZ6cS6KY59LcooKZqFnw5+jCX3KH/rG/FFsP6+PZt8vPBMMSfjvvTehsZNpf7Gc2f/faoNudF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=qODgwZxP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="qODgwZxP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A25E61F000E9; Wed, 12 Aug 2026 01:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786497443; bh=SxdYehvPB2WVYUbztSXNwmjxjvx+FvtqXP7MGmiyaJk=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=qODgwZxPYAtmz154ADGy5Hq7StozSnJMk5fAiVAVk9yNXDIG7sO1OBNjx8WPvFbNo 0T5FM1PncijnVWJL05S8Usky00wQZWasUBNWABNXspzjBAQmIxsq8JcaQ22vAthuop MwksMB6eGlKmahVC/bNf8nIBTaJzvgbh5x/o7XRI= Date: Tue, 11 Aug 2026 18:17:21 -0700 From: Andrew Morton To: Alex Elder Cc: david@kernel.org, pjw@kernel.org, brauner@kernel.org, ljs@kernel.org, demiobenour@gmail.com, tglx@kernel.org, debug@rivosinc.com, oleg@redhat.com, thomas.weissschuh@linutronix.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/sys.c: use RCU when accessing task_struct->real_parent Message-Id: <20260811181721.f9e383fdb84f963520c664b6@linux-foundation.org> In-Reply-To: <20260811190501.1486442-1-elder@riscstar.com> References: <20260811190501.1486442-1-elder@riscstar.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 11 Aug 2026 14:05:00 -0500 Alex Elder wrote: > In the setpgid() syscall definition, a check is made to determine > whether the target process is in the same thread group as the > current process. The check accesses the target process's real_parent > pointer directly, however that field is supposed to be accessed via > RCU. Use rcu_dereference() to avoid this C=1 build warning: > > kernel/sys.c:1144:32: warning: incorrect type in argument 1 (different address spaces) Oh. Why don't all those other uses of ->real_parent produce this warning? > --- a/kernel/sys.c > +++ b/kernel/sys.c > @@ -1114,6 +1114,7 @@ COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf) > SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) > { > struct task_struct *p; > + struct task_struct *real_parent; > struct task_struct *group_leader = current->group_leader; > struct pid *pids[PIDTYPE_MAX] = { 0 }; > struct pid *pgrp; > @@ -1141,7 +1142,8 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) > if (!thread_group_leader(p)) > goto out; > > - if (same_thread_group(p->real_parent, group_leader)) { > + real_parent = rcu_dereference(p->real_parent); > + if (same_thread_group(real_parent, group_leader)) { > err = -EPERM; > if (task_session(p) != task_session(group_leader)) > goto out; >