Skip to contentSkip to conversation

ipv6: Add ipv6_renew_options_kern() that accepts a kernel mem pointer.

RFC PATCH Superseded Huw Davies 2 participants 2 messages Dec 22, 2015

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Huw Davies

author
#0 lore raw

RFC PATCH 8/17 ipv6: Add ipv6_renew_options_kern() that accepts a kernel mem pointer.

The functionality is equivalent to ipv6_renew_options() except that the newopt pointer is in kernel, not user, memory

The kernel memory implementation will be used by the CALIPSO network labelling engine, which needs to be able to set IPv6 hop-by-hop options.

---
 include/net/ipv6.h |   6 +++
 net/ipv6/exthdrs.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 125 insertions(+), 12 deletions(-)
include/net/ipv6.h +6 -0
index 9a5c9f0..5a72ffd 100644
@@ -304,6 +304,12 @@ struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
 					  int newtype,
 					  struct ipv6_opt_hdr __user *newopt,
 					  int newoptlen);
+struct ipv6_txoptions *
+ipv6_renew_options_kern(struct sock *sk,
+			struct ipv6_txoptions *opt,
+			int newtype,
+			struct ipv6_opt_hdr *newopt,
+			int newoptlen);
 struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
 					  struct ipv6_txoptions *opt);
 
net/ipv6/exthdrs.c +119 -12

196 lines not on this page · raw message

Signature · 7 lines
1.8.0

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]
To get help, send an email containing "help" to [email protected]
#1 lore raw
Quoted 35 lines · Huw Davies

The functionality is equivalent to ipv6_renew_options() except that the newopt pointer is in kernel, not user, memory

The kernel memory implementation will be used by the CALIPSO network labelling engine, which needs to be able to set IPv6 hop-by-hop options.

---
 include/net/ipv6.h |   6 +++
 net/ipv6/exthdrs.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 125 insertions(+), 12 deletions(-)
include/net/ipv6.h +6 -0
index 9a5c9f0..5a72ffd 100644
@@ -304,6 +304,12 @@ struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
 					  int newtype,
 					  struct ipv6_opt_hdr __user *newopt,
 					  int newoptlen);
+struct ipv6_txoptions *
+ipv6_renew_options_kern(struct sock *sk,
+			struct ipv6_txoptions *opt,
+			int newtype,
+			struct ipv6_opt_hdr *newopt,
+			int newoptlen);
 struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
 					  struct ipv6_txoptions *opt);
 
net/ipv6/exthdrs.c +0 -0
index ea7c4d6..9426b26 100644

net/ipv6/exthdrs.c ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt) · line 742

Quoted 10 lines
net/ipv6/exthdrs.c +3 -1
@@ -734,11 +734,16 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
 EXPORT_SYMBOL_GPL(ipv6_dup_options);
 
 static int ipv6_renew_option(void *ohdr,
-			     struct ipv6_opt_hdr __user *newopt, int newoptlen,
+			     struct ipv6_opt_hdr __user *newopt_user,
+			     struct ipv6_opt_hdr *newopt,
+			     int newoptlen,
 			     int inherit,
 			     struct ipv6_opt_hdr **hdr,
 			     char **p)

This looks quite ugly to me.

Wouldn't it be possible to do something like this:

ipv6_renew_option_kern(...)

{
	int ret;
	const mm_segment_t old_fs = get_fs();
	set_fs(KERNEL_DS);
	ret = ipv6_renew_option(...); // maybe you need to forcefully cast the
user away here
	set_fs(old_fs);
	return ret;
}

Bye,
Hannes