diff options
| author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-12-11 08:18:45 -0500 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-12-11 08:18:45 -0500 |
| commit | 9374020a78fce13a1cf2edf3d26f6dd7231b5c3d (patch) | |
| tree | 50c8629e6c6222c5b9681506b52afbde818c5e56 /kernel/pid_namespace.c | |
| parent | d2a0db1ee01aea154ccc460e45a16857e32c4427 (diff) | |
| parent | 29594404d7fe73cd80eaa4ee8c43dcc53970c60e (diff) | |
Merge tag 'v3.7' into v4l_for_linus
Linux 3.7
* tag 'v3.7': (1545 commits)
Linux 3.7
Input: matrix-keymap - provide proper module license
Revert "revert "Revert "mm: remove __GFP_NO_KSWAPD""" and associated damage
ipv4: ip_check_defrag must not modify skb before unsharing
Revert "mm: avoid waking kswapd for THP allocations when compaction is deferred or contended"
inet_diag: validate port comparison byte code to prevent unsafe reads
inet_diag: avoid unsafe and nonsensical prefix matches in inet_diag_bc_run()
inet_diag: validate byte code to prevent oops in inet_diag_bc_run()
inet_diag: fix oops for IPv4 AF_INET6 TCP SYN-RECV state
mm: vmscan: fix inappropriate zone congestion clearing
vfs: fix O_DIRECT read past end of block device
net: gro: fix possible panic in skb_gro_receive()
tcp: bug fix Fast Open client retransmission
tmpfs: fix shared mempolicy leak
mm: vmscan: do not keep kswapd looping forever due to individual uncompactable zones
mm: compaction: validate pfn range passed to isolate_freepages_block
mmc: sh-mmcif: avoid oops on spurious interrupts (second try)
Revert misapplied "mmc: sh-mmcif: avoid oops on spurious interrupts"
mmc: sdhci-s3c: fix missing clock for gpio card-detect
lib/Makefile: Fix oid_registry build dependency
...
Diffstat (limited to 'kernel/pid_namespace.c')
| -rw-r--r-- | kernel/pid_namespace.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 478bad2745e3..7b07cc0dfb75 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c | |||
| @@ -71,12 +71,22 @@ err_alloc: | |||
| 71 | return NULL; | 71 | return NULL; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */ | ||
| 75 | #define MAX_PID_NS_LEVEL 32 | ||
| 76 | |||
| 74 | static struct pid_namespace *create_pid_namespace(struct pid_namespace *parent_pid_ns) | 77 | static struct pid_namespace *create_pid_namespace(struct pid_namespace *parent_pid_ns) |
| 75 | { | 78 | { |
| 76 | struct pid_namespace *ns; | 79 | struct pid_namespace *ns; |
| 77 | unsigned int level = parent_pid_ns->level + 1; | 80 | unsigned int level = parent_pid_ns->level + 1; |
| 78 | int i, err = -ENOMEM; | 81 | int i; |
| 82 | int err; | ||
| 83 | |||
| 84 | if (level > MAX_PID_NS_LEVEL) { | ||
| 85 | err = -EINVAL; | ||
| 86 | goto out; | ||
| 87 | } | ||
| 79 | 88 | ||
| 89 | err = -ENOMEM; | ||
| 80 | ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); | 90 | ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); |
| 81 | if (ns == NULL) | 91 | if (ns == NULL) |
| 82 | goto out; | 92 | goto out; |
| @@ -133,19 +143,26 @@ struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *old | |||
| 133 | return create_pid_namespace(old_ns); | 143 | return create_pid_namespace(old_ns); |
| 134 | } | 144 | } |
| 135 | 145 | ||
| 136 | void free_pid_ns(struct kref *kref) | 146 | static void free_pid_ns(struct kref *kref) |
| 137 | { | 147 | { |
| 138 | struct pid_namespace *ns, *parent; | 148 | struct pid_namespace *ns; |
| 139 | 149 | ||
| 140 | ns = container_of(kref, struct pid_namespace, kref); | 150 | ns = container_of(kref, struct pid_namespace, kref); |
| 141 | |||
| 142 | parent = ns->parent; | ||
| 143 | destroy_pid_namespace(ns); | 151 | destroy_pid_namespace(ns); |
| 152 | } | ||
| 153 | |||
| 154 | void put_pid_ns(struct pid_namespace *ns) | ||
| 155 | { | ||
| 156 | struct pid_namespace *parent; | ||
| 144 | 157 | ||
| 145 | if (parent != NULL) | 158 | while (ns != &init_pid_ns) { |
| 146 | put_pid_ns(parent); | 159 | parent = ns->parent; |
| 160 | if (!kref_put(&ns->kref, free_pid_ns)) | ||
| 161 | break; | ||
| 162 | ns = parent; | ||
| 163 | } | ||
| 147 | } | 164 | } |
| 148 | EXPORT_SYMBOL_GPL(free_pid_ns); | 165 | EXPORT_SYMBOL_GPL(put_pid_ns); |
| 149 | 166 | ||
| 150 | void zap_pid_ns_processes(struct pid_namespace *pid_ns) | 167 | void zap_pid_ns_processes(struct pid_namespace *pid_ns) |
| 151 | { | 168 | { |
