Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2671174lqp; Mon, 25 Mar 2024 06:16:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMra3uKgBaUHyXmygstlNUy1NHvOyMlhxj7cWZn7d7iEMQggpUe0pi1U1a0y2gS9hsXr/m0QVu10FaVZzruCsn+mPtYH88zJTYVOybsQ== X-Google-Smtp-Source: AGHT+IFbmpPH6HFrCFC3O9T4WOa1aHKykSFudapDexeUV2FXeyoQvt69T9gRRRwIUcQYH75cUAYj X-Received: by 2002:a17:903:2341:b0:1e0:310b:b833 with SMTP id c1-20020a170903234100b001e0310bb833mr8216523plh.3.1711372609728; Mon, 25 Mar 2024 06:16:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711372609; cv=pass; d=google.com; s=arc-20160816; b=LPYBa5bXDo0JD19I288fKko/FrAG3YFMC6jqqONh2tnE7J0vQiQMrIbHZCapAIwg0j +pMEh+j6OJ5/6rIr2g//I96Pr2Awzg0jOhwf4rluOeGanAIWKE/gXNN43AcaN36AWxwP QGT28pUKLR6DRnkf276faolqF2oH9hReRHg6mVuiiE2NgiKRAaYFy6U0vAPasOUqkQ3Y tODGSWl5TtiQp6AY55FG69/tdrlIjPXzG6Hj+FlRapLSjbTojU+H/Q4Jrm/8VJ0uR4pZ nqgWdB49oQPw015lQV2biQDzZy+0p8eUnTdoAZfSFbqTw1//6lh+o/68EiXTz/rst05H 2Tvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=LdtjsxWZrxWAM7FD0+ShCSR+nRDlcvFeiIDcH8g3Cvk=; fh=olxpZCNlraX9/mIJ4ElUOnnCmmKIItglBDMzVK1JWME=; b=MT4KPvQyrbEYQ6e79BhEJZR9CCdXdA7Z1QMI2ZRW8XEZDHr+QOS6rkAIlFN46LzeHC 8NK+qyfZ6CXGN5cRacplwzAY+tyXZQWxFSgnYGZNX3E+Vm4qmCJSYplXF8z+j2OkVR5R R6kPoVRoufguYkYhdMzd9dZZZKvjm5VzhKClgYy1FkJiuRzcIlQB5nZtZolMydgPAx/e zsnzJElP1Er6Dvj1zi3WSjf4F9dyWA/f7DOMQK3mrAyE+vDgLKGBv01v5cmx0p6Fqt6z hr99zYjCVYvo0RkUPrvbBhWoJP+pMuruGyuGivUvZB7USxBQ/dqywoNnrsdVOqDAw617 jvIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-116620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116620-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mc13-20020a1709032b0d00b001e0c94b2a5csi1077684plb.592.2024.03.25.06.16.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-116620-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116620-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7363B2C6B43 for ; Mon, 25 Mar 2024 13:15:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29DF815E1E9; Mon, 25 Mar 2024 09:11:25 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 9F16215E1F5 for ; Mon, 25 Mar 2024 07:30:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711351851; cv=none; b=OtD5htYJ1X0X4wvCemGNQ7EjbXM+fKozvBK5e3b8KiIQ6nYcVuak2p6qNA4ODYJvbJttZ5TtpLVBB/u7z6mORKGQVJYsvPt02a3N45JVLO5mQtoD4h5K0E9/gZ+RqzNopGMQu+aKEXQra+iviZ5MsM9ezK1hmM5jVFi/UKUSM/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711351851; c=relaxed/simple; bh=sVHZa3jrZmfABtaZ0lWF5Is6RcXMa1ISTkVnlYOC8SE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cxA9j9ZQ4j4PqnzzZzd3ScROgp0yNApUQerEU7cm5N6xBHy+TnuhQ7u2ZWFnQf8v/7obMxxWatiA8r+Lxdt6/57oKMBqIOQY2PFHS3NT+IYo/R1LWk0JxiBOnL90M5tRwYHy4PVUGI76QPSw9wf94rT6aWHo4U2zleBeCqCdgtA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 6555D20002; Mon, 25 Mar 2024 07:30:37 +0000 (UTC) Message-ID: Date: Mon, 25 Mar 2024 08:30:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] riscv: Define TASK_SIZE_MAX for __access_ok() Content-Language: en-US To: David Laight , Samuel Holland , Alexandre Ghiti Cc: Palmer Dabbelt , "linux-riscv@lists.infradead.org" , Albert Ou , Andrew Morton , Charlie Jenkins , Guo Ren , Jisheng Zhang , Kemeng Shi , "Matthew Wilcox (Oracle)" , "Mike Rapoport (IBM)" , Paul Walmsley , Xiao Wang , Yangyu Chen , "linux-kernel@vger.kernel.org" References: <20240313180010.295747-1-samuel.holland@sifive.com> <88de4a1a-047e-4be9-b5b0-3e53434dc022@sifive.com> From: Alexandre Ghiti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi David, On 24/03/2024 20:42, David Laight wrote: > ... >> The use of alternatives allows to return right away if the buffer is >> beyond the usable user address space, and it's not just "slightly >> faster" for some cases (a very large buffer with only a few bytes being >> beyond the limit or someone could fault-in all the user pages and fail >> very late...etc). access_ok() is here to guarantee that such situations >> don't happen, so actually it makes more sense to use an alternative to >> avoid that. > Is it really worth doing ANY optimisations for the -EFAULT path? > They really don't happen. > > The only fault path that matters is the one that has to page in > data from somewhere. Which is completely avoided with a strict definition of access_ok(). I see access_ok() as an already existing optimization of fault paths by avoiding them entirely when they are bound to happen. Thanks, Alex > > Provided there is a gap between the highest valid user address and the > lowest valid kernel address (may not be true on some 32bit systems) > and copy_to/from_user() do 'increasing address' copies then the > access_ok() check they do can almost certainly ignore the length. > > This may be true for pretty much all access_ok() tests? > It would certainly simplify the test. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv