From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63B6D21B9DA for ; Thu, 11 Dec 2025 01:20:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765416013; cv=none; b=Zf6Qy89ZZN2uI8Akjc2ceTyvpHTeztjhbCLxQF6uOToeJTg9LsRyHIl7v6JRDSI1zWO8gqORoHAG5YHu8HI9b5wC5Q7eJx2a3aMU9MDC0+OkhRlNFxHJpVK0W/jjwrXaxhRFaxboXX6UoFi5zhMkXdevh1ensE6aoloeS2ANWtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765416013; c=relaxed/simple; bh=kYmaS1EySI2ZpVOrBQ5II91JbUvOcTxVrKIgckXw1dg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FnhTJ+GF91kn8yvOaxkBHUrhNmE800z/9xuJSACdrFgE/5SPX6j6K74ZASgWhFJHlhYo8i5jUfM2fzj0+030Dkh9oniFSTdlai6onTBX0oG6bfzco9RB1dxXmamKoBGV5mO30rk7HEfkN5DbNrYz8KNKUidg0fCwIBibsHX6rAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3FGyP1bl; arc=none smtp.client-ip=209.85.218.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3FGyP1bl" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-b79f8f988faso32257166b.2 for ; Wed, 10 Dec 2025 17:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765416010; x=1766020810; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=meKtWNpBilYixdM6fRPymu7e3W79Vp1jzlEWK7aJOMU=; b=3FGyP1bllhHAe8JF7O5UZ372D1fAvs8CCrXaQxhq3DjhHGncgucrAjQbdwzGOGDhel KlCV7Wp+vSfV8xdcRUgzrYumsii4XhCVo4kqArzOO34WnbfjWVMCfOfjAVMum3YPiJFR Y+WfsefTArskVzeZSaWYMAUQ2MK4DjpJDgYRBPHHDKy4jgjf2p+BLI1tTwZ9hTUgWQMc ev8ENEG3P0KArgMrmWk5EVgDETVeLBvohwuFzCFN6LMh6qXCiMywqQZ8Ve44Wozfb9WJ brnFiTF9AShvsfxyY5flCkvQT/tSNu82pwYpYnKMlXdnDuvf1Nz5qlhSlAqS+/mj5PqT UnwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765416010; x=1766020810; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=meKtWNpBilYixdM6fRPymu7e3W79Vp1jzlEWK7aJOMU=; b=Stikq6OYyhPX2OMC4a1+2eqCo049+MvZKWrePiXW9fkgjFHqe1fivP87YGXDP4NaVZ FOJQeMzGlRGXB9sJTXiFL0Ohx5RcSW4RAjF0zYwZUXdz+b0A1kov6qPpqmJhkB5Wz6GJ TEENfclIe1lZS5okql0YgSiWpdV6AXT6I1XTfomgRgx4ryAhIkOq3+59mL1v1EBIyEZW 0siM6Jsai3KEcWXXTfA4tH9ajmCGLkd4NAClG6m0/n8NdB96X+OpzjhJQ8XFD5N0tVyt NJ5n+3U/Q2WbNw3dvA5G379j7nOVCjbcUEjGPHApGmGwhQ2OErOMAyNRwsuzdP2XnOn3 woRw== X-Forwarded-Encrypted: i=1; AJvYcCVR0ZLrNchjz4dlURi0/rjyWwglX7XS8M6asgj0ruDBSlkEHIun8qtQDhBA2JNgjQV2rlsyG9oBW+WFoZc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1ONwUr7vM5GLO9ytvhfXugnnuI3JDHL8dmp0naHXqA7n7FeaS 7WgcTvR8DgWlorvmhgf0AwsgyWOT08F6xQ2c/i9qzvBcs6IaLyG9L+2K4L7nQo06yyLsGwcnfYb M5Dk9QIEtGgQwr8ttIg== X-Google-Smtp-Source: AGHT+IGfY76vCQSvfYBdPLqKoAMxg8hBUNzmeY2CO2o9Low3SkoekY/jMRCYPoZXYyb6oBlTLvX0hsVkVhxBbCk= X-Received: from ejctf13.prod.google.com ([2002:a17:907:8d8d:b0:b7a:21aa:8972]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:9613:b0:b73:42df:27a with SMTP id a640c23a62f3a-b7ce8345c0dmr413515166b.1.1765416009673; Wed, 10 Dec 2025 17:20:09 -0800 (PST) Date: Thu, 11 Dec 2025 01:20:08 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: Message-ID: Subject: Re: rust: wrong SAFETY comments in group_leader() and pid() + questions From: Alice Ryhl To: Oleg Nesterov Cc: Christian Brauner , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Panagiotis Foliadis , Shankari Anand , FUJITA Tomonori , Alexey Gladkov , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Mon, Dec 08, 2025 at 03:30:00PM +0100, Oleg Nesterov wrote: > Alice, > > Thanks again for your explanations. Not that I fully understand > them, though ;) > > On 12/05, Alice Ryhl wrote: > > > > To start with, it's likely that this comment is not the right choice > > for this function, given our discussion. Most likely group_leader() > > needs to be moved to `impl CurrentTask {}` > > I obviously can't comment this proposal, > > > and the safety comment needs > > to explain why being the current task ensures that the returned &Task > > lives for long enough. > > This is simple. task->group_leader can't change or go away until > this task exits or execs. The "current" task can't exit/exec. > > (This also covers the race with mt-exec from current's subthread, > the execing thread will kill all the threads and wait until they > all pass release_task(). Only then it will change ->group_leader). > > > impl CurrentTask { > > fn group_leader(&self) -> &Task { > > // SAFETY: This is the current task, so the task must be alive. > > // Therefore the group leader cannot change, and thus it will > > // stay valid as long as self is the current task. > > unsafe { &*bindings::task_group_leader(self.as_ptr()).cast::() } > > } > > } > > Yes, the comment looks good to me. > > But we don't have the task_group_leader() helper yet, so far I > only sent the trivial initial preparations, see > https://lore.kernel.org/all/aTV1KYdcDGvjXHos@redhat.com/ > > So if you are going to move Task::group_leader to the > CurrentTask block, please use .group_leader directly, like > the current code does. Yeah I'll be moving it soon (after conferences). I'll add a Reported-by tag for you if that's okay :) Alice