History

Merge branch 'akpm' (patches from Andrew)

Merge more updates from Andrew Morton: "147 patches, based on 7d2a07b769330c34b4deabeed939325c77a7ec2f. Subsystems affected by this patch series: mm (memory-hotplug, rmap, ioremap, highmem, cleanups, secretmem, kfence, damon, and vmscan), alpha, percpu, procfs, misc, core-kernel, MAINTAINERS, lib, checkpatch, epoll, init, nilfs2, coredump, fork, pids, criu, kconfig, selftests, ipc, and scripts" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (94 commits) scripts: check_extable: fix typo in user error message mm/workingset: correct kernel-doc notations ipc: replace costly bailout check in sysvipc_find_ipc() selftests/memfd: remove unused variable Kconfig.debug: drop selecting non-existing HARDLOCKUP_DETECTOR_ARCH configs: remove the obsolete CONFIG_INPUT_POLLDEV prctl: allow to setup brk for et_dyn executables pid: cleanup the stale comment mentioning pidmap_init(). kernel/fork.c: unexport get_{mm,task}_exe_file coredump: fix memleak in dump_vma_snapshot() fs/coredump.c: log if a core dump is aborted due to changed file permissions nilfs2: use refcount_dec_and_lock() to fix potential UAF nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group nilfs2: fix memory leak in nilfs_sysfs_delete_##name##_group nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group nilfs2: fix NULL pointer in nilfs_##name##_attr_release nilfs2: fix memory leak in nilfs_sysfs_create_device_group trap: cleanup trap_init() init: move usermodehelper_enable() to populate_rootfs() ...

Linus Torvalds committed 5 years ago

Commit 2d338202 parents cc09ee8 b285437149 files · +5341 −930Browse files

Showing the changes to kernel (5 of 149 files). Show all

Unified · Split

5 files
  1. kernel/acct.c +1 −1
  2. kernel/fork.c +0 −2
  3. kernel/profile.c +11 −10
  4. kernel/sys.c +0 −7
  5. kernel/user.c +25 −0
kernel/acct.c+1−1
@@ -478,7 +478,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) · 477 unmodified lines
478478 /*
479479 * Accounting records are not subject to resource limits.
480480 */
481− flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
481+ flim = rlimit(RLIMIT_FSIZE);
482482 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
483483 /* Perform file operations on behalf of whoever enabled accounting */
484484 orig_cred = override_creds(file->f_cred);
kernel/fork.c+0−2
@@ -1262,7 +1262,6 @@ struct file *get_mm_exe_file(struct mm_struct *mm) · 1261 unmodified lines
12621262 rcu_read_unlock();
12631263 return exe_file;
12641264 }
1265−EXPORT_SYMBOL(get_mm_exe_file);
12661265
12671266 /**
12681267 * get_task_exe_file - acquire a reference to the task's executable file
@@ -1285,7 +1284,6 @@ struct file *get_task_exe_file(struct task_struct *task) · 16 unmodified lines
12851284 task_unlock(task);
12861285 return exe_file;
12871286 }
1288−EXPORT_SYMBOL(get_task_exe_file);
12891287
12901288 /**
12911289 * get_task_mm - acquire a reference to the task's mm
kernel/profile.c+11−10
@@ -41,7 +41,8 @@ struct profile_hit { · 40 unmodified lines
4141 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
4242
4343 static atomic_t *prof_buffer;
44−static unsigned long prof_len, prof_shift;
44+static unsigned long prof_len;
45+static unsigned short int prof_shift;
4546
4647 int prof_on __read_mostly;
4748 EXPORT_SYMBOL_GPL(prof_on);
@@ -67,8 +68,8 @@ int profile_setup(char *str) · 19 unmodified lines
6768 if (str[strlen(sleepstr)] == ',')
6869 str += strlen(sleepstr) + 1;
6970 if (get_option(&str, &par))
70− prof_shift = par;
71− pr_info("kernel sleep profiling enabled (shift: %ld)\n",
71+ prof_shift = clamp(par, 0, BITS_PER_LONG - 1);
72+ pr_info("kernel sleep profiling enabled (shift: %u)\n",
7273 prof_shift);
7374 #else
7475 pr_warn("kernel sleep profiling requires CONFIG_SCHEDSTATS\n");
@@ -78,21 +79,21 @@ int profile_setup(char *str) · 3 unmodified lines
7879 if (str[strlen(schedstr)] == ',')
7980 str += strlen(schedstr) + 1;
8081 if (get_option(&str, &par))
81− prof_shift = par;
82− pr_info("kernel schedule profiling enabled (shift: %ld)\n",
82+ prof_shift = clamp(par, 0, BITS_PER_LONG - 1);
83+ pr_info("kernel schedule profiling enabled (shift: %u)\n",
8384 prof_shift);
8485 } else if (!strncmp(str, kvmstr, strlen(kvmstr))) {
8586 prof_on = KVM_PROFILING;
8687 if (str[strlen(kvmstr)] == ',')
8788 str += strlen(kvmstr) + 1;
8889 if (get_option(&str, &par))
89− prof_shift = par;
90− pr_info("kernel KVM profiling enabled (shift: %ld)\n",
90+ prof_shift = clamp(par, 0, BITS_PER_LONG - 1);
91+ pr_info("kernel KVM profiling enabled (shift: %u)\n",
9192 prof_shift);
9293 } else if (get_option(&str, &par)) {
93− prof_shift = par;
94+ prof_shift = clamp(par, 0, BITS_PER_LONG - 1);
9495 prof_on = CPU_PROFILING;
95− pr_info("kernel profiling enabled (shift: %ld)\n",
96+ pr_info("kernel profiling enabled (shift: %u)\n",
9697 prof_shift);
9798 }
9899 return 1;
@@ -468,7 +469,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos) · 369 unmodified lines
468469 unsigned long p = *ppos;
469470 ssize_t read;
470471 char *pnt;
471− unsigned int sample_step = 1 << prof_shift;
472+ unsigned long sample_step = 1UL << prof_shift;
472473
473474 profile_flip_buffers();
474475 if (p >= (prof_len+1)*sizeof(unsigned int))
kernel/sys.c+0−7
@@ -1929,13 +1929,6 @@ static int validate_prctl_map_addr(struct prctl_mm_map *prctl_map) · 1928 unmodified lines
19291929
19301930 error = -EINVAL;
19311931
1932− /*
1933− * @brk should be after @end_data in traditional maps.
1934− */
1935− if (prctl_map->start_brk <= prctl_map->end_data ||
1936− prctl_map->brk <= prctl_map->end_data)
1937− goto out;
1938−
19391932 /*
19401933 * Neither we should allow to override limits if they set.
19411934 */
kernel/user.c+25−0
@@ -129,6 +129,22 @@ static struct user_struct *uid_hash_find(kuid_t uid, struct hlist_head *hashent) · 128 unmodified lines
129129 return NULL;
130130 }
131131
132+static int user_epoll_alloc(struct user_struct *up)
133+{
134+#ifdef CONFIG_EPOLL
135+ return percpu_counter_init(&up->epoll_watches, 0, GFP_KERNEL);
136+#else
137+ return 0;
138+#endif
139+}
140+
141+static void user_epoll_free(struct user_struct *up)
142+{
143+#ifdef CONFIG_EPOLL
144+ percpu_counter_destroy(&up->epoll_watches);
145+#endif
146+}
147+
132148 /* IRQs are disabled and uidhash_lock is held upon function entry.
133149 * IRQ state (as stored in flags) is restored and uidhash_lock released
134150 * upon function exit.
@@ -138,6 +154,7 @@ static void free_user(struct user_struct *up, unsigned long flags) · 3 unmodified lines
138154 {
139155 uid_hash_remove(up);
140156 spin_unlock_irqrestore(&uidhash_lock, flags);
157+ user_epoll_free(up);
141158 kmem_cache_free(uid_cachep, up);
142159 }
143160
@@ -185,6 +202,10 @@ struct user_struct *alloc_uid(kuid_t uid) · 41 unmodified lines
185202
186203 new->uid = uid;
187204 refcount_set(&new->__count, 1);
205+ if (user_epoll_alloc(new)) {
206+ kmem_cache_free(uid_cachep, new);
207+ return NULL;
208+ }
188209 ratelimit_state_init(&new->ratelimit, HZ, 100);
189210 ratelimit_set_flags(&new->ratelimit, RATELIMIT_MSG_ON_RELEASE);
190211
@@ -195,6 +216,7 @@ struct user_struct *alloc_uid(kuid_t uid) · 4 unmodified lines
195216 spin_lock_irq(&uidhash_lock);
196217 up = uid_hash_find(uid, hashent);
197218 if (up) {
219+ user_epoll_free(new);
198220 kmem_cache_free(uid_cachep, new);
199221 } else {
200222 uid_hash_insert(new, hashent);
@@ -216,6 +238,9 @@ static int __init uid_cache_init(void) · 15 unmodified lines
216238 for(n = 0; n < UIDHASH_SZ; ++n)
217239 INIT_HLIST_HEAD(uidhash_table + n);
218240
241+ if (user_epoll_alloc(&root_user))
242+ panic("root_user epoll percpu counter alloc failed");
243+
219244 /* Insert the root user immediately (init already runs as root) */
220245 spin_lock_irq(&uidhash_lock);
221246 uid_hash_insert(&root_user, uidhashentry(GLOBAL_ROOT_UID));