stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Ralph Campbell <rcampbell@nvidia.com>,
	Alexander Duyck <alexander.duyck@gmail.com>,
	Waiman Long <longman@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.9 04/63] numa: change get_mempolicy() to use nr_node_ids instead of MAX_NUMNODES
Date: Mon, 25 Feb 2019 22:11:04 +0100	[thread overview]
Message-ID: <20190225195036.048077356@linuxfoundation.org> (raw)
In-Reply-To: <20190225195035.713274200@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ralph Campbell <rcampbell@nvidia.com>

commit 050c17f239fd53adb55aa768d4f41bc76c0fe045 upstream.

The system call, get_mempolicy() [1], passes an unsigned long *nodemask
pointer and an unsigned long maxnode argument which specifies the length
of the user's nodemask array in bits (which is rounded up).  The manual
page says that if the maxnode value is too small, get_mempolicy will
return EINVAL but there is no system call to return this minimum value.
To determine this value, some programs search /proc/<pid>/status for a
line starting with "Mems_allowed:" and use the number of digits in the
mask to determine the minimum value.  A recent change to the way this line
is formatted [2] causes these programs to compute a value less than
MAX_NUMNODES so get_mempolicy() returns EINVAL.

Change get_mempolicy(), the older compat version of get_mempolicy(), and
the copy_nodes_to_user() function to use nr_node_ids instead of
MAX_NUMNODES, thus preserving the defacto method of computing the minimum
size for the nodemask array and the maxnode argument.

[1] http://man7.org/linux/man-pages/man2/get_mempolicy.2.html
[2] https://lore.kernel.org/lkml/1545405631-6808-1-git-send-email-longman@redhat.com

Link: http://lkml.kernel.org/r/20190211180245.22295-1-rcampbell@nvidia.com
Fixes: 4fb8e5b89bcbbbb ("include/linux/nodemask.h: use nr_node_ids (not MAX_NUMNODES) in __nodemask_pr_numnodes()")
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Waiman Long <longman@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/mempolicy.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1327,7 +1327,7 @@ static int copy_nodes_to_user(unsigned l
 			      nodemask_t *nodes)
 {
 	unsigned long copy = ALIGN(maxnode-1, 64) / 8;
-	const int nbytes = BITS_TO_LONGS(MAX_NUMNODES) * sizeof(long);
+	unsigned int nbytes = BITS_TO_LONGS(nr_node_ids) * sizeof(long);
 
 	if (copy > nbytes) {
 		if (copy > PAGE_SIZE)
@@ -1488,7 +1488,7 @@ SYSCALL_DEFINE5(get_mempolicy, int __use
 	int uninitialized_var(pval);
 	nodemask_t nodes;
 
-	if (nmask != NULL && maxnode < MAX_NUMNODES)
+	if (nmask != NULL && maxnode < nr_node_ids)
 		return -EINVAL;
 
 	err = do_get_mempolicy(&pval, &nodes, addr, flags);
@@ -1517,7 +1517,7 @@ COMPAT_SYSCALL_DEFINE5(get_mempolicy, in
 	unsigned long nr_bits, alloc_size;
 	DECLARE_BITMAP(bm, MAX_NUMNODES);
 
-	nr_bits = min_t(unsigned long, maxnode-1, MAX_NUMNODES);
+	nr_bits = min_t(unsigned long, maxnode-1, nr_node_ids);
 	alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
 
 	if (nmask)



  parent reply	other threads:[~2019-02-25 22:05 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 21:11 [PATCH 4.9 00/63] 4.9.161-stable review Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 01/63] mac80211: Free mpath object when rhashtable insertion fails Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 02/63] libceph: handle an empty authorize reply Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 03/63] ceph: avoid repeatedly adding inode to mdsc->snap_flush_list Greg Kroah-Hartman
2019-02-25 21:11 ` Greg Kroah-Hartman [this message]
2019-02-25 21:11 ` [PATCH 4.9 05/63] proc, oom: do not report alien mms when setting oom_score_adj Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 06/63] KEYS: allow reaching the keys quotas exactly Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 07/63] mfd: ti_am335x_tscadc: Use PLATFORM_DEVID_AUTO while registering mfd cells Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 08/63] mfd: twl-core: Fix section annotations on {,un}protect_pm_master Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 09/63] mfd: db8500-prcmu: Fix some section annotations Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 10/63] mfd: mt6397: Do not call irq_domain_remove if PMIC unsupported Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 11/63] mfd: ab8500-core: Return zero in get_register_interruptible() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 12/63] mfd: qcom_rpm: write fw_version to CTRL_REG Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 13/63] mfd: wm5110: Add missing ASRC rate register Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 14/63] mfd: mc13xxx: Fix a missing check of a register-read failure Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 15/63] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 16/63] net: hns: Fix use after free identified by SLUB debug Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 17/63] MIPS: ath79: Enable OF serial ports in the default config Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 18/63] scsi: qla4xxx: check return code of qla4xxx_copy_from_fwddb_param Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 19/63] scsi: isci: initialize shost fully before calling scsi_add_host() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 20/63] MIPS: jazz: fix 64bit build Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 21/63] net: stmmac: Fix PCI module removal leak Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 22/63] isdn: i4l: isdn_tty: Fix some concurrency double-free bugs Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 23/63] atm: he: fix sign-extension overflow on large shift Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 24/63] leds: lp5523: fix a missing check of return value of lp55xx_read Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 25/63] mlxsw: spectrum_switchdev: Do not treat static FDB entries as sticky Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 26/63] net/mlx5e: Fix wrong (zero) TX drop counter indication for representor Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 27/63] isdn: avm: Fix string plus integer warning from Clang Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 28/63] net: ethernet: stmmac: change dma descriptors to __le32 Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 29/63] RDMA/srp: Rework SCSI device reset handling Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 30/63] KEYS: user: Align the payload buffer Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 31/63] KEYS: always initialize keyring_index_key::desc_len Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 32/63] batman-adv: fix uninit-value in batadv_interface_tx() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 33/63] net/packet: fix 4gb buffer limit due to overflow check Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 34/63] team: avoid complex list operations in team_nl_cmd_options_set() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 35/63] sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 36/63] sctp: call gso_reset_checksum when computing checksum in sctp_gso_segment Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 37/63] net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 38/63] parisc: Fix ptrace syscall number modification Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 39/63] ARCv2: Enable unaligned access in early ASM code Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 40/63] ARC: U-boot: check arguments paranoidly Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 41/63] ARC: define ARCH_SLAB_MINALIGN = 8 Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 42/63] hpet: Make cmd parameter of hpet_ioctl_common() unsigned Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 43/63] clocksource: Use GENMASK_ULL in definition of CLOCKSOURCE_MASK Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 44/63] netpoll: Fix device name check in netpoll_setup() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 45/63] tracing: Use cpumask_available() to check if cpumask variable may be used Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 46/63] x86/boot: Disable the address-of-packed-member compiler warning Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 47/63] drm/i915: Consistently use enum pipe for PCH transcoders Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 48/63] drm/i915: Fix enum pipe vs. enum transcoder for the PCH transcoder Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 49/63] kbuild: move cc-option and cc-disable-warning after incl. arch Makefile Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 50/63] kbuild: clang: fix build failures with sparse check Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 51/63] kbuild: clang: remove crufty HOSTCFLAGS Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 52/63] kbuild: clang: disable unused variable warnings only when constant Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 53/63] kbuild: set no-integrated-as before incl. arch Makefile Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 54/63] kbuild: add -no-integrated-as Clang option unconditionally Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 55/63] irqchip/gic-v3: Convert arm64 GIC accessors to {read,write}_sysreg_s Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 56/63] mm/zsmalloc.c: change stat type parameter to int Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 57/63] mm/zsmalloc.c: fix -Wunneeded-internal-declaration warning Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 58/63] Revert "bridge: do not add port to router list when receives query with source 0.0.0.0" Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.9 59/63] netfilter: nf_tables: fix flush after rule deletion in the same batch Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.9 60/63] pinctrl: max77620: Use define directive for max77620_pinconf_param values Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.9 61/63] phy: tegra: remove redundant self assignment of map Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.9 62/63] sched/sysctl: Fix attributes of some extern declarations Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.9 63/63] kbuild: consolidate Clang compiler flags Greg Kroah-Hartman
2019-02-26  8:33 ` [PATCH 4.9 00/63] 4.9.161-stable review Naresh Kamboju
2019-02-26 12:23 ` Jon Hunter
2019-02-26 15:06 ` shuah
2019-02-26 17:41 ` Guenter Roeck
2019-02-26 18:18   ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190225195036.048077356@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.duyck@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=rcampbell@nvidia.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).