]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
uacce: implement mremap in uacce_vm_ops to return -EPERM
authorYang Shen <shenyang39@huawei.com>
Tue, 2 Dec 2025 06:12:55 +0000 (14:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:27:40 +0000 (10:27 +0100)
commit 02695347be532b628f22488300d40c4eba48b9b7 upstream.

The current uacce_vm_ops does not support the mremap operation of
vm_operations_struct. Implement .mremap to return -EPERM to remind
users.

The reason we need to explicitly disable mremap is that when the
driver does not implement .mremap, it uses the default mremap
method. This could lead to a risk scenario:

An application might first mmap address p1, then mremap to p2,
followed by munmap(p1), and finally munmap(p2). Since the default
mremap copies the original vma's vm_private_data (i.e., q) to the
new vma, both munmap operations would trigger vma_close, causing
q->qfr to be freed twice(qfr will be set to null here, so repeated
release is ok).

Fixes: 015d239ac014 ("uacce: add uacce driver")
Cc: stable@vger.kernel.org
Signed-off-by: Yang Shen <shenyang39@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Acked-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Link: https://patch.msgid.link/20251202061256.4158641-4-huangchenghai2@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/uacce/uacce.c

index 65bc0d128dba22a04079af89e4083818ab82f248..0e2399a90ec5211cbba292909756c5fce2a61440 100644 (file)
@@ -211,8 +211,14 @@ static void uacce_vma_close(struct vm_area_struct *vma)
        }
 }
 
+static int uacce_vma_mremap(struct vm_area_struct *area)
+{
+       return -EPERM;
+}
+
 static const struct vm_operations_struct uacce_vm_ops = {
        .close = uacce_vma_close,
+       .mremap = uacce_vma_mremap,
 };
 
 static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma)