Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1744707lqg; Mon, 4 Mar 2024 02:21:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXvLWBnbkf+Q/WEc8A7tVFcYbuZEFDXH+3tL9DtZ/Do77sW4bk6nqU+s1cA9dHjf1fcYJYHvaryUzK3O+XVKxVzvuJVTQppUOjhUAjeCw== X-Google-Smtp-Source: AGHT+IFpffeibuBbo5xNFD97hx1G81AbJtk9sINC6avW3CXBt/diIciv+j+3LVg0PJR1xVG/UyMb X-Received: by 2002:a05:6870:dc4b:b0:21f:f485:6b71 with SMTP id nr11-20020a056870dc4b00b0021ff4856b71mr11634770oab.8.1709547701761; Mon, 04 Mar 2024 02:21:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709547701; cv=pass; d=google.com; s=arc-20160816; b=FmYoCWJ+eke+irtvS7oNKGbDBXwxJ2/E2jVUoVywPQaEV5ne2eAks2VEnQ+MyniEub HmIV77r//aqO2pu8Ea3JXnK2DN14X6erJWVrBwbTkC6MXgvVq6Q4NnuMz9urmH6RRFU6 H0/ymyNdTfiAm59DnGbKKg1fYpkyCMrnXunF3SaCo5b4Xv9IIpWPwBCFWcFXbEmQKore 9mBsI9jCwm+5TLy9m6GA4w23ZQEpMhiq6cB7h1zqM5N9kLPUYG38Y5enKhdrOmC29rb8 lVpZ4h+femf9bHJ43krbrLikYDlby58Um+ql9ju91uHpcVM8fDnPDO0lTGFna6nwDbPo +3Xw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=JtmrisRHZR6UF3WBSqph8+Mk5bBFqrMgy9HjBdcJVEk=; fh=XPJs5ZGCvlB7w9yfpC1hED1EJsKLDZjsVhRhMNCPkns=; b=ARwVF9eBbl46rb3xvRdZ98pUzGHxHJRGhsKg5LgfFGRwzOGfQh9+2NuieojvxtDYFY t7izbVTFX3cVw9ROUNtQBPZeMkV3XhLKpRtxnyYBXn468ve3yeKainkLj3fhorWNokBP /TP8agwIApZUjfaxw5iIXmu4OQSdvYKAGCd5yHNQOPqkWe4cqtKhxWZgFaxLFigUSG6F f9q4iTpsdUU2qEaAZuGSH14y46NgkYONlb1XAkof2J3GCrlBWgF6pY7TuLiOhz3pBKU9 OfZbtsrUM33eLf0ZvzI0yh1M4oHAdSiFrp0rrdUbyyA8yvoqcA1vfeWE08WdptefU8Lr uJvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eDZv0UmS; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-90395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90395-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id r2-20020aa78442000000b006e55ebbb7b6si7788757pfn.271.2024.03.04.02.21.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 02:21:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eDZv0UmS; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-90395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90395-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8DD5FB21BAF for ; Mon, 4 Mar 2024 10:15:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EC113C067; Mon, 4 Mar 2024 10:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eDZv0UmS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GXY72yH0" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 5A2F33B19E; Mon, 4 Mar 2024 10:12:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709547148; cv=none; b=oNBmChrfZaKk7qEdS+9BExCIBvSxnWfue942sO4OnfgLZFTtPaqRhrmWn9C+hZ5bfDNoMMNJdCq3G58L4W6tbmGwZPi3O831F2GjyAznwDV9xTlafnwUMQDZ9cswUaXGUXTe8gPRPXGqASTyuZkM6lI81daqx2z7GlVHPdiKcP4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709547148; c=relaxed/simple; bh=enev8MrKkQFhyKy6/g0YuchRKJkUxEiVZlXysx2toMs=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=t3bYCLwzomWxbkJ32x46lSCYTWXMYmPRslmi4+c31AjPpQ6bwYJxCK4nMK45aNor9BSY2AyQQqLOUY1IKn3TQBmt4TyNxFeirWSYUvpZIHmkQ7pNw4wV25AxeoKwuv/3oPUQreZjlPVl/6PU1c8rV2q01F/M0pXgadDteCR1ojc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=eDZv0UmS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GXY72yH0; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240304005104.677606054@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709547145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=JtmrisRHZR6UF3WBSqph8+Mk5bBFqrMgy9HjBdcJVEk=; b=eDZv0UmS37zHGyTd0OEhoci5joGpDwnN82H8rXK16SI+p1QAQGGllTQYoU0Dln0QfVvDyu w54P1LhxSFAnVZonYjgam+Nwzrkp0UDkFGn92VHsMkXDG7oEWcVCndNbPkM62UJdnBSPDY d2I62ijiuSLpz68gc7WydSBEgC5iZUdhJNSEUP5TwJg4/tqwQfwgpzi3p/P5e8NFfk0q4a sAnME1arzVTX2aCz86olZKuHMSwlaFTpQiGUo3TUwTHfDKFVrdo/z0iDNjFbyvUy7V6uj4 NpTWTDWvxQ1D1m88e7yjB8ptJaBTtFtpqMYiTlQQ2yXy7L+WI6hzq/2njaGVXg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709547145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=JtmrisRHZR6UF3WBSqph8+Mk5bBFqrMgy9HjBdcJVEk=; b=GXY72yH0oyMBAGlKJeAWMRCFXiwyVc/SK62N6NHJayvUlS1I76NnxOBgthWNkeAwjP7zd4 r4wIKfiIhaBciDDg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Uros Bizjak , linux-sparse@vger.kernel.org, lkp@intel.com, oe-kbuild-all@lists.linux.dev Subject: [patch 6/9] x86/uaccess: Add missing __force to casts in __access_ok() and valid_user_address() References: <20240303235029.555787150@linutronix.de> 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 Date: Mon, 4 Mar 2024 11:12:25 +0100 (CET) sparse complains about losing the __user address space due to the cast to long: uaccess_64.h:88:24: sparse: warning: cast removes address space '__user' of expression Annotate it with __force to tell sparse that this is intentional. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/uaccess_64.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/arch/x86/include/asm/uaccess_64.h +++ b/arch/x86/include/asm/uaccess_64.h @@ -54,7 +54,7 @@ static inline unsigned long __untagged_a * half and a user half. When cast to a signed type, user pointers * are positive and kernel pointers are negative. */ -#define valid_user_address(x) ((long)(x) >= 0) +#define valid_user_address(x) ((__force long)(x) >= 0) /* * User pointers can have tag bits on x86-64. This scheme tolerates @@ -87,8 +87,9 @@ static inline bool __access_ok(const voi if (__builtin_constant_p(size <= PAGE_SIZE) && size <= PAGE_SIZE) { return valid_user_address(ptr); } else { - unsigned long sum = size + (unsigned long)ptr; - return valid_user_address(sum) && sum >= (unsigned long)ptr; + unsigned long sum = size + (__force unsigned long)ptr; + + return valid_user_address(sum) && sum >= (__force unsigned long)ptr; } } #define __access_ok __access_ok