hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/coda/psdev.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * An implementation of a loadable kernel mode driver providing
34 * multiple kernel/user space bidirectional communications links.
45 *
56 * Author: Alan Cox <alan@lxorguk.ukuu.org.uk>
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version
10
- * 2 of the License, or (at your option) any later version.
117 *
128 * Adapted to become the Linux 2.0 Coda pseudo device
139 * Peter Braam <braam@maths.ox.ac.uk>
....@@ -39,12 +35,10 @@
3935 #include <linux/device.h>
4036 #include <linux/pid_namespace.h>
4137 #include <asm/io.h>
42
-#include <linux/poll.h>
4338 #include <linux/uaccess.h>
4439
4540 #include <linux/coda.h>
46
-#include <linux/coda_psdev.h>
47
-
41
+#include "coda_psdev.h"
4842 #include "coda_linux.h"
4943
5044 #include "coda_int.h"
....@@ -105,8 +99,12 @@
10599 ssize_t retval = 0, count = 0;
106100 int error;
107101
102
+ /* make sure there is enough to copy out the (opcode, unique) values */
103
+ if (nbytes < (2 * sizeof(u_int32_t)))
104
+ return -EINVAL;
105
+
108106 /* Peek at the opcode, uniquefier */
109
- if (copy_from_user(&hdr, buf, 2 * sizeof(u_long)))
107
+ if (copy_from_user(&hdr, buf, 2 * sizeof(u_int32_t)))
110108 return -EFAULT;
111109
112110 if (DOWNCALL(hdr.opcode)) {
....@@ -124,17 +122,21 @@
124122 hdr.opcode, hdr.unique);
125123 nbytes = size;
126124 }
127
- CODA_ALLOC(dcbuf, union outputArgs *, nbytes);
125
+ dcbuf = kvmalloc(nbytes, GFP_KERNEL);
126
+ if (!dcbuf) {
127
+ retval = -ENOMEM;
128
+ goto out;
129
+ }
128130 if (copy_from_user(dcbuf, buf, nbytes)) {
129
- CODA_FREE(dcbuf, nbytes);
131
+ kvfree(dcbuf);
130132 retval = -EFAULT;
131133 goto out;
132134 }
133135
134136 /* what downcall errors does Venus handle ? */
135
- error = coda_downcall(vcp, hdr.opcode, dcbuf);
137
+ error = coda_downcall(vcp, hdr.opcode, dcbuf, nbytes);
136138
137
- CODA_FREE(dcbuf, nbytes);
139
+ kvfree(dcbuf);
138140 if (error) {
139141 pr_warn("%s: coda_downcall error: %d\n",
140142 __func__, error);
....@@ -260,7 +262,7 @@
260262 goto out;
261263 }
262264
263
- CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr));
265
+ kvfree(req->uc_data);
264266 kfree(req);
265267 out:
266268 mutex_unlock(&vcp->vc_mutex);
....@@ -322,7 +324,7 @@
322324
323325 /* Async requests need to be freed here */
324326 if (req->uc_flags & CODA_REQ_ASYNC) {
325
- CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr));
327
+ kvfree(req->uc_data);
326328 kfree(req);
327329 continue;
328330 }
....@@ -355,13 +357,13 @@
355357 .llseek = noop_llseek,
356358 };
357359
358
-static int init_coda_psdev(void)
360
+static int __init init_coda_psdev(void)
359361 {
360362 int i, err = 0;
361363 if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) {
362364 pr_err("%s: unable to get major %d\n",
363365 __func__, CODA_PSDEV_MAJOR);
364
- return -EIO;
366
+ return -EIO;
365367 }
366368 coda_psdev_class = class_create(THIS_MODULE, "coda");
367369 if (IS_ERR(coda_psdev_class)) {
....@@ -386,7 +388,8 @@
386388 MODULE_DESCRIPTION("Coda Distributed File System VFS interface");
387389 MODULE_ALIAS_CHARDEV_MAJOR(CODA_PSDEV_MAJOR);
388390 MODULE_LICENSE("GPL");
389
-MODULE_VERSION("6.6");
391
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
392
+MODULE_VERSION("7.0");
390393
391394 static int __init init_coda(void)
392395 {