From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1EA171991CF for ; Wed, 30 Oct 2024 04:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730264393; cv=none; b=CymFK8GnTiWnO0d+UEMPaywTYpQl3NTR736vDnq3Yof4+UjtcLUNY3MFK7kpRj49j/Ef3pPkjBN1AT/mOcdVV9BlorDbmBmbA5HXKhIQaMooZVv8tTKBgGaW0zxiC7QaY13nTUKJDWLP34WPuh1rxl1Jx8csHMfXJuJCWb7EHlo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730264393; c=relaxed/simple; bh=clwkCkL3BZR7sqMAfkQC96bSOyRLVozXznaixOXl9DE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BoV+vDSPUrhOBFfIsK3u8xAzkfhtaJmLcDt+WbqnGZML00rODw75HxsVGD1VJopSvNuCnRHPpsO8EgIHnl476xk9QhnXWoR6qC3rp/i6D+kQyhL660+ukqZK4SgopFVTYwORR+vx0RXRBY3C4vEakEN0bGthDDxEpm65ILxe7rY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GURAcYsa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GURAcYsa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10DFAC4CEE4; Wed, 30 Oct 2024 04:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730264392; bh=clwkCkL3BZR7sqMAfkQC96bSOyRLVozXznaixOXl9DE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GURAcYsarscbouOoVAkYLa3mgqib+mMtxhOmhXZhTMYl+WV9MczAevmN78y1o0Ssn Zak27Gd4PMmkVsYjF9pgQ3Cy8BLzS1YOb9FJFO20epHkNoV1Yy2u59HmKuWRNK4o8D vH5i1aHb8tJ0zf7HwYu1gZby+3jLyD/CSkmJ6/YxmXtX6axNYc2qqOpQtuG/olDzcv RqQrUzVeWFHfTK4aVWGGBAypmeO8lUQxiOSmVs+d7rWEExPQ9+agnNlSRJlwtQN0cw /KvBdv1H/m3SSx9h4vXVEd4GoPVXi0ZEJk71t8nn+wr8DUpfduK335zRcRxJmsxuMi ReiuUH97ViYDQ== Date: Tue, 29 Oct 2024 21:59:50 -0700 From: Josh Poimboeuf To: Linus Torvalds Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Pawan Gupta , Waiman Long , Dave Hansen , Ingo Molnar , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Andrew Cooper , Mark Rutland , "Kirill A . Shutemov" Subject: Re: [PATCH v3 1/6] x86/uaccess: Avoid barrier_nospec() in 64-bit copy_from_user() Message-ID: <20241030045950.p6fc7xnkd3rq2gob@treble.attlocal.net> References: <5b887fe4c580214900e21f6c61095adf9a142735.1730166635.git.jpoimboe@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Tue, Oct 29, 2024 at 04:03:31PM -1000, Linus Torvalds wrote: > Hmm. So it strikes me that this still does the "access_ok()", but > that's pointless for the actual pointer masking case. One of the whole > points of the pointer masking is that we can just do this without > actually checking the address (or length) at all. > > That's why the strncpy_from_user() has the pattern of > > if (can_do_masked_user_access()) { > ... don't worry about the size of the address space .. > > and I think this code should do that too. > > IOW, I think we can do even better than your patch with something > (UNTESTED!) like the attached. > > That will also mean that any other architecture that starts doing the > user address masking trick will pick up on this automatically. > > Hmm? Yeah, it makes sense to hook into that existing can_do_masked_user_access() thing. The patch looks good, and it boots without blowing up. Thanks! Reviewed-by: Josh Poimboeuf -- Josh