* Transfer function to/from user space. */
| 2022 | * Transfer function to/from user space. |
| 2023 | */ |
| 2024 | static int |
| 2025 | sysctl_old_user(struct sysctl_req *req, const void *p, size_t l) |
| 2026 | { |
| 2027 | size_t i, len, origidx; |
| 2028 | int error; |
| 2029 | |
| 2030 | origidx = req->oldidx; |
| 2031 | req->oldidx += l; |
| 2032 | if (req->oldptr == NULL) |
| 2033 | return (0); |
| 2034 | /* |
| 2035 | * If we have not wired the user supplied buffer and we are currently |
| 2036 | * holding locks, drop a witness warning, as it's possible that |
| 2037 | * write operations to the user page can sleep. |
| 2038 | */ |
| 2039 | if (req->lock != REQ_WIRED) |
| 2040 | WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, |
| 2041 | "sysctl_old_user()"); |
| 2042 | i = l; |
| 2043 | len = req->validlen; |
| 2044 | if (len <= origidx) |
| 2045 | i = 0; |
| 2046 | else { |
| 2047 | if (i > len - origidx) |
| 2048 | i = len - origidx; |
| 2049 | if (req->lock == REQ_WIRED) { |
| 2050 | error = copyout_nofault(p, (char *)req->oldptr + |
| 2051 | origidx, i); |
| 2052 | } else |
| 2053 | error = copyout(p, (char *)req->oldptr + origidx, i); |
| 2054 | if (error != 0) |
| 2055 | return (error); |
| 2056 | } |
| 2057 | if (i < l) |
| 2058 | return (ENOMEM); |
| 2059 | return (0); |
| 2060 | } |
| 2061 | |
| 2062 | static int |
| 2063 | sysctl_new_user(struct sysctl_req *req, void *p, size_t l) |
nothing calls this directly
no test coverage detected