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; From patchwork Mon Jul 1 17:48:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 13718497 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 0D944C2BD09 for ; Mon, 1 Jul 2024 17:48:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC4E26B0085; Mon, 1 Jul 2024 13:48:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B75126B008A; 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 A3BF36B008C; Mon, 1 Jul 2024 13:48:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 879AB6B0085 for ; Mon, 1 Jul 2024 13:48:17 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0D6CA1A1CF9 for ; Mon, 1 Jul 2024 17:48:17 +0000 (UTC) X-FDA: 82291917834.10.F9996F1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 615B420018 for ; Mon, 1 Jul 2024 17:48:14 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pRBHaRTd; spf=pass (imf03.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=1719856072; 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:in-reply-to:references:references:dkim-signature; bh=xY0TCoFtq/6OVPlbLmxUtj3hpxfLNbBA6kdId/lKAWk=; b=l3JIb7wEw92cela5+sAi/0XlkV0kaQSVupEo8djkabFvMbnVsrF18r8TM+ab3U8WOGHwxu 7VRDOXM2et4WllC4Qzbo6gNz6YWKafL7z94ztqGmJrNGpk3PPuP/NRJGIUkjLCZKMKvXDq BqhEAaj5RF6TfZJW4zPmn44jIi0hlBk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719856072; a=rsa-sha256; cv=none; b=MJfrUS5E1vi41FUMjP4QEYfbxGo5Zd5Fit6Gi0Urm+ZZc1zVuoCPsweEU7Qpdhvv1jnZdG CvpAmo4JoSysQuVe6wClWaDxijmz3V1PvBbzp0dxFoUe8W4cuYgZ83V2H9o2PJ08Ir7Tz9 qWcjI91BW7d7lteLjHGJbJuQf+nDFiE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pRBHaRTd; spf=pass (imf03.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4A6C46173F; Mon, 1 Jul 2024 17:48:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2E24C4AF0A; Mon, 1 Jul 2024 17:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719856093; bh=vClrN8Cgz91Pyp8b4riGZaG1H0hvRxtBooe+ewQkcqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pRBHaRTdyqI4Pp5Y/yc6w73ARTYOtRfRkHODvDLacSQU8DXg5IqqKNeCjQ7n3Xa90 DjItfOERvdhm8d/MkL4MSeAMMQcDdOQxm7hm/WOXwcVfHgtqOTPyQBoI6i67kDcfcU J66uRbX6RQkj/pBFD6TczR+Wrq1n7UctUssaf4OkwPZTCkQlYw5zoELi5QhR/UV9DN cSLvU5VKtPLiY9k2sCIOpUS8SgQEujAZK5tNUPNR8+5ArPiTnggUIQK840hF9eiLdP 5lZRbPWN2Xya4e8wyFHc9vKc8P/6iB4bMQMonqZ+wLAvsvG6ZbB7ExvCwgWwPEKbIs S7qt8NJMlML9A== 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 2/2] fs/procfs: improve PROCMAP_QUERY's compat mode handling Date: Mon, 1 Jul 2024 10:48:05 -0700 Message-ID: <20240701174805.1897344-2-andrii@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701174805.1897344-1-andrii@kernel.org> References: <20240701174805.1897344-1-andrii@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 615B420018 X-Stat-Signature: uf99y9e3wgp814p51pkbzwss18zq7pck X-HE-Tag: 1719856094-812370 X-HE-Meta: U2FsdGVkX19wmC8tT2zKcP5FbUSBEqcwU93Urcpj+zj05uf+Vj9F+HdsS/AqgHFxTDp0CU95C1kChSF5HZuA+3j57T2I9AXg32187zMVpKSimyaTtWdKvhrXy/YfxUONi+WnGR9fS8dcXSPyBezZFrNB/cS6KvySpCV2j25RulHrvjmlWG2cuER62lNnUD8TkV0uhdXd6VMHiKi/qRhyql/syjgCLDoO+3afNMFEHdmDIYrw7dYUhKcn0zArqpkhGdmQGHDeg64OucUEczvE9Pr5h7KMXnCvs7MUlE3y8WcnmPym7/6VwOSmx4c9Sp70a5dw2guhrYTy7Hv8hyNIv9XBZaLtUBw4Xvd/3lOS2o0oDMEhoO6H9DM09r/PGahUNhjitUKGwursGIU4wXF/wDfQCgHum22pAfq899rvGdoiNsiXmezWyGfqWXyHrvMbCd6ZTgI1uCC8SQFqrR8psxoQPZNLzOrePFfqmq9yMjQvYtrFDuQWPGJvvIGHE1FU53bEYe/YALWbquvUvYytdqTybGhxQWAzPPMp5O8wiTCocjYrCbKTqq+k6eY6vLi+kA5OF8Gvkk06ITYrPavHghN+4vc9d6HxBRvErtFL6lqekO7pAzK+hEY4GktvVsK9a8MD0s6o1SVaTuRzYx+Szkc+96AXDoR7A57Ebyh/nR7Ia9NcARNDFh/Y1XJIgHGl12aLzM0p/NlKOG3moBYZbDs7dKLmT8Yh1gQRnfnZnoIPKbQ75eNHZa17HrwRlpg55pCWD5Y+0IPfptTWii+9VmmX6GgpBOgVStWGK7MC9Fx+g1h27umaQ7AyN7EZVdNeYbx+dQF6aPWqp46Oq9H4Fp+DCU+uXKaBKDot4l6rnBxf7EQG7cmq6Gw0Z1vHu7RBN2kXtz7gY2Fq/jkPQTkdITXo3cQJj1oR7XE5Nj+Hyzf6GUvzbPcnrg/KGg8cX78LnbaFaz0zRA/N8eTJM0c WTDNL1nj w/Y4qIRReg3RshXuSYi470GOyuTHilUNNCE4tiAo+faDeWcO2pTYInLnI41v+AaIcvBescIj9fCvc0UmPEojxCGrNHzEDDo7Y/H0qVVA/zA8mVQB8kkylro0B57PBlwZnwYNjwdd1bRVKu9AW5Qd1kR1WrgnQl+a5tqZbvw/trUY0kL68l875L7bklol8xYVB4aST0LOm9pxJwnWlFtJSeITMs0KIliSxVGc5ame4chsCMA2jtWLvkZIgAJzCApPe/+3yXKczxP6QVMH79cYLXIq1sboB5AntEiGJ 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: Kernel provides compat_ptr_ioctl() wrapper to sanitize pointers for 32-bit processes on 64-bit host architectures. Given procfs_procmap_ioctl() always expects pointer argument, this is exactly what we need. This has any effect only on 32-bit processes on s390 architecture. Suggested-by: Arnd Bergmann Fixes: 3757be498749 ("fs/procfs: implement efficient VMA querying API for /proc//maps") Signed-off-by: Andrii Nakryiko --- fs/proc/task_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 3f1d0d2f78fe..b7bb4d04e962 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -637,7 +637,7 @@ const struct file_operations proc_pid_maps_operations = { .llseek = seq_lseek, .release = proc_map_release, .unlocked_ioctl = procfs_procmap_ioctl, - .compat_ioctl = procfs_procmap_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; /*