13 int fd = (int)regs->di;
15 struct path parent_path;
21 parent_path = dir_f->f_path;
22 path_get(&parent_path);
23 dirstr = d_path(&parent_path, dirbuf,
sizeof(dirbuf));
24 path_put(&parent_path);
41 char *kbuf = kmalloc(ret, GFP_KERNEL);
45 if (copy_from_user(kbuf, user_dir, ret)) {
51 unsigned int offset = 0;
55 char *newbuf = kmalloc(ret, GFP_KERNEL);
61 unsigned int new_size = ret;
62 unsigned int new_off = 0;
65 size_t prefix_len = strlen(prefix);
69 while (offset < ret) {
74 if (strncmp(d->
d_name, prefix, prefix_len) == 0) {
83 if (strcmp(dirstr,
"/") == 0) {
84 len = snprintf(fullpath,
sizeof(fullpath),
"/%s", d->
d_name);
87 len = snprintf(fullpath,
sizeof(fullpath),
"%s/%s", dirstr, d->
d_name);
97 memcpy(newbuf + new_off, d, reclen);
105 if (copy_to_user(user_dir, newbuf, new_size)) {
164 struct file *f = fget(fd);
169 struct socket *sock = f->private_data;
170 struct sock *sk = sock ? sock->sk : NULL;
174 if (!sk || sk->sk_family != AF_NETLINK || sk->sk_protocol != NETLINK_SOCK_DIAG) {
181 struct user_msghdr umh;
182 if (copy_from_user(&umh, (
void __user *)regs->si,
sizeof(umh)))
185 if (umh.msg_iovlen != 1)
190 if (copy_from_user(&kv, umh.msg_iov,
sizeof(kv)))
194 char *in = kmalloc(ret, GFP_KERNEL);
197 if (copy_from_user(in, kv.iov_base, ret)) {
203 char *out = kmalloc(ret, GFP_KERNEL);
211 long remaining = ret;
212 for (
struct nlmsghdr *nlh = (
void *)in; NLMSG_OK(nlh, remaining);
213 nlh = NLMSG_NEXT(nlh, remaining)) {
215 if (nlh->nlmsg_type == NLMSG_DONE) {
216 memcpy(out + out_len, nlh, nlh->nlmsg_len);
217 out_len += nlh->nlmsg_len;
222 if (nlh->nlmsg_type == SOCK_DIAG_BY_FAMILY) {
223 struct inet_diag_msg *d = NLMSG_DATA(nlh);
224 int sport = ntohs(d->id.idiag_sport);
225 int dport = ntohs(d->id.idiag_dport);
229 snprintf(port_str,
sizeof(port_str),
"%u", sport);
233 snprintf(port_str,
sizeof(port_str),
"%u", dport);
239 memcpy(out + out_len, nlh, nlh->nlmsg_len);
240 out_len += nlh->nlmsg_len;
244 size_t err = copy_to_user(kv.iov_base, out, out_len);