From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.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 9E269326D4A for ; Tue, 3 Mar 2026 11:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772537498; cv=none; b=cjpeuUZ4mQ1OvGSVF6FUOoiFWi676/sVhlXfj8ynKwteyK7dwRNdcN0pJ0ncSAC1B3vVs0P8j9xuNq8XR+Oj9Ia0Ce6NKHkN+Jxiy6neS6B0EPrMZsfWRKBtR9+7knajRQhOzFakNjgxU8KlMVehiWWKcuQw5EwbSeQ7WlytXhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772537498; c=relaxed/simple; bh=Sh0Wyuegl3U89t2IMn2+3vPBnjuBYsEDi6+plbKyr8o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tGS7uipMRAFWmp3XZ7T6Invi5Hlp31GLJZQ481T4MIbzk2cDDRr+eMCbOkGeRzA6IxRXHSbmRWq6YjAu2n3JaZHMHhGezcwUtwVEirsj7yipa3lM1KCeD+eJRkc/j5zilQ7f1Xzx2DlLVmUn+ok0rA8nlNjGanfc/H/C3rzweH0= 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=yqgT2GLx; arc=none smtp.client-ip=209.85.221.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="yqgT2GLx" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-439c4c1056fso52616f8f.0 for ; Tue, 03 Mar 2026 03:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772537494; x=1773142294; 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=38x5OncwAiSFYUDBr2ZhbAskiL0YL/di//zDMAN1dtM=; b=yqgT2GLxsniwtcrOyrIiJw6pSiPC6zj4wvX3yzvkIFbwEJAF31yKw4VDw9pmwAfXS8 pYNTqIkLM2H87GSVNVqgUsrgvLM7M0HQyjDpqSO3jsSPCSg4kDgsTGbrr2f3ctGtcR6g wJfM1jtNYJRo2/ZjErbGHe9FSr+SRtdf9N9OaBxeaCPLhjaWcpZYa5udE1+YUm/OAcXA 2ClBw7nziN8imlAa9m9JoTmrkbeZ+ym6tTTt/k3YwSF/CFfSFcPFeMXx8eeCCRVetYWe /CgWijsPFSc5BJqilik8oZ+c8G+qwQh4zIgY3BxGUCfWhs7xD/GxIlC40Kd5kPwfmKPz U6Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772537494; x=1773142294; 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=38x5OncwAiSFYUDBr2ZhbAskiL0YL/di//zDMAN1dtM=; b=cBGJL8ltevzLR2BviJmVvopzgITKOsF4w8g5O4nKt5xnCYroSGJgwcdeI/xvfyfy8N tCAZTQuQclgEvAzc2bR71g/grF4qSFOao0S+AO9UmPo3c7So5tKsr74CuJkNr03GelPK OeBeNyMh45vI8ju7MQ0NvuwXI9zoHA8tKoS2vsAHrepLtOn+2VW2Pjh6QuWpF3HLwXEv qD72OD+S0Zt7p8Q4RiDxnRVuHlA8IvhY+TXLktSRxqY2CNiZ7Dm9zLNwQMKCjTEmH9o+ 0sX8zta5Axe4uH1OPJ5ALVHeLy9yrJmhWtxTPjL/qdI8ru/G1RIL6/TXteUBIG6V9Set ivaQ== X-Forwarded-Encrypted: i=1; AJvYcCVnXmA0N/rT1uZ5wsB/LESvsrzH8Qvs9ruipE/RP6994rYBf1ozpqm2u1LRWJvo9a1LHQJ/ESNwMwQFAT4=@vger.kernel.org X-Gm-Message-State: AOJu0YysgqkGOo3N6mzYu03VFKpATlWUXWVderBlf/sYmtQPLcY5t+V4 iHMar4wTKB3UJiztkiUphpKvkKvtWEBkCMf9zpUlINK4MSV+ZQpefdXVwc/f1Fg48Cr5mHQlXIJ gXQJrtRreu8KHdz5ovg== X-Received: from wmbbd15.prod.google.com ([2002:a05:600c:1f0f:b0:477:9dee:b5d5]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1e2a:b0:480:1dc6:2686 with SMTP id 5b1f17b1804b1-483c9ba15afmr297261305e9.13.1772537493662; Tue, 03 Mar 2026 03:31:33 -0800 (PST) Date: Tue, 3 Mar 2026 11:31:32 +0000 In-Reply-To: <20260302140424.4097655-1-lossin@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260302140424.4097655-1-lossin@kernel.org> Message-ID: Subject: Re: [PATCH v2 1/2] rust: pin-init: internal: init: remove `#[disable_initialized_field_access]` From: Alice Ryhl To: Benno Lossin Cc: Gary Guo , Miguel Ojeda , Boqun Feng , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Janne Grunau , asahi@lists.linux.dev, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Mon, Mar 02, 2026 at 03:04:14PM +0100, Benno Lossin wrote: > Gary noticed [1] that the initializer macros as well as the `[Pin]Init` > traits cannot support unaligned fields, since they use operations that > require aligned pointers. This means that any code using structs with > unaligned fields in pin-init is unsound. > > By default, the `init!` macro generates references to initialized > fields, which makes the compiler check that those fields are aligned. > However, we added the `#[disable_initialized_field_access]` attribute to > avoid this behavior in ceca298c53f9 ("rust: pin-init: internal: init: checkpatch here: missing 'commit' before ceca298c53f9 > add escape hatch for referencing initialized fields"). Thus remove the > `#[disable_initialized_field_access]` attribute from `init!`, which is > the only safe way to create an initializer handling unaligned fields. > > If support for in-place initializing structs with unaligned fields is > required in the future, we could figure out a solution. This is tracked > in [2]. > > Reported-by: Gary Guo > Link: https://rust-for-linux.zulipchat.com/#narrow/channel/561532-pin-init/topic/initialized.20field.20accessor.20detection/with/576210658 [1] Should probably be Closes: rather than Link:. > Link: https://github.com/Rust-for-Linux/pin-init/issues/112 [2] > Fixes: ceca298c53f9 ("rust: pin-init: internal: init: add escape hatch for referencing initialized fields") > Signed-off-by: Benno Lossin change itself LGTM Reviewed-by: Alice Ryhl