From patchwork Mon Jul 1 17:48:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 13718496 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 0E64BC3065A for ; Mon, 1 Jul 2024 17:48:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55B956B0083; Mon, 1 Jul 2024 13:48:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50B726B0085; Mon, 1 Jul 2024 13:48:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F9C16B008A; Mon, 1 Jul 2024 13:48:17 -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 2341F6B0083 for ; Mon, 1 Jul 2024 13:48:17 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 92D171A1CE3 for ; Mon, 1 Jul 2024 17:48:16 +0000 (UTC) X-FDA: 82291917792.01.0C03686 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf21.hostedemail.com (Postfix) with ESMTP id AA0751C0010 for ; Mon, 1 Jul 2024 17:48:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JTlR11Z3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of andrii@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=andrii@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719856069; 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=A7Gz47YlfcUK+0hh+FpyLPlMxKFNn5rslHvzMVWPztk=; b=50tXPuHCuTIdAbN/l9d2Jq+O2k2Mm3v9E1m/A0kW08h2jI02JUTeFiQSlMPa+8WLmg5//M LpRhn0tmgFE3Vn14utZMTfJJXwHYSak8EIYH6PybUTnam3xyzpvwAiWITremy6f7RzbqNL vYFEKFlcPzeGDp22SD+Sd+2vdUD6k5M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719856069; a=rsa-sha256; cv=none; b=NZO+WLQb3lys9GK6UhKkgOMWvfMr6lmKnFG4ON1nwC4zJNOHk+etDrzT1lGgs8V7JXndK0 WjKaulKbwsZrZKJUSYaQj7DVQ5YAckyieMK9+EuMYuPB6tsfVQBOwp73Mt5JSgi+arxe8X tWsacbgSRez7HY0jQyCfH2Vci9dVbQU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JTlR11Z3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of andrii@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=andrii@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 93364CE1692; Mon, 1 Jul 2024 17:48:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D7DFC116B1; Mon, 1 Jul 2024 17:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719856089; bh=KaH8oQNKC2J+JbJiecogG+d2lkZRfkZprOTkDkcmMME=; h=From:To:Cc:Subject:Date:From; b=JTlR11Z3vOzVWgjESAvFRce5NH8+OcWnKAfBj7vbmDanIPrM/sUpbNpmek+sVO0bT uW4CS3aWvOC7fb88eYKjAP06LN865mcwXQ41hmWLnj9z8rUs8fXIwdYRWdZThVbswC jub4pkOis0IiXzHnSp2zkzofD2uyG3Se7MLjaJd7qzw8GXKpDxHRwqFtE9mpMz/Cxf PMOo5yeXGUOsBB9Sv7gT8mcmk5OxuvYOsPTSsdFj+hzkrA9lxfar6Yov77+bVhgIo8 vTJxn2SzqufaVYLQUKIT6/BRJMBdGrQrodC3bZDhZl2EP+Q6zgjgPF/OSFB7BJPkDB 533lcLLASM2hA== 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 , Arnd Bergmann , Stephen Rothwell Subject: [PATCH v2 1/2] fs/procfs: fix integer to pointer cast warning in do_procmap_query() Date: Mon, 1 Jul 2024 10:48:04 -0700 Message-ID: <20240701174805.1897344-1-andrii@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AA0751C0010 X-Stat-Signature: 1jd5m8s5gis46y3e3ymxpiiggr1fmc3g X-Rspam-User: X-HE-Tag: 1719856093-576389 X-HE-Meta: U2FsdGVkX19G9VpA7gE8II+yQsaDpVYQwykLeNohAXZqhNxavkry2QiAmsnDf/PONEKSEO+QmEFDo22gLGWkkCgYKPSaVBnKKGZkUfGlBn2GuBC0oivcYtyDWuojSG3Y9PF+LYEAb9dVKFa2rYRbXsM3ZKovr1qkH3o0nZo/P7x4XekB5H1WbkrhrD+Y2ye1tUjhEo8xobakJhSRSry+DmnCOAx6a9a3guCLefBn0qMbAOaUG1Bv1xnisPG8g+0CHH/U6/wtyHBdjYgaewJz7Y5Lnt5a6SRGs36GWDtRyRI+x9lnBFyavh5EmTdchHbU7Mqhq6sQcCMsNV03mbyDUqvJt+QQVabgJhtoA7GpKHSNU89tEXUXBibBs9h/0+/Mmx00/9piQJlTsiiW7pfFHjtWJIE7RsRP/LOwxGWtJKPrGEjCDStj1JiqUIWEAyeVHtX4VGBALAWc4ZoOfjhW3KFQP2m+b3vgiTbfhn4fGxCOZExrrZucsvQoLGlnxz/oAQ4A1nkrameE6zLzUwnKO/x2pAPrv9sLX9gNmppOlBXyaIwoYUJtD+iXxGqhcuOjF+MxKAdWkcEi2tgsqWfsJ7sKcsibiS2Feh9NQJ9nuIPgGMnkQKCQFN9QvWA5OXJzH7iDslse4eYXVXy/OC8zXUJqVri86o0Ba1a/JOHBX2jDHPKwJkJNJbyu1ber+TUNwMSGn8I2wwvjXFOSU7o9ZGZ5SK/xS2uCzgbwsFcRrfoTN2GzZurPtMAgcdSvHRYOvHZnyrbj7Yx4tJ5/BN9mgCaIhSiIbFEq5U85ja4HQvKz5Y1FvJe/V4N+EbxOnfv7iTnJg5wDTQuJPyfC5ho3HCi/ZSdXKCjrFllpvN+JhWq/iVnkKRYd5rF8iq+CQyP1vTRDOrq0lspHhCV7slz/h0xcyjte5J77mPhHnfidhDI2M416Nn5ZiQ2Cm2aBJN1RgOnAcMA0Y96vsxIvZ6A zFP/gpNm 47rYDLdLoaQWOJ0MnBrixOtSAur0ZC7EWuQLUUvZi4I4RdqYky5klF2Ef0y2h1c1WZyaJCOxqquUBonym2k/2cEHT9Ij0sWcXZbDeCnqGhaP8AVs7GZEw0knJsuiGNKFPG+Y2hcScNpOlW3GhbQhhVX4LaJYLn46o8KTEZLCGXlDglEI83iIBjUsNMq71eq6GCkRh3tTssOnSQ48pRtVeRBbOO27xtO10Aas1XAgVd2GHBqCL5Kj4JLypU9nmJ84djbBT/BZn1SSwLEw4GUoWNhLwaFkPAHfbQedN2PrZd9Q5ZozDn1O2esfVX8NDscl6pLQhHhnOvfNPiReejCRjwsQuUA== 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 using u64_to_user_ptr() helper that's meant to handle this properly. Suggested-by: Arnd Bergmann 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..3f1d0d2f78fe 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(u64_to_user_ptr(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(u64_to_user_ptr(karg.build_id_addr), build_id_buf, karg.build_id_size)) return -EFAULT;