Skip to content

Commit f1d6e17

Browse files
committed
Merge branch 'akpm' (patches from Andrew Morton)
Merge a bunch of fixes from Andrew Morton. * emailed patches from Andrew Morton <[email protected]>: fs/proc/task_mmu.c: fix buffer overflow in add_page_map() arch: *: Kconfig: add "kernel/Kconfig.freezer" to "arch/*/Kconfig" ocfs2: fix null pointer dereference in ocfs2_dir_foreach_blk_id() x86 get_unmapped_area(): use proper mmap base for bottom-up direction ocfs2: fix NULL pointer dereference in ocfs2_duplicate_clusters_by_page ocfs2: Revert 40bd62e to avoid regression in extended allocation drivers/rtc/rtc-stmp3xxx.c: provide timeout for potentially endless loop polling a HW bit hugetlb: fix lockdep splat caused by pmd sharing aoe: adjust ref of head for compound page tails microblaze: fix clone syscall mm: save soft-dirty bits on file pages mm: save soft-dirty bits on swapped pages memcg: don't initialize kmem-cache destroying work for root caches
2 parents 28fbc8b + 8c82962 commit f1d6e17

File tree

32 files changed

+282
-105
lines changed

32 files changed

+282
-105
lines changed

arch/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ config CLONE_BACKWARDS2
407407
help
408408
Architecture has the first two arguments of clone(2) swapped.
409409

410+
config CLONE_BACKWARDS3
411+
bool
412+
help
413+
Architecture has tls passed as the 3rd argument of clone(2),
414+
not the 5th one.
415+
410416
config ODD_RT_SIGACTION
411417
bool
412418
help

arch/hexagon/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ source "kernel/Kconfig.hz"
158158
endmenu
159159

160160
source "init/Kconfig"
161+
source "kernel/Kconfig.freezer"
161162
source "drivers/Kconfig"
162163
source "fs/Kconfig"
163164

arch/microblaze/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ config MICROBLAZE
2828
select GENERIC_CLOCKEVENTS
2929
select GENERIC_IDLE_POLL_SETUP
3030
select MODULES_USE_ELF_RELA
31-
select CLONE_BACKWARDS
31+
select CLONE_BACKWARDS3
3232

3333
config SWAP
3434
def_bool n

arch/openrisc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ config GENERIC_CSUM
5555

5656
source "init/Kconfig"
5757

58+
source "kernel/Kconfig.freezer"
5859

5960
menu "Processor type and features"
6061

arch/score/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ config STACKTRACE_SUPPORT
8787

8888
source "init/Kconfig"
8989

90+
source "kernel/Kconfig.freezer"
91+
9092
config MMU
9193
def_bool y
9294

arch/x86/include/asm/pgtable-2level.h

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,53 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
5555
#define native_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp)
5656
#endif
5757

58+
#ifdef CONFIG_MEM_SOFT_DIRTY
59+
60+
/*
61+
* Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE, _PAGE_BIT_SOFT_DIRTY and
62+
* _PAGE_BIT_PROTNONE are taken, split up the 28 bits of offset
63+
* into this range.
64+
*/
65+
#define PTE_FILE_MAX_BITS 28
66+
#define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1)
67+
#define PTE_FILE_SHIFT2 (_PAGE_BIT_FILE + 1)
68+
#define PTE_FILE_SHIFT3 (_PAGE_BIT_PROTNONE + 1)
69+
#define PTE_FILE_SHIFT4 (_PAGE_BIT_SOFT_DIRTY + 1)
70+
#define PTE_FILE_BITS1 (PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1)
71+
#define PTE_FILE_BITS2 (PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1)
72+
#define PTE_FILE_BITS3 (PTE_FILE_SHIFT4 - PTE_FILE_SHIFT3 - 1)
73+
74+
#define pte_to_pgoff(pte) \
75+
((((pte).pte_low >> (PTE_FILE_SHIFT1)) \
76+
& ((1U << PTE_FILE_BITS1) - 1))) \
77+
+ ((((pte).pte_low >> (PTE_FILE_SHIFT2)) \
78+
& ((1U << PTE_FILE_BITS2) - 1)) \
79+
<< (PTE_FILE_BITS1)) \
80+
+ ((((pte).pte_low >> (PTE_FILE_SHIFT3)) \
81+
& ((1U << PTE_FILE_BITS3) - 1)) \
82+
<< (PTE_FILE_BITS1 + PTE_FILE_BITS2)) \
83+
+ ((((pte).pte_low >> (PTE_FILE_SHIFT4))) \
84+
<< (PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3))
85+
86+
#define pgoff_to_pte(off) \
87+
((pte_t) { .pte_low = \
88+
((((off)) & ((1U << PTE_FILE_BITS1) - 1)) << PTE_FILE_SHIFT1) \
89+
+ ((((off) >> PTE_FILE_BITS1) \
90+
& ((1U << PTE_FILE_BITS2) - 1)) \
91+
<< PTE_FILE_SHIFT2) \
92+
+ ((((off) >> (PTE_FILE_BITS1 + PTE_FILE_BITS2)) \
93+
& ((1U << PTE_FILE_BITS3) - 1)) \
94+
<< PTE_FILE_SHIFT3) \
95+
+ ((((off) >> \
96+
(PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3))) \
97+
<< PTE_FILE_SHIFT4) \
98+
+ _PAGE_FILE })
99+
100+
#else /* CONFIG_MEM_SOFT_DIRTY */
101+
58102
/*
59103
* Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken,
60-
* split up the 29 bits of offset into this range:
104+
* split up the 29 bits of offset into this range.
61105
*/
62106
#define PTE_FILE_MAX_BITS 29
63107
#define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1)
@@ -88,6 +132,8 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
88132
<< PTE_FILE_SHIFT3) \
89133
+ _PAGE_FILE })
90134

135+
#endif /* CONFIG_MEM_SOFT_DIRTY */
136+
91137
/* Encode and de-code a swap entry */
92138
#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
93139
#define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)

arch/x86/include/asm/pgtable-3level.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp)
179179
/*
180180
* Bits 0, 6 and 7 are taken in the low part of the pte,
181181
* put the 32 bits of offset into the high part.
182+
*
183+
* For soft-dirty tracking 11 bit is taken from
184+
* the low part of pte as well.
182185
*/
183186
#define pte_to_pgoff(pte) ((pte).pte_high)
184187
#define pgoff_to_pte(off) \

arch/x86/include/asm/pgtable.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,36 @@ static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
314314
return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
315315
}
316316

317+
static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
318+
{
319+
return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
320+
}
321+
322+
static inline int pte_swp_soft_dirty(pte_t pte)
323+
{
324+
return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
325+
}
326+
327+
static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
328+
{
329+
return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
330+
}
331+
332+
static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
333+
{
334+
return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
335+
}
336+
337+
static inline pte_t pte_file_mksoft_dirty(pte_t pte)
338+
{
339+
return pte_set_flags(pte, _PAGE_SOFT_DIRTY);
340+
}
341+
342+
static inline int pte_file_soft_dirty(pte_t pte)
343+
{
344+
return pte_flags(pte) & _PAGE_SOFT_DIRTY;
345+
}
346+
317347
/*
318348
* Mask out unsupported bits in a present pgprot. Non-present pgprots
319349
* can use those bits for other purposes, so leave them be.

arch/x86/include/asm/pgtable_types.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,27 @@
6161
* they do not conflict with each other.
6262
*/
6363

64+
#define _PAGE_BIT_SOFT_DIRTY _PAGE_BIT_HIDDEN
65+
6466
#ifdef CONFIG_MEM_SOFT_DIRTY
65-
#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
67+
#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_SOFT_DIRTY)
6668
#else
6769
#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 0))
6870
#endif
6971

72+
/*
73+
* Tracking soft dirty bit when a page goes to a swap is tricky.
74+
* We need a bit which can be stored in pte _and_ not conflict
75+
* with swap entry format. On x86 bits 6 and 7 are *not* involved
76+
* into swap entry computation, but bit 6 is used for nonlinear
77+
* file mapping, so we borrow bit 7 for soft dirty tracking.
78+
*/
79+
#ifdef CONFIG_MEM_SOFT_DIRTY
80+
#define _PAGE_SWP_SOFT_DIRTY _PAGE_PSE
81+
#else
82+
#define _PAGE_SWP_SOFT_DIRTY (_AT(pteval_t, 0))
83+
#endif
84+
7085
#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
7186
#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
7287
#else

arch/x86/kernel/sys_x86_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
101101
*begin = new_begin;
102102
}
103103
} else {
104-
*begin = TASK_UNMAPPED_BASE;
104+
*begin = mmap_legacy_base();
105105
*end = TASK_SIZE;
106106
}
107107
}

arch/x86/mm/mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static unsigned long mmap_base(void)
9898
* Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
9999
* does, but not when emulating X86_32
100100
*/
101-
static unsigned long mmap_legacy_base(void)
101+
unsigned long mmap_legacy_base(void)
102102
{
103103
if (mmap_is_ia32())
104104
return TASK_UNMAPPED_BASE;

drivers/block/aoe/aoecmd.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -906,16 +906,10 @@ bio_pageinc(struct bio *bio)
906906
int i;
907907

908908
bio_for_each_segment(bv, bio, i) {
909-
page = bv->bv_page;
910909
/* Non-zero page count for non-head members of
911-
* compound pages is no longer allowed by the kernel,
912-
* but this has never been seen here.
910+
* compound pages is no longer allowed by the kernel.
913911
*/
914-
if (unlikely(PageCompound(page)))
915-
if (compound_trans_head(page) != page) {
916-
pr_crit("page tail used for block I/O\n");
917-
BUG();
918-
}
912+
page = compound_trans_head(bv->bv_page);
919913
atomic_inc(&page->_count);
920914
}
921915
}
@@ -924,10 +918,13 @@ static void
924918
bio_pagedec(struct bio *bio)
925919
{
926920
struct bio_vec *bv;
921+
struct page *page;
927922
int i;
928923

929-
bio_for_each_segment(bv, bio, i)
930-
atomic_dec(&bv->bv_page->_count);
924+
bio_for_each_segment(bv, bio, i) {
925+
page = compound_trans_head(bv->bv_page);
926+
atomic_dec(&page->_count);
927+
}
931928
}
932929

933930
static void

drivers/rtc/rtc-stmp3xxx.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/init.h>
2424
#include <linux/platform_device.h>
2525
#include <linux/interrupt.h>
26+
#include <linux/delay.h>
2627
#include <linux/rtc.h>
2728
#include <linux/slab.h>
2829
#include <linux/of_device.h>
@@ -119,24 +120,39 @@ static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
119120
}
120121
#endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */
121122

122-
static void stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data)
123+
static int stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data)
123124
{
125+
int timeout = 5000; /* 3ms according to i.MX28 Ref Manual */
124126
/*
125-
* The datasheet doesn't say which way round the
126-
* NEW_REGS/STALE_REGS bitfields go. In fact it's 0x1=P0,
127-
* 0x2=P1, .., 0x20=P5, 0x40=ALARM, 0x80=SECONDS
127+
* The i.MX28 Applications Processor Reference Manual, Rev. 1, 2010
128+
* states:
129+
* | The order in which registers are updated is
130+
* | Persistent 0, 1, 2, 3, 4, 5, Alarm, Seconds.
131+
* | (This list is in bitfield order, from LSB to MSB, as they would
132+
* | appear in the STALE_REGS and NEW_REGS bitfields of the HW_RTC_STAT
133+
* | register. For example, the Seconds register corresponds to
134+
* | STALE_REGS or NEW_REGS containing 0x80.)
128135
*/
129-
while (readl(rtc_data->io + STMP3XXX_RTC_STAT) &
130-
(0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT))
131-
cpu_relax();
136+
do {
137+
if (!(readl(rtc_data->io + STMP3XXX_RTC_STAT) &
138+
(0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)))
139+
return 0;
140+
udelay(1);
141+
} while (--timeout > 0);
142+
return (readl(rtc_data->io + STMP3XXX_RTC_STAT) &
143+
(0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)) ? -ETIME : 0;
132144
}
133145

134146
/* Time read/write */
135147
static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
136148
{
149+
int ret;
137150
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
138151

139-
stmp3xxx_wait_time(rtc_data);
152+
ret = stmp3xxx_wait_time(rtc_data);
153+
if (ret)
154+
return ret;
155+
140156
rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
141157
return 0;
142158
}
@@ -146,8 +162,7 @@ static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t)
146162
struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
147163

148164
writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS);
149-
stmp3xxx_wait_time(rtc_data);
150-
return 0;
165+
return stmp3xxx_wait_time(rtc_data);
151166
}
152167

153168
/* interrupt(s) handler */

fs/hugetlbfs/inode.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,14 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
463463
return inode;
464464
}
465465

466+
/*
467+
* Hugetlbfs is not reclaimable; therefore its i_mmap_mutex will never
468+
* be taken from reclaim -- unlike regular filesystems. This needs an
469+
* annotation because huge_pmd_share() does an allocation under
470+
* i_mmap_mutex.
471+
*/
472+
struct lock_class_key hugetlbfs_i_mmap_mutex_key;
473+
466474
static struct inode *hugetlbfs_get_inode(struct super_block *sb,
467475
struct inode *dir,
468476
umode_t mode, dev_t dev)
@@ -474,6 +482,8 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
474482
struct hugetlbfs_inode_info *info;
475483
inode->i_ino = get_next_ino();
476484
inode_init_owner(inode, dir, mode);
485+
lockdep_set_class(&inode->i_mapping->i_mmap_mutex,
486+
&hugetlbfs_i_mmap_mutex_key);
477487
inode->i_mapping->a_ops = &hugetlbfs_aops;
478488
inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
479489
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;

fs/ocfs2/aops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ int ocfs2_write_begin_nolock(struct file *filp,
17571757
goto out;
17581758
} else if (ret == 1) {
17591759
clusters_need = wc->w_clen;
1760-
ret = ocfs2_refcount_cow(inode, filp, di_bh,
1760+
ret = ocfs2_refcount_cow(inode, di_bh,
17611761
wc->w_cpos, wc->w_clen, UINT_MAX);
17621762
if (ret) {
17631763
mlog_errno(ret);

fs/ocfs2/dir.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,11 +2153,9 @@ int ocfs2_empty_dir(struct inode *inode)
21532153
{
21542154
int ret;
21552155
struct ocfs2_empty_dir_priv priv = {
2156-
.ctx.actor = ocfs2_empty_dir_filldir
2156+
.ctx.actor = ocfs2_empty_dir_filldir,
21572157
};
21582158

2159-
memset(&priv, 0, sizeof(priv));
2160-
21612159
if (ocfs2_dir_indexed(inode)) {
21622160
ret = ocfs2_empty_dir_dx(inode, &priv);
21632161
if (ret)

fs/ocfs2/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
370370
if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
371371
goto out;
372372

373-
return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
373+
return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
374374

375375
out:
376376
return status;
@@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
899899
zero_clusters = last_cpos - zero_cpos;
900900

901901
if (needs_cow) {
902-
rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
902+
rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
903903
zero_clusters, UINT_MAX);
904904
if (rc) {
905905
mlog_errno(rc);
@@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
20782078

20792079
*meta_level = 1;
20802080

2081-
ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
2081+
ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
20822082
if (ret)
20832083
mlog_errno(ret);
20842084
out:

fs/ocfs2/journal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb,
537537
extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth);
538538

539539
return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks +
540-
ocfs2_quota_trans_credits(sb) + bits_wanted;
540+
ocfs2_quota_trans_credits(sb);
541541
}
542542

543543
static inline int ocfs2_calc_symlink_credits(struct super_block *sb)

fs/ocfs2/move_extents.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
6969
u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
7070
u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
7171

72-
ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
72+
ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
7373
p_cpos, new_p_cpos, len);
7474
if (ret) {
7575
mlog_errno(ret);

0 commit comments

Comments
 (0)