Skip to contentSkip to conversation

utsns: Restore proper namespace handling.

PATCH In review Eric W. Biederman 3 participants 5 messages Nov 23, 2007 – Nov 27, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utsns: Restore proper namespace handling.

When CONFIG_UTS_NS was removed it seems that we also deleted the code for handling sysctls in the other then the initial
uts namespace. This patch restores that code.

---
 kernel/utsname_sysctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/utsname_sysctl.c +2 -0
index c76c064..71f58c3 100644
@@ -18,6 +18,8 @@
 static void *get_uts(ctl_table *table, int write)
 {
 	char *which = table->data;
+	struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
+	which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
 
 	if (!write)
 		down_read(&uts_sem);
Signature · 1 line
1.5.3.rc6.17.g1911
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Eric W. Biederman

When CONFIG_UTS_NS was removed it seems that we also deleted the code for handling sysctls in the other then the initial
uts namespace. This patch restores that code.

Thanks, Eric.

Quoted 24 lines
---
 kernel/utsname_sysctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/utsname_sysctl.c +2 -0
index c76c064..71f58c3 100644
@@ -18,6 +18,8 @@
 static void *get_uts(ctl_table *table, int write)
 {
 	char *which = table->data;
+	struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
+	which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
 
 	if (!write)
 		down_read(&uts_sem);
Signature · 6 lines
1.5.3.rc6.17.g1911

_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers
#2 lore raw
Quoted 27 lines · On Mon, 26 Nov 2007 09:19:17 -0600 "Serge E. Hallyn" <[email protected]> wrote:
Quoted 6 lines · Eric W. Biederman

When CONFIG_UTS_NS was removed it seems that we also deleted the code for handling sysctls in the other then the initial
uts namespace. This patch restores that code.

Thanks, Eric.

Quoted 15 lines
---
 kernel/utsname_sysctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/utsname_sysctl.c +2 -0
index c76c064..71f58c3 100644
@@ -18,6 +18,8 @@
 static void *get_uts(ctl_table *table, int write)
 {
 	char *which = table->data;
+	struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
+	which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
 
Quoted 2 lines

kernel/utsname_sysctl.c line 25

Quoted 2 lines
kernel/utsname_sysctl.c +0 -0
 	if (!write)
 		down_read(&uts_sem);

I already have a (more codingstylely attractive) version of this from Pavel, for which I shall steal your ack.

kernel/utsname_sysctl.c renamed from kernel/utsname_sysctl.c~isolate-the-uts-namespaces-domainname-and-hostname-back +4 -0
@@ -18,6 +18,10 @@
 static void *get_uts(ctl_table *table, int write)
 {
 	char *which = table->data;
+	struct uts_namespace *uts_ns;
+
+	uts_ns = current->nsproxy->uts_ns;
+	which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
 
 	if (!write)
 		down_read(&uts_sem);

_

Those pointer tricksies are revolting. What's going on in there?

#3 lore raw
Quoted 2 lines · Andrew Morton

I already have a (more codingstylely attractive) version of this from Pavel, for which I shall steal your ack.

Perfectly fine. I overlooked that one when I generated this patch the first time (Oops). Let's just get this bug fixed.

Eric

#4 lore raw
In reply to Andrew Morton
Quoted 29 lines · Andrew Morton
Quoted 27 lines · On Mon, 26 Nov 2007 09:19:17 -0600 "Serge E. Hallyn" <[email protected]> wrote:
Quoted 6 lines · Eric W. Biederman

When CONFIG_UTS_NS was removed it seems that we also deleted the code for handling sysctls in the other then the initial
uts namespace. This patch restores that code.

Thanks, Eric.

Quoted 15 lines
---
 kernel/utsname_sysctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/utsname_sysctl.c +2 -0
index c76c064..71f58c3 100644
@@ -18,6 +18,8 @@
 static void *get_uts(ctl_table *table, int write)
 {
 	char *which = table->data;
+	struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
+	which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
 
Quoted 5 lines
Quoted 2 lines

kernel/utsname_sysctl.c line 27

Quoted 2 lines
kernel/utsname_sysctl.c +0 -0
 	if (!write)
 		down_read(&uts_sem);

I already have a (more codingstylely attractive) version of this from Pavel, for which I shall steal your ack.

Cool, thanks.

Quoted 16 lines
kernel/utsname_sysctl.c renamed from kernel/utsname_sysctl.c~isolate-the-uts-namespaces-domainname-and-hostname-back +4 -0
@@ -18,6 +18,10 @@
 static void *get_uts(ctl_table *table, int write)
 {
 	char *which = table->data;
+	struct uts_namespace *uts_ns;
+
+	uts_ns = current->nsproxy->uts_ns;
+	which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
 
 	if (!write)
 		down_read(&uts_sem);

_

Quoted 1 line

Those pointer tricksies are revolting. What's going on in there?

This is true. There is only one sysctl table, and it's data points to the location of the desired field in the initial namespace. So the trickery finds the same field in the target namespace.

I believe Eric and Pavel are working on a patchset that will make this trickery unnecessary by having sort of shadow sysctls.

-serge