Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
868d550
Fix build error if enable xfs or btfs
hardkernel Jan 10, 2013
a8695e1
bonding: Bonding driver does not consider the gso_max_size/gso_max_se…
Nov 21, 2012
cefbc05
bonding: fix race condition in bonding_store_slaves_active
Nov 29, 2012
e620776
sctp: fix memory leak in sctp_datamsg_from_user() when copy from user…
rantala Nov 27, 2012
55fdb80
sctp: fix -ENOMEM result with invalid user space pointer in sendto() …
rantala Nov 22, 2012
80fef29
ne2000: add the right platform device
Nov 20, 2012
98ffdcd
irda: sir_dev: Fix copy/paste typo
shcgit Nov 20, 2012
8d759d1
usb/ipheth: Add iPhone 5 support
Oct 14, 2012
947d716
pnpacpi: fix incorrect TEST_ALPHA() test
Alan-Cox Dec 7, 2012
28278b3
exec: do not leave bprm->interp on stack
kees Dec 20, 2012
276c234
x86, 8042: Enable A20 using KBC to fix S3 resume on some MSI laptops
Dec 11, 2012
812e638
virtio: force vring descriptors to be allocated from lowmem
wildea01 Oct 19, 2012
8fafe01
mm: Fix PageHead when !CONFIG_PAGEFLAGS_EXTENDED
chazy Dec 21, 2012
51afc62
tmpfs mempolicy: fix /proc/mounts corrupting memory
Jan 2, 2013
5a6400c
ALSA: usb-audio: Avoid autopm calls after disconnection
tiwai Dec 3, 2012
6ab1dea
ALSA: usb-audio: Fix missing autopm for MIDI input
tiwai Dec 3, 2012
45a62af
p54usb: add USB ID for T-Com Sinus 154 data II
Dec 22, 2012
1db444f
p54usb: add USBIDs for two more p54usb devices
chunkeey Dec 27, 2012
42fac8e
usb: gadget: phonet: free requests in pn_bind()'s error path
Oct 22, 2012
611d6f0
ACPI / scan: Do not use dummy HID for system bus ACPI nodes
rafaeljw Jan 4, 2013
64b45c8
NFS: avoid NULL dereference in nfs_destroy_server
neilbrown Dec 13, 2012
9d53441
NFS: Fix calls to drop_nlink()
Dec 14, 2012
d6e0c42
nfsd4: fix oops on unusual readlike compound
Dec 4, 2012
31c4e8c
nfs: fix null checking in nfs_get_option_str()
xiw Jan 4, 2013
ada84ad
Input: walkera0701 - fix crash on startup
Dec 15, 2012
d038911
genirq: Always force thread affinity
KAGA-KOKO Nov 3, 2012
5729b13
xhci: Add Lynx Point LP to list of Intel switchable hosts
Nov 9, 2012
01fdcf4
cgroup: remove incorrect dget/dput() pair in cgroup_create_dir()
htejun Nov 19, 2012
6c94f43
x86, amd: Disable way access filter on Piledriver CPUs
aprzywar Oct 31, 2012
6fe7238
ftrace: Do not function trace inlined functions
Dec 12, 2011
1e8928a
sparc: huge_ptep_set_* functions need to call set_huge_pte_at()
kleikamp Dec 17, 2012
9b79271
net: sched: integer overflow fix
matiniero Dec 21, 2012
86791bb
tcp: implement RFC 5961 3.2
edumazet Jul 17, 2012
ab5c718
tcp: implement RFC 5961 4.2
edumazet Jul 17, 2012
282190e
tcp: refine SYN handling in tcp_validate_incoming
edumazet Jul 17, 2012
ffd34fc
tcp: tcp_replace_ts_recent() should not be called from tcp_validate_i…
edumazet Nov 13, 2012
8d15569
tcp: RFC 5961 5.2 Blind Data Injection Attack Mitigation
edumazet Oct 21, 2012
f61019b
ARM: mm: use pteval_t to represent page protection values
wildea01 Sep 18, 2012
0b6916a
ARM: missing ->mmap_sem around find_vma() in swp_emulate.c
Dec 16, 2012
decbd08
solos-pci: fix double-free of TX skb in DMA mode
dwmw2 Dec 11, 2012
e641306
PCI: Reduce Ricoh 0xe822 SD card reader base clock frequency to 50MHz
amluto Dec 1, 2012
1bc2621
Bluetooth: ath3k: Add support for VAIO VPCEH [0489:e027]
mrkindustries Nov 6, 2012
9b7b38a
Bluetooth: cancel power_on work when unregistering the device
Nov 21, 2012
4a16c40
CRIS: fix I/O macros
cminyard Dec 18, 2012
afc0e69
drivers/rtc/rtc-vt8500.c: correct handling of CR_24H bitfield
tonyprisk Jan 4, 2013
a2e1113
drivers/rtc/rtc-vt8500.c: fix handling of data passed in struct rtc_time
tonyprisk Jan 4, 2013
c39096f
mm: limit mmu_gather batching to fix soft lockups on !CONFIG_PREEMPT
Jan 4, 2013
a0ed2e7
can: Do not call dev_put if restart timer is running upon close
Nov 27, 2012
2a68fec
Linux 3.0.58
gregkh Jan 11, 2013
08c96fe
Merge branch 'odroid-3.0.y' of git://github.com/hardkernel/linux into…
zehome Jan 12, 2013
c59e25f
Merge branch 'linux-3.0.58' into odroid-ed-3.0.y
zehome Jan 12, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tmpfs mempolicy: fix /proc/mounts corrupting memory
commit f2a07f4 upstream.

Recently I suggested using "mount -o remount,mpol=local /tmp" in NUMA
mempolicy testing.  Very nasty.  Reading /proc/mounts, /proc/pid/mounts
or /proc/pid/mountinfo may then corrupt one bit of kernel memory, often
in a page table (causing "Bad swap" or "Bad page map" warning or "Bad
pagetable" oops), sometimes in a vm_area_struct or rbnode or somewhere
worse.  "mpol=prefer" and "mpol=prefer:Node" are equally toxic.

Recent NUMA enhancements are not to blame: this dates back to 2.6.35,
when commit e17f74a "mempolicy: don't call mpol_set_nodemask() when
no_context" skipped mpol_parse_str()'s call to mpol_set_nodemask(),
which used to initialize v.preferred_node, or set MPOL_F_LOCAL in flags.
With slab poisoning, you can then rely on mpol_to_str() to set the bit
for node 0x6b6b, probably in the next page above the caller's stack.

mpol_parse_str() is only called from shmem_parse_options(): no_context
is always true, so call it unused for now, and remove !no_context code.
Set v.nodes or v.preferred_node or MPOL_F_LOCAL as mpol_to_str() might
expect.  Then mpol_to_str() can ignore its no_context argument also,
the mpol being appropriately initialized whether contextualized or not.
Rename its no_context unused too, and let subsequent patch remove them
(that's not needed for stable backporting, which would involve rejects).

I don't understand why MPOL_LOCAL is described as a pseudo-policy:
it's a reasonable policy which suffers from a confusing implementation
in terms of MPOL_PREFERRED with MPOL_F_LOCAL.  I believe this would be
much more robust if MPOL_LOCAL were recognized in switch statements
throughout, MPOL_F_LOCAL deleted, and MPOL_PREFERRED use the (possibly
empty) nodes mask like everyone else, instead of its preferred_node
variant (I presume an optimization from the days before MPOL_LOCAL).
But that would take me too long to get right and fully tested.

Signed-off-by: Hugh Dickins <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Hugh Dickins authored and gregkh committed Jan 11, 2013
commit 51afc625ccd2e38f76f690ccce93e11a21d9543b
64 changes: 26 additions & 38 deletions mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2308,8 +2308,7 @@ void numa_default_policy(void)
*/

/*
* "local" is pseudo-policy: MPOL_PREFERRED with MPOL_F_LOCAL flag
* Used only for mpol_parse_str() and mpol_to_str()
* "local" is implemented internally by MPOL_PREFERRED with MPOL_F_LOCAL flag.
*/
#define MPOL_LOCAL MPOL_MAX
static const char * const policy_modes[] =
Expand All @@ -2324,28 +2323,21 @@ static const char * const policy_modes[] =

#ifdef CONFIG_TMPFS
/**
* mpol_parse_str - parse string to mempolicy
* mpol_parse_str - parse string to mempolicy, for tmpfs mpol mount option.
* @str: string containing mempolicy to parse
* @mpol: pointer to struct mempolicy pointer, returned on success.
* @no_context: flag whether to "contextualize" the mempolicy
* @unused: redundant argument, to be removed later.
*
* Format of input:
* <mode>[=<flags>][:<nodelist>]
*
* if @no_context is true, save the input nodemask in w.user_nodemask in
* the returned mempolicy. This will be used to "clone" the mempolicy in
* a specific context [cpuset] at a later time. Used to parse tmpfs mpol
* mount option. Note that if 'static' or 'relative' mode flags were
* specified, the input nodemask will already have been saved. Saving
* it again is redundant, but safe.
*
* On success, returns 0, else 1
*/
int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
int mpol_parse_str(char *str, struct mempolicy **mpol, int unused)
{
struct mempolicy *new = NULL;
unsigned short mode;
unsigned short uninitialized_var(mode_flags);
unsigned short mode_flags;
nodemask_t nodes;
char *nodelist = strchr(str, ':');
char *flags = strchr(str, '=');
Expand Down Expand Up @@ -2433,24 +2425,23 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
if (IS_ERR(new))
goto out;

if (no_context) {
/* save for contextualization */
new->w.user_nodemask = nodes;
} else {
int ret;
NODEMASK_SCRATCH(scratch);
if (scratch) {
task_lock(current);
ret = mpol_set_nodemask(new, &nodes, scratch);
task_unlock(current);
} else
ret = -ENOMEM;
NODEMASK_SCRATCH_FREE(scratch);
if (ret) {
mpol_put(new);
goto out;
}
}
/*
* Save nodes for mpol_to_str() to show the tmpfs mount options
* for /proc/mounts, /proc/pid/mounts and /proc/pid/mountinfo.
*/
if (mode != MPOL_PREFERRED)
new->v.nodes = nodes;
else if (nodelist)
new->v.preferred_node = first_node(nodes);
else
new->flags |= MPOL_F_LOCAL;

/*
* Save nodes for contextualization: this will be used to "clone"
* the mempolicy in a specific context [cpuset] at a later time.
*/
new->w.user_nodemask = nodes;

err = 0;

out:
Expand All @@ -2470,13 +2461,13 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
* @buffer: to contain formatted mempolicy string
* @maxlen: length of @buffer
* @pol: pointer to mempolicy to be formatted
* @no_context: "context free" mempolicy - use nodemask in w.user_nodemask
* @unused: redundant argument, to be removed later.
*
* Convert a mempolicy into a string.
* Returns the number of characters in buffer (if positive)
* or an error (negative)
*/
int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int unused)
{
char *p = buffer;
int l;
Expand All @@ -2502,18 +2493,15 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
case MPOL_PREFERRED:
nodes_clear(nodes);
if (flags & MPOL_F_LOCAL)
mode = MPOL_LOCAL; /* pseudo-policy */
mode = MPOL_LOCAL;
else
node_set(pol->v.preferred_node, nodes);
break;

case MPOL_BIND:
/* Fall through */
case MPOL_INTERLEAVE:
if (no_context)
nodes = pol->w.user_nodemask;
else
nodes = pol->v.nodes;
nodes = pol->v.nodes;
break;

default:
Expand Down