Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp482632rdh; Wed, 14 Feb 2024 02:52:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWLTtxH6m29Zf5EMiWhK5Fj017GVGgsvvGgkjrUbtOPLD+M4e4le9ai6Ewo1FFtmGa2yFSs9t3vtVE730tYjk0JjyNKd1j61Gj85kcigA== X-Google-Smtp-Source: AGHT+IHy7ZaOHlbWgsHxgcL9W4UOoD8lBoOO2wGSHq860oi5kJ4YsWxlOmEItJBYzlpbz+LRyKnf X-Received: by 2002:a05:6808:11ca:b0:3bf:e91c:2736 with SMTP id p10-20020a05680811ca00b003bfe91c2736mr2298297oiv.14.1707907938851; Wed, 14 Feb 2024 02:52:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707907938; cv=pass; d=google.com; s=arc-20160816; b=IqzMIlddjj1jS1w6fiyi7ncbmHDzqnst7DdbLgXCcU+tk09kUpDC3NdTY5h6rHvpzk 6XAJqfJamRzcvP5Om/6ZZvu/EIzsaqqoPAzsRlkgz1IWPwQKLYUX3VHeH388LCktleoS 6azth6UoEQWO0sscS+nqK448fAM4wBYMmAAvaaFZJ0/98eKDFh3DNq7S9HI8a0xEZgoZ nj7ajfj848DbiMr2OOVOuxrjTd869JMO2dLBOLZ9v29WTQ6f+vMtL6U8oM9zI20lVNuJ 8IlRbKkUs+8dgxn3ne3tY9x4nwiX+GlfAnSCt7pR++bZZdsOYQy6WUgxpisUFtcLVHpy cnaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=2g1mQizjkEn3VxHNfnwCGd5SJVNpMNtdqZQAgI51wCU=; fh=lWaffV2EjqqRC5iKz2JFybIvOqzK5HMoJDIv8fW4Ues=; b=RBZuUFpQ7zJP5q6+plfp+ow6NCbgWn+Ztakh6v/wUjSErIrfOL96mELNUg7wMjsMwd 3hhsO+yyXzpqSmFYmutAEXkhRnxq36IQheqdh+t8Xkcx/snf/uwYcSu0KaVx/jev+wJA 1ELNelSWMhTS1FMRZlpshuPaUZxSW5GN4o4myK1RJXeebe0XA0/IazCNIutepfKrhaLq WB0ZQ6k/JublvaKKqOoqJMqgcPGckZifmlqwBRMNdA9arbPRtzmCW3dDSiXnRrcK91/0 XAUM4aJWWVQw8ycSYd2qJ73A+g1ONndXDa9NysRcy8jIE6MM0v0+L4izwKcUOFwxvmJA CPEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zrXgyHlF; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-65082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUUdByj9dA2TQAv4a/BZkDG92HjD7JqFtfoSU9JZmlqDfTlax64CE8Bn9mYtLLb0bo2i7GTttxwGFHdyXD+qUqDwXNuzhfJ7fJz/3Fjig== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f13-20020a056214076d00b0068cdb0ede35si4937397qvz.399.2024.02.14.02.52.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:52:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zrXgyHlF; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-65082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 30F4B1C25077 for ; Wed, 14 Feb 2024 10:52:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C83A518E12; Wed, 14 Feb 2024 10:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zrXgyHlF" Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (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 7DBDA18638 for ; Wed, 14 Feb 2024 10:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907911; cv=none; b=s5PNLH2VGBG/1/CRj2AjxynYwHJGJB6pLwZh/v4+kzBfgNS3kvRty8YA/PYqOpTlzqCGp+37RCszZL41VUaTVmmf8ppizUGYsdqcGui97L7N29heYlTcYi4DrjzAA2q/d0MA5rdhoepOIaDOUoNrNzgQ9+AwJx6cq2BRKDBXyQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707907911; c=relaxed/simple; bh=FngIp4KBxf0vqziz3+ArzSp7oe/urJZKigfldVYi13c=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XC2WgpAyKmkf3//s7C+tqxR/utSwEotQXbdfCZ6hOyPdVtHpi9hn7TYadOG9HIPE8aGI1xR+nMP5JgArtnD+cCeot00fGxaS570+r6RLRbaZ5YqjETiqi/a9nPO3m7BoRWrOrRJqSRILMTeSVD7wzBY9GRRLv/e0Dt2RbtqFmpY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zrXgyHlF; arc=none smtp.client-ip=209.85.222.52 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=google.com Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-7d5bfdd2366so1945810241.3 for ; Wed, 14 Feb 2024 02:51:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707907908; x=1708512708; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2g1mQizjkEn3VxHNfnwCGd5SJVNpMNtdqZQAgI51wCU=; b=zrXgyHlFKZAdxlGFAEhVc9G81FYr3RYeNYuShQ4yP8E8rC3aopZPA22zrXy5aZs3en nUYJUIBjDB0Tcr9doCutUstpxGclzvX4hZItLoP4gP4oCl3pQcHC8oGr/2xsVpeelTN/ U3HFwWh3k2v7Dd4bcbmGubl9Dtq84ZF7ipGEj1ZJ+gIgB1/gsNVcg+IlbV0n/gWVZRKh wV3FqGfEELI4OtgBCKAbk1D8b//XX4v4xK7h0nUnYJtvUyvdmHdWZSZH4CyOJB0D7DCl rcEGCecR94nZCDr6lzS8WkdIT0Auh4eO8VNEBo760wtu/P1Y4HM0UEe4qqGfqOWIw0JR F9Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707907908; x=1708512708; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2g1mQizjkEn3VxHNfnwCGd5SJVNpMNtdqZQAgI51wCU=; b=I/lZeKr8YfGuNq7OgA0ncKfKHb7Ac/ZBkibndLjHtPK7ZQwDCc9dZ6eFyRALyKxmLL zSiE74fGWGZLOSbfiqYoYz9WBC0KmR3OZwVclcepi3BQMG5htAaHxdrduUZ1MQuFzZ9v y7Sznt9MJ5PXSZHN9bYtBIQOgzjt1P5iXlPZVJRe3fMGXP10Re8BVeR6K18KY81oFJrK qGKOnEHN0M2gzU8qhGOiInuktIRRkyqXlzWXz9BLe5/tHdhyB2jguBD/PPO1YGo4gbvS MiedMzr/qAOouUgoUDiNUkYZZLB/wyh65h6oYGB1kyOjedrfeyh4pt5Ss92wvySnA4AP if5Q== X-Forwarded-Encrypted: i=1; AJvYcCX6DbWSdBKlEpVJxLPZ6sy7hbOKLbAqvGkgh0HKlKuEdAbaoQ1kQ0Vd0oCfVIBBt/OmEDKSOsfnvjJFjhhDEymjOv/jk6N9pqij9z7u X-Gm-Message-State: AOJu0YzwTJv0WH52XIQeAQs43R9+BKVEF56WY6kE10sUwSKTKqsf87t1 5M0HduFIajharYpnssl6VpOaPJps2F8hEGE+Ue2iWlGY3L/u6zOAj8XegYq7N0y7hIjTymxdHfC 1Qa8iSpvcxzDtvrLJZC6ITne3OF765n6XXMUn X-Received: by 2002:a1f:e084:0:b0:4c0:2a9f:d3ec with SMTP id x126-20020a1fe084000000b004c02a9fd3ecmr2466287vkg.6.1707907908067; Wed, 14 Feb 2024 02:51:48 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240208-alice-mm-v2-0-d821250204a6@google.com> <20240208-alice-mm-v2-2-d821250204a6@google.com> <202402091606.A181673F0A@keescook> In-Reply-To: <202402091606.A181673F0A@keescook> From: Alice Ryhl Date: Wed, 14 Feb 2024 11:51:36 +0100 Message-ID: Subject: Re: [PATCH v2 2/4] uaccess: always export _copy_[from|to]_user with CONFIG_RUST To: Kees Cook Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Al Viro , Andrew Morton , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Christian Brauner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Feb 10, 2024 at 1:15=E2=80=AFAM Kees Cook w= rote: > > On Thu, Feb 08, 2024 at 03:47:52PM +0000, Alice Ryhl wrote: > > unsigned long res =3D n; > > might_fault(); > > if (!should_fail_usercopy() && likely(access_ok(from, n))) { > > + /* > > + * Ensure that bad access_ok() speculation will not > > + * lead to nasty side effects *after* the copy is > > + * finished: > > + */ > > + barrier_nospec(); > > This means all callers just gained this barrier. That's a behavioral > change -- is it intentional here? I don't see it mentioned in the commit > log. > > Also did this get tested with the CONFIG_TEST_USER_COPY tests? I would > expect it to be fine, but better to check and mention it in the commit > log. I just ran this with CONFIG_TEST_USER_COPY on x86 using the Android cuttlefish emulator and it passed there. I also verified that it fails if I remove the access_ok check. However, the tests succeed even if the barrier_nospec() call is removed. That said, it seems like it fails to compile on some other platforms. It seems like we need to add #include to uaccess.h to fix it. Alice