Skip to content

Commit 46edaed

Browse files
committed
Merge branch 'akpm' (Andrew's fixups)
Merge random fixes from Andrew Morton. * emailed from Andrew Morton <akpm@linux-foundation.org>: (11 patches) mm: correctly synchronize rss-counters at exit/exec btree: catch NULL value before it does harm btree: fix tree corruption in btree_get_prev() ipc: shm: restore MADV_REMOVE functionality on shared memory segments drivers/platform/x86/acerhdf.c: correct Boris' mail address c/r: prctl: drop VMA flags test on PR_SET_MM_ stack data assignment c/r: prctl: add ability to get clear_tid_address c/r: prctl: add minimal address test to PR_SET_MM c/r: prctl: update prctl_set_mm_exe_file() after mm->num_exe_file_vmas removal MAINTAINERS: whitespace fixes shmem: replace_page must flush_dcache and others
2 parents 513335f + 40af1bb commit 46edaed

File tree

11 files changed

+118
-69
lines changed

11 files changed

+118
-69
lines changed

MAINTAINERS

+9-9
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ F: drivers/media/video/s5p-fimc/
10771077
ARM/SAMSUNG S5P SERIES Multi Format Codec (MFC) SUPPORT
10781078
M: Kyungmin Park <kyungmin.park@samsung.com>
10791079
M: Kamil Debski <k.debski@samsung.com>
1080-
M: Jeongtae Park <jtp.park@samsung.com>
1080+
M: Jeongtae Park <jtp.park@samsung.com>
10811081
L: linux-arm-kernel@lists.infradead.org
10821082
L: linux-media@vger.kernel.org
10831083
S: Maintained
@@ -1743,10 +1743,10 @@ F: include/linux/can/platform/
17431743
CAPABILITIES
17441744
M: Serge Hallyn <serge.hallyn@canonical.com>
17451745
L: linux-security-module@vger.kernel.org
1746-
S: Supported
1746+
S: Supported
17471747
F: include/linux/capability.h
17481748
F: security/capability.c
1749-
F: security/commoncap.c
1749+
F: security/commoncap.c
17501750
F: kernel/capability.c
17511751

17521752
CELL BROADBAND ENGINE ARCHITECTURE
@@ -2146,11 +2146,11 @@ S: Orphan
21462146
F: drivers/net/wan/pc300*
21472147

21482148
CYTTSP TOUCHSCREEN DRIVER
2149-
M: Javier Martinez Canillas <javier@dowhile0.org>
2150-
L: linux-input@vger.kernel.org
2151-
S: Maintained
2152-
F: drivers/input/touchscreen/cyttsp*
2153-
F: include/linux/input/cyttsp.h
2149+
M: Javier Martinez Canillas <javier@dowhile0.org>
2150+
L: linux-input@vger.kernel.org
2151+
S: Maintained
2152+
F: drivers/input/touchscreen/cyttsp*
2153+
F: include/linux/input/cyttsp.h
21542154

21552155
DAMA SLAVE for AX.25
21562156
M: Joerg Reuter <jreuter@yaina.de>
@@ -5185,7 +5185,7 @@ S: Maintained
51855185
F: drivers/firmware/pcdp.*
51865186

51875187
PCI ERROR RECOVERY
5188-
M: Linas Vepstas <linasvepstas@gmail.com>
5188+
M: Linas Vepstas <linasvepstas@gmail.com>
51895189
L: linux-pci@vger.kernel.org
51905190
S: Supported
51915191
F: Documentation/PCI/pci-error-recovery.txt

drivers/platform/x86/acerhdf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* (C) 2009 - Peter Feuerer peter (a) piie.net
77
* http://piie.net
8-
* 2009 Borislav Petkov <petkovbb@gmail.com>
8+
* 2009 Borislav Petkov bp (a) alien8.de
99
*
1010
* Inspired by and many thanks to:
1111
* o acerfand - Rachel Greenham

fs/exec.c

-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,6 @@ static int exec_mmap(struct mm_struct *mm)
819819
/* Notify parent that we're no longer interested in the old VM */
820820
tsk = current;
821821
old_mm = current->mm;
822-
sync_mm_rss(old_mm);
823822
mm_release(tsk, old_mm);
824823

825824
if (old_mm) {

include/linux/prctl.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@
127127
#define PR_SET_PTRACER 0x59616d61
128128
# define PR_SET_PTRACER_ANY ((unsigned long)-1)
129129

130-
#define PR_SET_CHILD_SUBREAPER 36
131-
#define PR_GET_CHILD_SUBREAPER 37
130+
#define PR_SET_CHILD_SUBREAPER 36
131+
#define PR_GET_CHILD_SUBREAPER 37
132132

133133
/*
134134
* If no_new_privs is set, then operations that grant new privileges (i.e.
@@ -142,7 +142,9 @@
142142
* asking selinux for a specific new context (e.g. with runcon) will result
143143
* in execve returning -EPERM.
144144
*/
145-
#define PR_SET_NO_NEW_PRIVS 38
146-
#define PR_GET_NO_NEW_PRIVS 39
145+
#define PR_SET_NO_NEW_PRIVS 38
146+
#define PR_GET_NO_NEW_PRIVS 39
147+
148+
#define PR_GET_TID_ADDRESS 40
147149

148150
#endif /* _LINUX_PRCTL_H */

include/linux/sched.h

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ extern int get_dumpable(struct mm_struct *mm);
439439
/* leave room for more dump flags */
440440
#define MMF_VM_MERGEABLE 16 /* KSM may merge identical pages */
441441
#define MMF_VM_HUGEPAGE 17 /* set when VM_HUGEPAGE is set on vma */
442+
#define MMF_EXE_FILE_CHANGED 18 /* see prctl_set_mm_exe_file() */
442443

443444
#define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK)
444445

ipc/shm.c

+12
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,16 @@ static int shm_fsync(struct file *file, loff_t start, loff_t end, int datasync)
393393
return sfd->file->f_op->fsync(sfd->file, start, end, datasync);
394394
}
395395

396+
static long shm_fallocate(struct file *file, int mode, loff_t offset,
397+
loff_t len)
398+
{
399+
struct shm_file_data *sfd = shm_file_data(file);
400+
401+
if (!sfd->file->f_op->fallocate)
402+
return -EOPNOTSUPP;
403+
return sfd->file->f_op->fallocate(file, mode, offset, len);
404+
}
405+
396406
static unsigned long shm_get_unmapped_area(struct file *file,
397407
unsigned long addr, unsigned long len, unsigned long pgoff,
398408
unsigned long flags)
@@ -410,6 +420,7 @@ static const struct file_operations shm_file_operations = {
410420
.get_unmapped_area = shm_get_unmapped_area,
411421
#endif
412422
.llseek = noop_llseek,
423+
.fallocate = shm_fallocate,
413424
};
414425

415426
static const struct file_operations shm_file_operations_huge = {
@@ -418,6 +429,7 @@ static const struct file_operations shm_file_operations_huge = {
418429
.release = shm_release,
419430
.get_unmapped_area = shm_get_unmapped_area,
420431
.llseek = noop_llseek,
432+
.fallocate = shm_fallocate,
421433
};
422434

423435
int is_file_shm_hugepages(struct file *file)

kernel/exit.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ void daemonize(const char *name, ...)
423423
* user space pages. We don't need them, and if we didn't close them
424424
* they would be locked into memory.
425425
*/
426+
mm_release(current, current->mm);
426427
exit_mm(current);
427428
/*
428429
* We don't want to get frozen, in case system-wide hibernation
@@ -640,7 +641,6 @@ static void exit_mm(struct task_struct * tsk)
640641
struct mm_struct *mm = tsk->mm;
641642
struct core_state *core_state;
642643

643-
mm_release(tsk, mm);
644644
if (!mm)
645645
return;
646646
/*
@@ -960,9 +960,13 @@ void do_exit(long code)
960960
preempt_count());
961961

962962
acct_update_integrals(tsk);
963-
/* sync mm's RSS info before statistics gathering */
964-
if (tsk->mm)
965-
sync_mm_rss(tsk->mm);
963+
964+
/* Set exit_code before complete_vfork_done() in mm_release() */
965+
tsk->exit_code = code;
966+
967+
/* Release mm and sync mm's RSS info before statistics gathering */
968+
mm_release(tsk, tsk->mm);
969+
966970
group_dead = atomic_dec_and_test(&tsk->signal->live);
967971
if (group_dead) {
968972
hrtimer_cancel(&tsk->signal->real_timer);
@@ -975,7 +979,6 @@ void do_exit(long code)
975979
tty_audit_exit();
976980
audit_free(tsk);
977981

978-
tsk->exit_code = code;
979982
taskstats_exit(tsk, group_dead);
980983

981984
exit_mm(tsk);

kernel/fork.c

+8
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,14 @@ void mmput(struct mm_struct *mm)
619619
module_put(mm->binfmt->module);
620620
mmdrop(mm);
621621
}
622+
623+
/*
624+
* Final rss-counter synchronization. After this point there must be
625+
* no pagefaults into this mm from the current context. Otherwise
626+
* mm->rss_stat will be inconsistent.
627+
*/
628+
if (mm)
629+
sync_mm_rss(mm);
622630
}
623631
EXPORT_SYMBOL_GPL(mmput);
624632

kernel/sys.c

+33-27
Original file line numberDiff line numberDiff line change
@@ -1786,27 +1786,13 @@ SYSCALL_DEFINE1(umask, int, mask)
17861786
}
17871787

17881788
#ifdef CONFIG_CHECKPOINT_RESTORE
1789-
static bool vma_flags_mismatch(struct vm_area_struct *vma,
1790-
unsigned long required,
1791-
unsigned long banned)
1792-
{
1793-
return (vma->vm_flags & required) != required ||
1794-
(vma->vm_flags & banned);
1795-
}
1796-
17971789
static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
17981790
{
1791+
struct vm_area_struct *vma;
17991792
struct file *exe_file;
18001793
struct dentry *dentry;
18011794
int err;
18021795

1803-
/*
1804-
* Setting new mm::exe_file is only allowed when no VM_EXECUTABLE vma's
1805-
* remain. So perform a quick test first.
1806-
*/
1807-
if (mm->num_exe_file_vmas)
1808-
return -EBUSY;
1809-
18101796
exe_file = fget(fd);
18111797
if (!exe_file)
18121798
return -EBADF;
@@ -1827,17 +1813,30 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
18271813
if (err)
18281814
goto exit;
18291815

1816+
down_write(&mm->mmap_sem);
1817+
1818+
/*
1819+
* Forbid mm->exe_file change if there are mapped other files.
1820+
*/
1821+
err = -EBUSY;
1822+
for (vma = mm->mmap; vma; vma = vma->vm_next) {
1823+
if (vma->vm_file && !path_equal(&vma->vm_file->f_path,
1824+
&exe_file->f_path))
1825+
goto exit_unlock;
1826+
}
1827+
18301828
/*
18311829
* The symlink can be changed only once, just to disallow arbitrary
18321830
* transitions malicious software might bring in. This means one
18331831
* could make a snapshot over all processes running and monitor
18341832
* /proc/pid/exe changes to notice unusual activity if needed.
18351833
*/
1836-
down_write(&mm->mmap_sem);
1837-
if (likely(!mm->exe_file))
1838-
set_mm_exe_file(mm, exe_file);
1839-
else
1840-
err = -EBUSY;
1834+
err = -EPERM;
1835+
if (test_and_set_bit(MMF_EXE_FILE_CHANGED, &mm->flags))
1836+
goto exit_unlock;
1837+
1838+
set_mm_exe_file(mm, exe_file);
1839+
exit_unlock:
18411840
up_write(&mm->mmap_sem);
18421841

18431842
exit:
@@ -1862,7 +1861,7 @@ static int prctl_set_mm(int opt, unsigned long addr,
18621861
if (opt == PR_SET_MM_EXE_FILE)
18631862
return prctl_set_mm_exe_file(mm, (unsigned int)addr);
18641863

1865-
if (addr >= TASK_SIZE)
1864+
if (addr >= TASK_SIZE || addr < mmap_min_addr)
18661865
return -EINVAL;
18671866

18681867
error = -EINVAL;
@@ -1924,12 +1923,6 @@ static int prctl_set_mm(int opt, unsigned long addr,
19241923
error = -EFAULT;
19251924
goto out;
19261925
}
1927-
#ifdef CONFIG_STACK_GROWSUP
1928-
if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSUP, 0))
1929-
#else
1930-
if (vma_flags_mismatch(vma, VM_READ | VM_WRITE | VM_GROWSDOWN, 0))
1931-
#endif
1932-
goto out;
19331926
if (opt == PR_SET_MM_START_STACK)
19341927
mm->start_stack = addr;
19351928
else if (opt == PR_SET_MM_ARG_START)
@@ -1981,12 +1974,22 @@ static int prctl_set_mm(int opt, unsigned long addr,
19811974
up_read(&mm->mmap_sem);
19821975
return error;
19831976
}
1977+
1978+
static int prctl_get_tid_address(struct task_struct *me, int __user **tid_addr)
1979+
{
1980+
return put_user(me->clear_child_tid, tid_addr);
1981+
}
1982+
19841983
#else /* CONFIG_CHECKPOINT_RESTORE */
19851984
static int prctl_set_mm(int opt, unsigned long addr,
19861985
unsigned long arg4, unsigned long arg5)
19871986
{
19881987
return -EINVAL;
19891988
}
1989+
static int prctl_get_tid_address(struct task_struct *me, int __user **tid_addr)
1990+
{
1991+
return -EINVAL;
1992+
}
19901993
#endif
19911994

19921995
SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
@@ -2124,6 +2127,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
21242127
else
21252128
return -EINVAL;
21262129
break;
2130+
case PR_GET_TID_ADDRESS:
2131+
error = prctl_get_tid_address(me, (int __user **)arg2);
2132+
break;
21272133
default:
21282134
return -EINVAL;
21292135
}

lib/btree.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ void *btree_get_prev(struct btree_head *head, struct btree_geo *geo,
319319

320320
if (head->height == 0)
321321
return NULL;
322-
retry:
323322
longcpy(key, __key, geo->keylen);
323+
retry:
324324
dec_key(geo, key);
325325

326326
node = head->node;
@@ -351,7 +351,7 @@ void *btree_get_prev(struct btree_head *head, struct btree_geo *geo,
351351
}
352352
miss:
353353
if (retry_key) {
354-
__key = retry_key;
354+
longcpy(key, retry_key, geo->keylen);
355355
retry_key = NULL;
356356
goto retry;
357357
}
@@ -509,6 +509,7 @@ static int btree_insert_level(struct btree_head *head, struct btree_geo *geo,
509509
int btree_insert(struct btree_head *head, struct btree_geo *geo,
510510
unsigned long *key, void *val, gfp_t gfp)
511511
{
512+
BUG_ON(!val);
512513
return btree_insert_level(head, geo, key, val, 1, gfp);
513514
}
514515
EXPORT_SYMBOL_GPL(btree_insert);

0 commit comments

Comments
 (0)