From patchwork Mon Jul 1 01:23:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 13717469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 187C6C27C4F for ; Mon, 1 Jul 2024 01:23:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D51B6B0088; Sun, 30 Jun 2024 21:23:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 383586B0089; Sun, 30 Jun 2024 21:23:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24AF46B008A; Sun, 30 Jun 2024 21:23:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 066366B0088 for ; Sun, 30 Jun 2024 21:23:57 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 77B89C189D for ; Mon, 1 Jul 2024 01:23:57 +0000 (UTC) X-FDA: 82289437314.05.BE69898 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id E679C1C000F for ; Mon, 1 Jul 2024 01:23:54 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Pwm4SjLZ; spf=pass (imf18.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719797018; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=bZsEKBHh5XV6Yd7TxOUlxf2omD6GQPRo9Qcd+UxAj7w=; b=1uSB2r0w28ww0ZFeuNxc88/2Z3TVdJL6Lxv0Ant40Tyf7Oh51C0/CcoD73D2YOVMR6llEE r8gjosygKJLSHwO7i6Q6OybjaHWYbEvmXWCUdvdXTVMH6yJntyS4sA14qfLUlip+1btk/W TDSloQOcLBxLTz4yzjn2HONXF3pUbrI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Pwm4SjLZ; spf=pass (imf18.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719797018; a=rsa-sha256; cv=none; b=OPueXrhiagC6/8r9rA8g0iooBVhm4k61PRjYyqObTPpY1dQvbU2qMNcrEgkLPX9DyIbJax z7XGbU52aMMZbf3/p4EZlUxyz7wcmEoBMssNolHFZlzr6HmOuCRkyCsx9WOQVb62UQ6chn BtTkIOspWK1iH1NQA6UV5M9dhbAzR1Q= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C52C460DE1; Mon, 1 Jul 2024 01:23:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51263C2BD10; Mon, 1 Jul 2024 01:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719797033; bh=PXEVGb9oz8orp8VLr8ThkNcfgmDcGbc5DLjK93XJEqg=; h=From:To:Cc:Subject:Date:From; b=Pwm4SjLZX09ACPcQSjvLIshCIvAiJk/sFRJChDuSLASzT3uNoYtLac5aal4BCYOsh i/Fqp5yQh370oEBurgsGrFHlQI3NlDhuz4Q2q1Fp8LJZIupqG8q0b2pSi9oGTCq4CC 0OMvWhgK9o2SmpRPeP3n2y6u6NgMZFu8EiSJvs9HMgDTjRe3OrknSf8bVK7Fh17rjI jVqCSSMdeX/uBFMkE2Sd7nzESi8/TQaDZIoNCWfTGPj3T/rtFaSrr9DPKzCPQ7Uaiy HAKdrvix+i+xoNL2o+YQCAWFDPjk7VsNb7MY73Oa0WiZZDWaZPNXMD87QfvohaTN5u l7SPm5ewg8Drg== From: Andrii Nakryiko To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, adobriyan@gmail.com, Andrii Nakryiko , Stephen Rothwell Subject: [PATCH] fs/procfs: fix integer to pointer cast warning in do_procmap_query() Date: Sun, 30 Jun 2024 18:23:48 -0700 Message-ID: <20240701012348.2409471-1-andrii@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Stat-Signature: qn86g3m7o59wahswhiwshhdkbynhotuu X-Rspam-User: X-Rspamd-Queue-Id: E679C1C000F X-Rspamd-Server: rspam02 X-HE-Tag: 1719797034-857921 X-HE-Meta: U2FsdGVkX18PCnGFXebq0Sjz0f/o+bdrXE+NeU6bnzjr5UxtDEvHdSF11mshB30ByYhEu3j4jvgyZZNgufkvMifZITSOh3HftSl7S4WgiNIs4nFPVFoucaFDiQedB75GHt5Xy5rgA/DjiPsj3vQa8j/6zlH9akDa4infLp/dSmw7HTSHncSIk4DovSd3hl3PwNC+4MEkmvC8DrsgDqoMmgvwPR6syULUWNlE8IDkzzuv72h25EGQFRQ6HzNtApYi5dVqzxUsvxcZFtfPl79olU8eXBEegWZJ75G0aSBu8PROcelysFGhDEAzet3EhatxGl74NiwWKoMqnewG2JCi38ZpddteDjL3SlkRHV58NAMfF7gkvqlNvQ9ySMcF7LvFAUG5iXNswCNcytM2vAa9vt10mqfy3S53vkX/WJUsWoxjEf+QtM6xbHngxQTqKKullCEkckDFS1Q/0rb5ssrNr03hATqcojbh1dyBGopqgMowXUZc6PMsWIcvxpoHsUGmQUieczcss220Y7QdH4ejhcUSD4QfFC0cM+nL8RLaGu+K+BZSMwiJLTkqbGefxUhO99c8LXkwzzOs7vUxUtdc1XG/IDMAQxiw1BZeUu7jkX0EPCpN/hFG+fxO73maXxQ4U+fSaLJgZsMDQLzlRAHKPApfW7551Ta1yscLe9cqBbab+5oeQtN4698tILRazJwOp2ONtpa8RElCqeFEGTcxlzaY6Aawwcm04ue4a3BSFFAVwO2gqQjhYsA4prt/mz8aFujETYgdKv4lqooQK5ZvNc9HtB6/snZKKDS0BG9FMJdFhCtsUMpBUXv1hwqZW3ohuCdH6Uu/jCiEYy8FWrJQE1bUzKxFbMIWGZSTAHmstH4tBYzoet48Xkb/KDVurAORiAvN2cjYcFNMA70xatPE+nx8EPxWd388RYCr56f8anzfXvs2i2ED8AM/DcMhTtB1Q509K2jh1OE/Ogr4b8y 6MUvCIDZ nxnDQ3CgtM3YlVO9Tldvv2TETGYwnMsWpQcXMEeS2WL2/T036T3vgLz9Frrp+94q8FPHA3tVpPXD4dduyxMX6I/Dg8+zqDf3rtnjgE7sp/OS5N+xovaoiiVuKJ7R7LSv6nNOUq+fuwjXNrHZbwgBRQ+WvMp/RVtk49GwhDQSDOYeMdhtJz71I/3nYgGf9rVEHiENA7Wp8kfLV9Z3A9wehnsVal8wTIck0DSklqZYzI2Couw3mATSJwATGxwR8UfalREsFt9k7GF7zi8xBtbFYuiK9Rxyy5KYwZVq4kV39jhQf8ol7c91NxzWG8Ue6xJEcE1sV/GLhvdvyGiJn8VT73HDfRQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 32-bit architectures compiler will complain about casting __u64 to void * pointer: fs/proc/task_mmu.c: In function 'do_procmap_query': fs/proc/task_mmu.c:598:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 598 | if (karg.vma_name_size && copy_to_user((void __user *)karg.vma_name_addr, | ^ fs/proc/task_mmu.c:605:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 605 | if (karg.build_id_size && copy_to_user((void __user *)karg.build_id_addr, | ^ Fix this by adding intermediate cast to uintptr_t. Reported-by: Stephen Rothwell Fixes: df789ce1eb90 ("fs/procfs: add build ID fetching to PROCMAP_QUERY API") Fixes: 3757be498749 ("fs/procfs: implement efficient VMA querying API for /proc//maps") Signed-off-by: Andrii Nakryiko --- fs/proc/task_mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index d99a390a0f41..e11d6197cef5 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -595,14 +595,14 @@ static int do_procmap_query(struct proc_maps_private *priv, void __user *uarg) query_vma_teardown(mm, vma); mmput(mm); - if (karg.vma_name_size && copy_to_user((void __user *)karg.vma_name_addr, + if (karg.vma_name_size && copy_to_user((void __user *)(uintptr_t)karg.vma_name_addr, name, karg.vma_name_size)) { kfree(name_buf); return -EFAULT; } kfree(name_buf); - if (karg.build_id_size && copy_to_user((void __user *)karg.build_id_addr, + if (karg.build_id_size && copy_to_user((void __user *)(uintptr_t)karg.build_id_addr, build_id_buf, karg.build_id_size)) return -EFAULT;