Linux filesystem development
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Naresh Kamboju" <naresh.kamboju@linaro.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org, lkft-triage@lists.linaro.org
Cc: "Jan Kara" <jack@suse.cz>,
	"Christian Brauner" <brauner@kernel.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Dan Carpenter" <dan.carpenter@linaro.org>,
	"Anders Roxell" <anders.roxell@linaro.org>
Subject: Re: fs/proc/task_mmu.c:598:48: error: cast to pointer from integer of different size
Date: Mon, 01 Jul 2024 13:58:05 +0200	[thread overview]
Message-ID: <5f1f44be-80ad-4b4e-90a0-c2e4e8cd3dbf@app.fastmail.com> (raw)
In-Reply-To: <CA+G9fYsk85UOsa0ijXcYRvvZLXEMQKe4phWhND+0qSNP36N5Tw@mail.gmail.com>

On Mon, Jul 1, 2024, at 12:19, Naresh Kamboju wrote:
> fs/proc/task_mmu.c: In function 'do_procmap_query':
> fs/proc/task_mmu.c:598:48: error: cast to pointer from integer of
> different size [-Werror=int-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: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
>   605 |         if (karg.build_id_size && copy_to_user((void __user
> *)karg.build_id_addr,
>       |                                                ^
> cc1: all warnings being treated as errors
>

There is already a fix in linux-next:

@@ -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;
        }


This could be expressed slightly nicer using u64_to_user_ptr(),
but functionally that is the same.

I also see a slight issue in the use of .compat_ioctl:

 const struct file_operations proc_pid_maps_operations = {
        .open           = pid_maps_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = proc_map_release,
+       .unlocked_ioctl = procfs_procmap_ioctl,
+       .compat_ioctl   = procfs_procmap_ioctl,
 };
 

Since the argument is always a pointer, this should be

       .compat_ioctl = compat_ptr_ioctl,

In practice this is only relevant on 32-bit s390
tasks to sanitize the pointer value.

     Arnd

  reply	other threads:[~2024-07-01 11:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 10:19 fs/proc/task_mmu.c:598:48: error: cast to pointer from integer of different size Naresh Kamboju
2024-07-01 11:58 ` Arnd Bergmann [this message]
2024-07-01 17:40   ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f1f44be-80ad-4b4e-90a0-c2e4e8cd3dbf@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=anders.roxell@linaro.org \
    --cc=andrii@kernel.org \
    --cc=brauner@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox