From: dsneddon-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org To: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: [PATCH] spi: spidev: Fix user-space memory access. Date: Thu, 19 Jun 2014 21:52:15 -0000 [thread overview] Message-ID: <4277a609d7431f34663d19a006a5ada6.squirrel@www.codeaurora.org> (raw) When the spidev module tries to access the user space memory passed in via an IOCTL the compat_ptr function should be called to ensure compatibility between kernel space and user space. Signed-off-by: Dan Sneddon <dsneddon-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> --- drivers/spi/spidev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index e3bc23b..3a45158 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -252,14 +252,16 @@ static int spidev_message(struct spidev_data *spidev, if (u_tmp->rx_buf) { k_tmp->rx_buf = buf; if (!access_ok(VERIFY_WRITE, (u8 __user *) - (uintptr_t) u_tmp->rx_buf, + (uintptr_t)compat_ptr( + u_tmp->rx_buf), u_tmp->len)) goto done; } if (u_tmp->tx_buf) { k_tmp->tx_buf = buf; if (copy_from_user(buf, (const u8 __user *) - (uintptr_t) u_tmp->tx_buf, + (uintptr_t)compat_ptr( + u_tmp->tx_buf), u_tmp->len)) goto done; } @@ -294,8 +296,8 @@ static int spidev_message(struct spidev_data *spidev, for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) { if (u_tmp->rx_buf) { if (__copy_to_user((u8 __user *) - (uintptr_t) u_tmp->rx_buf, buf, - u_tmp->len)) { + (uintptr_t)compat_ptr(u_tmp->rx_buf), + buf, u_tmp->len)) { status = -EFAULT; goto done; } -- 1.8.4 --- sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: dsneddon@codeaurora.org To: linux-spi@vger.kernel.org Cc: broonie@kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] spi: spidev: Fix user-space memory access. Date: Thu, 19 Jun 2014 21:52:15 -0000 [thread overview] Message-ID: <4277a609d7431f34663d19a006a5ada6.squirrel@www.codeaurora.org> (raw) When the spidev module tries to access the user space memory passed in via an IOCTL the compat_ptr function should be called to ensure compatibility between kernel space and user space. Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org> --- drivers/spi/spidev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index e3bc23b..3a45158 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -252,14 +252,16 @@ static int spidev_message(struct spidev_data *spidev, if (u_tmp->rx_buf) { k_tmp->rx_buf = buf; if (!access_ok(VERIFY_WRITE, (u8 __user *) - (uintptr_t) u_tmp->rx_buf, + (uintptr_t)compat_ptr( + u_tmp->rx_buf), u_tmp->len)) goto done; } if (u_tmp->tx_buf) { k_tmp->tx_buf = buf; if (copy_from_user(buf, (const u8 __user *) - (uintptr_t) u_tmp->tx_buf, + (uintptr_t)compat_ptr( + u_tmp->tx_buf), u_tmp->len)) goto done; } @@ -294,8 +296,8 @@ static int spidev_message(struct spidev_data *spidev, for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) { if (u_tmp->rx_buf) { if (__copy_to_user((u8 __user *) - (uintptr_t) u_tmp->rx_buf, buf, - u_tmp->len)) { + (uintptr_t)compat_ptr(u_tmp->rx_buf), + buf, u_tmp->len)) { status = -EFAULT; goto done; } -- 1.8.4 --- sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
next reply other threads:[~2014-06-19 21:52 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-06-19 21:52 dsneddon-sgV2jX0FEOL9JmXXK+q4OQ [this message] 2014-06-19 21:52 ` [PATCH] spi: spidev: Fix user-space memory access dsneddon 2014-06-20 20:40 ` dsneddon
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=4277a609d7431f34663d19a006a5ada6.squirrel@www.codeaurora.org \ --to=dsneddon-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \ --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \ --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.