mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 06:33:34 +00:00
vmemdup-user-array API and changes with it.
This is just a process PR to merge the topic branch into drm-next, this contains some core kernel and drm changes. Signed-off-by: Dave Airlie <airlied@redhat.com> -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEEKbZHaGwW9KfbeusDHTzWXnEhr4FAmU3GKAACgkQDHTzWXnE hr4niA//SBthUNEGmzYtYVnpL4O+6nFgC+Pd4HN+xgdobQUob5TfIGpsoeD+Z4KT hi7XcNdR+UElOIcNJOvzAYFZ9Joev3W2lUdwNpPtO/Oltaj5RSZr/2RqDLDKBsPl BXFKpkACUsuSLoHWNpgTmz4PvTFUJJMPUKzdQ09e+IXhM7J85AffpAHVnKFFxzjm mvcwmru64bElmlp0rySDN6RaeRqNQq3hcCfCtkRFiZgIZ+L59y+0kBsopJXHjJNX 9V3rvS0JRy5eoNkcwGUHr2EY/bO/hqIuHLv3aNbgqp4GfQAsFQ189cjXP8GmUxhX MUgOG0+/zwBieobgMTHddNI85pTDP4LNnXHzPpi3AKVkP/ByQLdeYBJe42Ea2nNS GOhA/0jRixfm2jqIc2cyZ+Ed9jyQSBs4gEV8hJOzlG6ex5qKeTLCG+9GLhxO3ZMM Ze1+iQCuFHke/9lpGVsY/gzASAZ9BPIaESaLFomH38Yei+tGtEMW1S1GUq26t4vT 6e/65UU9xvawLJVj/XckOuJe2Pjp74ViCRlYXjuO8KCorAJ5rj3CPa2Na/douZ2D YkjN7qOkUX7qDo1PBSVoIe18QP2+2pg62LXhqCMeIrQBWnViNps1/S+IyeC6VBQ0 HeMT7vFhC/mxEnzT1aiD+BQJpZgzPNNN+1Ug/kFczI0sCnyTOuQ= =8GVw -----END PGP SIGNATURE----- Merge tag 'topic/vmemdup-user-array-2023-10-24-1' of git://anongit.freedesktop.org/drm/drm into drm-next vmemdup-user-array API and changes with it. This is just a process PR to merge the topic branch into drm-next, this contains some core kernel and drm changes. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231024010905.646830-1-airlied@redhat.com
This commit is contained in:
commit
11ae5eb516
@ -510,8 +510,8 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
|
||||
/* Handle leased objects, if any */
|
||||
idr_init(&leases);
|
||||
if (object_count != 0) {
|
||||
object_ids = memdup_user(u64_to_user_ptr(cl->object_ids),
|
||||
array_size(object_count, sizeof(__u32)));
|
||||
object_ids = memdup_array_user(u64_to_user_ptr(cl->object_ids),
|
||||
object_count, sizeof(__u32));
|
||||
if (IS_ERR(object_ids)) {
|
||||
ret = PTR_ERR(object_ids);
|
||||
idr_destroy(&leases);
|
||||
|
@ -774,9 +774,9 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
|
||||
sizeof(metadata->mip_levels));
|
||||
metadata->num_sizes = num_sizes;
|
||||
metadata->sizes =
|
||||
memdup_user((struct drm_vmw_size __user *)(unsigned long)
|
||||
memdup_array_user((struct drm_vmw_size __user *)(unsigned long)
|
||||
req->size_addr,
|
||||
sizeof(*metadata->sizes) * metadata->num_sizes);
|
||||
metadata->num_sizes, sizeof(*metadata->sizes));
|
||||
if (IS_ERR(metadata->sizes)) {
|
||||
ret = PTR_ERR(metadata->sizes);
|
||||
goto out_no_sizes;
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include <linux/compiler.h> /* for inline */
|
||||
#include <linux/types.h> /* for size_t */
|
||||
#include <linux/stddef.h> /* for NULL */
|
||||
#include <linux/err.h> /* for ERR_PTR() */
|
||||
#include <linux/errno.h> /* for E2BIG */
|
||||
#include <linux/overflow.h> /* for check_mul_overflow() */
|
||||
#include <linux/stdarg.h>
|
||||
#include <uapi/linux/string.h>
|
||||
|
||||
@ -14,6 +16,44 @@ extern void *memdup_user(const void __user *, size_t);
|
||||
extern void *vmemdup_user(const void __user *, size_t);
|
||||
extern void *memdup_user_nul(const void __user *, size_t);
|
||||
|
||||
/**
|
||||
* memdup_array_user - duplicate array from user space
|
||||
* @src: source address in user space
|
||||
* @n: number of array members to copy
|
||||
* @size: size of one array member
|
||||
*
|
||||
* Return: an ERR_PTR() on failure. Result is physically
|
||||
* contiguous, to be freed by kfree().
|
||||
*/
|
||||
static inline void *memdup_array_user(const void __user *src, size_t n, size_t size)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
if (check_mul_overflow(n, size, &nbytes))
|
||||
return ERR_PTR(-EOVERFLOW);
|
||||
|
||||
return memdup_user(src, nbytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* vmemdup_array_user - duplicate array from user space
|
||||
* @src: source address in user space
|
||||
* @n: number of array members to copy
|
||||
* @size: size of one array member
|
||||
*
|
||||
* Return: an ERR_PTR() on failure. Result may be not
|
||||
* physically contiguous. Use kvfree() to free.
|
||||
*/
|
||||
static inline void *vmemdup_array_user(const void __user *src, size_t n, size_t size)
|
||||
{
|
||||
size_t nbytes;
|
||||
|
||||
if (check_mul_overflow(n, size, &nbytes))
|
||||
return ERR_PTR(-EOVERFLOW);
|
||||
|
||||
return vmemdup_user(src, nbytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Include machine specific inline routines
|
||||
*/
|
||||
|
@ -247,7 +247,7 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
|
||||
((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT))
|
||||
return -EINVAL;
|
||||
|
||||
ksegments = memdup_user(segments, nr_segments * sizeof(ksegments[0]));
|
||||
ksegments = memdup_array_user(segments, nr_segments, sizeof(ksegments[0]));
|
||||
if (IS_ERR(ksegments))
|
||||
return PTR_ERR(ksegments);
|
||||
|
||||
|
@ -331,7 +331,7 @@ long watch_queue_set_filter(struct pipe_inode_info *pipe,
|
||||
filter.__reserved != 0)
|
||||
return -EINVAL;
|
||||
|
||||
tf = memdup_user(_filter->filters, filter.nr_filters * sizeof(*tf));
|
||||
tf = memdup_array_user(_filter->filters, filter.nr_filters, sizeof(*tf));
|
||||
if (IS_ERR(tf))
|
||||
return PTR_ERR(tf);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user