Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp235005lqp; Wed, 20 Mar 2024 21:54:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1C8QjkaeV+i/5fG/h6ypuzFb2CE+P6aDnosftH/rNpnj+90bMeNx1FiToNgUe//CVgobRiRDhjy8OJ4kx6GYdsEwQMdMFJFuiEqmIvA== X-Google-Smtp-Source: AGHT+IGcSap2nBUwIvqyGqsXubHvzYqVV6c+ZpkTRJO1MRLLDh5DK7tKWfti5B9DBd4FliXss1Bj X-Received: by 2002:ac8:5f92:0:b0:431:2007:48ac with SMTP id j18-20020ac85f92000000b00431200748acmr1137336qta.38.1710996849003; Wed, 20 Mar 2024 21:54:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710996848; cv=pass; d=google.com; s=arc-20160816; b=G8O87rIZHIlCa5XXGFm5ONxG2918auokpbBI0+5DJuQQxRy+e/w5A/lrtoY/Po83Bn gGgFrKihKDgLmRkBhIZXAvpEDGJgr1nE1hzC806DWngB4ym+spDsY5Fw9BPbagVhr+JT iirk70zeHkWD20Poo51x5Rra0r9U9E8C10ggwkl2sImC7t/G/9NWmZxBSXOnYlH4Qjza O3d2WWG0AnH3B3d6eI+P+s0tbRgqCoC/tiFT3Bu+N9C2qRY7GActkQxTu8tnJhJE2O6h DG0pLVCXElZ0j6rSl3WkXTybfAq4D/UA6cpCysq8qAW/wurUrqi3paO5KRMMrSgAYfXQ u32w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=+3hJM/vrryWqnRrbEBildsXcg7SPWAKSHMy2nbEpucI=; fh=hUe0KSiAMJSQBiNfywzCnmQcLpUW+w/Qb3S09r+UhRk=; b=DAWsHbB7jJI0jQoaPyZ2rWQ3BaJ8DvmZAx74jZiq7jEZ9COL4Fu8axUusJS18DWhQ+ GOQYUgt6Kg4CsMcHfYhEid8jWMuoAYsY43HaEI7vfwJgjn09/i/u7+9BhLUE4sJfnxxI fYLFSgakVBxLjZSyVWzrENG+C9h3irqUb2D4Yb1k8IFsB7hfC6Q935C5IJScYTvdL1ZW 7IQObkR1YTLgfQ8OXxPdt8Ti7R8Lg3l6/0OBGSEsw2vZuiYhzVGdwDTWLFVRF2jGmPkB UUIOHi4feFhugMcNH6BrvuMvgZfkJwWkIXizQp5IHHJZeFaSkwNqOC3S08fANDsO9N/T 9iZw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=WYBAEEao; arc=pass (i=1 spf=pass spfdomain=me.com dkim=pass dkdomain=me.com dmarc=pass fromdomain=me.com); spf=pass (google.com: domain of linux-kernel+bounces-109655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 18-20020ac85712000000b00430c774a896si9331575qtw.110.2024.03.20.21.54.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 21:54:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=WYBAEEao; arc=pass (i=1 spf=pass spfdomain=me.com dkim=pass dkdomain=me.com dmarc=pass fromdomain=me.com); spf=pass (google.com: domain of linux-kernel+bounces-109655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7B5EF1C216D4 for ; Thu, 21 Mar 2024 04:54:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32F29335BC; Thu, 21 Mar 2024 04:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=me.com header.i=@me.com header.b="WYBAEEao" Received: from mr85p00im-ztdg06021701.me.com (mr85p00im-ztdg06021701.me.com [17.58.23.196]) (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 671262AE97 for ; Thu, 21 Mar 2024 04:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.23.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710996839; cv=none; b=fQwu/lKCJxLTNZcuJDzBGAI7hyWiVHzMD1dM4t3cY+dpYup7iMTMirHhOz9rvkstljWEW0IAanoHV5W2lk4Y5j7HZniMsYgwOGT/VZhjstkM2tRIjTBCm+MLaMsglR4Zc5t+h2YA01Wra5C+YW4LxoAwMdYEFWNZjZYovhX/4NY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710996839; c=relaxed/simple; bh=kmIKewn0OS9jBtK0VejszCjBQ3tt+jG0o6bU6vJqHAY=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=finbtyl+sltFYR7MH9xi00A/oUkBA6xNveSMi/C3QrXP6UysJqCAi9LvePjDzzFKyAFoznC+WfyfaxLI4H+X1dv6EMRO8zv9mM7oyvhuUoI6Kv6ZqPsHW/bBnz3aTm2oS6tO3kbYZX1015zH0IF92aUXWrxTMPEGB2lGS8Kzneg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=me.com; spf=pass smtp.mailfrom=me.com; dkim=pass (2048-bit key) header.d=me.com header.i=@me.com header.b=WYBAEEao; arc=none smtp.client-ip=17.58.23.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=me.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=me.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1710996836; bh=+3hJM/vrryWqnRrbEBildsXcg7SPWAKSHMy2nbEpucI=; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To; b=WYBAEEao7veau/h+dkj5VkV+mLzEJu8UybYGkwgD5TSoAKhp7sPAkR5QvtLMl2wv7 45UIQZLM0/N2zfO5xBMX7gbZlT+g1EGm02IaGW7Hte6z5KH39+VlgiGse+P+HkSxTb 2F2XUFRJEyCT19/u+3Q9tCGGxLCBhq9sKLhk3+E/eQ4PQOmplKFxRtw/RN2tBIzMlw Zao7gbEEnHisQC8jSL7+7DWRWjM09yvapJP+EtH0kZSUysrRT4tHgVfwxCTmtS+Bpc nOBPCxD1SwaScoJWWq5XUFLYJsig5Cnb7VjnwfVKLyMlPbE57gdb5vvdHo9BooaRBN 6NQSM8bdiURbw== Received: from smtpclient.apple (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-ztdg06021701.me.com (Postfix) with ESMTPSA id A1F652633222; Thu, 21 Mar 2024 04:53:54 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PATCH] rust: init: remove impl Zeroable for Infallible From: Laine Taffin Altman In-Reply-To: <6857bb37-c4ee-4817-9b6a-e40e549b6402@proton.me> Date: Wed, 20 Mar 2024 21:53:42 -0700 Cc: Boqun Feng , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Martin Rodriguez Reboredo , stable@vger.kernel.org, rust-for-linux@vger.kernel.org, lkml Content-Transfer-Encoding: quoted-printable Message-Id: References: <20240313230713.987124-1-benno.lossin@proton.me> <93FD9491-7E2D-4324-8443-0884B7CFC6EF@me.com> <3FBC841A-968E-4AC5-83F0-E906C7EE85C3@me.com> <6857bb37-c4ee-4817-9b6a-e40e549b6402@proton.me> To: Benno Lossin X-Mailer: Apple Mail (2.3774.500.171.1.1) X-Proofpoint-ORIG-GUID: 8t8BjbHkZ_z8T1oGI4ChJjWvYynAMZf7 X-Proofpoint-GUID: 8t8BjbHkZ_z8T1oGI4ChJjWvYynAMZf7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-21_02,2024-03-18_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2403210031 On Mar 19, 2024, at 3:34=E2=80=AFAM, Benno Lossin = wrote: > On 3/19/24 06:28, Laine Taffin Altman wrote: >> On Mar 18, 2024, at 9:39=E2=80=AFPM, Boqun Feng = wrote: >>> On Mon, Mar 18, 2024 at 08:17:07PM -0700, Laine Taffin Altman wrote: >>>> On Mar 18, 2024, at 10:25=E2=80=AFAM, Boqun Feng = wrote: >>>>> On Wed, Mar 13, 2024 at 11:09:37PM +0000, Benno Lossin wrote: >>>>>> From: Laine Taffin Altman >>>>>>=20 >>>>>> It is not enough for a type to be a ZST to guarantee that zeroed = memory >>>>>> is a valid value for it; it must also be inhabited. Creating a = value of >>>>>> an uninhabited type, ZST or no, is immediate UB. >>>>>> Thus remove the implementation of `Zeroable` for `Infallible`, = since >>>>>> that type is not inhabited. >>>>>>=20 >>>>>> Cc: stable@vger.kernel.org >>>>>> Fixes: 38cde0bd7b67 ("rust: init: add `Zeroable` trait and = `init::zeroed` function") >>>>>> Closes: https://github.com/Rust-for-Linux/pinned-init/pull/13 >>>>>> Signed-off-by: Laine Taffin Altman >>>>>> Signed-off-by: Benno Lossin >>>>>=20 >>>>> I think either in the commit log or in the code comment, there = better be >>>>> a link or explanation on "(un)inhabited type". The rest looks good = to >>>>> me. >>>>=20 >>>> Would the following be okay for that purpose? >>>>=20 >>>> A type is inhabited if at least one valid value of that type = exists; a >>>> type is uninhabited if no valid values of that type exist. The = terms >>>> "inhabited" and "uninhabited" in this sense originate in type = theory, >>>> a branch of mathematics. >>>>=20 >>>> In Rust, producing an invalid value of any type is immediate = undefined >>>> behavior (UB); this includes via zeroing memory. Therefore, since = an >>>> uninhabited type has no valid values, producing any values at all = for >>>> it is UB. >>>>=20 >>>> The Rust standard library type `core::convert::Infallible` is >>>> uninhabited, by virtue of having been declared as an enum with no >>>> cases, which always produces uninhabited types in Rust. Thus, = remove >>>> the implementation of `Zeroable` for `Infallible`, thereby avoiding >>>> the UB. >>>>=20 >>>=20 >>> Yeah, this works for me. Thanks! >>=20 >> Great! Should it be re-sent or can the new wording be incorporated = upon merge? >=20 > I can re-send it for you again, or do you want to send it yourself? > I think it is also a good idea to add a link to [1] in the code, since > the above explanation is rather long and fits better in the commit > message. >=20 I=E2=80=99ll try and do it myself; thank you for sending the first round = for me and illustrating procedures! What = Reviewed-By=E2=80=99s/Signed-Off-By's should I retain? Thanks, Laine > --=20 > Cheers, > Benno >=20 > [1]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types