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, Michael Ellerman <mpe@ellerman.id.au>
Subject: [PATCH 3.18 19/60] powerpc/64: Fix atomic64_inc_not_zero() to return an int
Date: Tue, 25 Jul 2017 12:16:10 -0700	[thread overview]
Message-ID: <20170725191616.885409128@linuxfoundation.org> (raw)
In-Reply-To: <20170725191614.043749784@linuxfoundation.org>

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

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

From: Michael Ellerman <mpe@ellerman.id.au>

commit 01e6a61aceb82e13bec29502a8eb70d9574f97ad upstream.

Although it's not documented anywhere, there is an expectation that
atomic64_inc_not_zero() returns a result which fits in an int. This is
the behaviour implemented on all arches except powerpc.

This has caused at least one bug in practice, in the percpu-refcount
code, where the long result from our atomic64_inc_not_zero() was
truncated to an int leading to lost references and stuck systems. That
was worked around in that code in commit 966d2b04e070 ("percpu-refcount:
fix reference leak during percpu-atomic transition").

To the best of my grepping abilities there are no other callers
in-tree which truncate the value, but we should fix it anyway. Because
the breakage is subtle and potentially very harmful I'm also tagging
it for stable.

Code generation is largely unaffected because in most cases the
callers are just using the result for a test anyway. In particular the
case of fget() that was mentioned in commit a6cf7ed5119f
("powerpc/atomic: Implement atomic*_inc_not_zero") generates exactly
the same code.

Fixes: a6cf7ed5119f ("powerpc/atomic: Implement atomic*_inc_not_zero")
Noticed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/include/asm/atomic.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -453,7 +453,7 @@ static __inline__ int atomic64_add_unles
  * Atomically increments @v by 1, so long as @v is non-zero.
  * Returns non-zero if @v was non-zero, and zero otherwise.
  */
-static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
+static __inline__ int atomic64_inc_not_zero(atomic64_t *v)
 {
 	long t1, t2;
 
@@ -472,7 +472,7 @@ static __inline__ long atomic64_inc_not_
 	: "r" (&v->counter)
 	: "cc", "xer", "memory");
 
-	return t1;
+	return t1 != 0;
 }
 
 #endif /* __powerpc64__ */

  parent reply	other threads:[~2017-07-25 19:17 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 19:15 [PATCH 3.18 00/60] 3.18.63-stable review Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 01/60] disable new gcc-7.1.1 warnings for now Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 03/60] x86/rtc: Remove duplicate const specifier Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 04/60] [media] ir-core: fix gcc-7 warning on bool arithmetic Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 05/60] CIFS: Fix handle_cancelled_mid callback initialization Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 06/60] ath9k: fix tx99 use after free Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 07/60] ath9k: fix tx99 bus error Greg Kroah-Hartman
2017-07-25 19:15 ` [PATCH 3.18 08/60] NFC: fix broken device allocation Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 09/60] nfc: Ensure presence of required attributes in the activate_target handler Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 10/60] nfc: Fix the sockaddr length sanitization in llcp_sock_connect Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 11/60] include/stddef.h: Move offsetofend() from vfio.h to a generic kernel header Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 12/60] stddef.h: move offsetofend inside #ifndef/#endif guard, neaten Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 13/60] NFC: Add sockaddr length checks before accessing sa_family in bind handlers Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 14/60] Bluetooth: use constant time memory comparison for secret values Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 15/60] ASoC: compress: Derive substream from stream based on direction Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 16/60] PM / Domains: Fix unsafe iteration over modified list of device links Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 17/60] PM / Domains: Fix unsafe iteration over modified list of domain providers Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 18/60] scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails Greg Kroah-Hartman
2017-07-25 19:16 ` Greg Kroah-Hartman [this message]
2017-07-25 19:16 ` [PATCH 3.18 20/60] powerpc: Fix emulation of mcrf in emulate_step() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 21/60] powerpc: Fix emulation of mfocrf " Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 22/60] powerpc/asm: Mark cr0 as clobbered in mftb() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 23/60] af_key: Fix sadb_x_ipsecrequest parsing Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 24/60] PCI/PM: Restore the status of PCI devices across hibernation Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 25/60] xhci: fix 20000ms port resume timeout Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 26/60] xhci: Fix NULL pointer dereference when cleaning up streams for removed host Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 27/60] usb: storage: return on error to avoid a null pointer dereference Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 28/60] USB: cdc-acm: add device-id for quirky printer Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 29/60] usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 30/60] md: dont use flush_signals in userspace processes Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 31/60] Raid5 should update rdev->sectors after reshape Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 32/60] s390/syscalls: Fix out of bounds arguments access Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 34/60] f2fs: Dont clear SGID when inheriting ACLs Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 35/60] vfio: Fix group release deadlock Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 36/60] vfio: New external user group/file match Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 37/60] MIPS: Fix mips_atomic_set() retry condition Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 38/60] MIPS: Fix mips_atomic_set() with EVA Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 39/60] MIPS: Negate error syscall return in trace Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 40/60] x86/acpi: Prevent out of bound access caused by broken ACPI tables Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 41/60] MIPS: Save static registers before sysmips Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 42/60] MIPS: Actually decode JALX in `__compute_return_epc_for_insn Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 43/60] MIPS: Fix unaligned PC interpretation in `compute_return_epc Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 44/60] MIPS: math-emu: Prevent wrong ISA mode instruction emulation Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 45/60] Input: i8042 - fix crash at boot time Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 46/60] NFS: only invalidate dentrys that are clearly invalid Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 47/60] udf: Fix deadlock between writeback and udf_setsize() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 48/60] target: Fix COMPARE_AND_WRITE caw_sem leak during se_cmd quiesce Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 50/60] Revert "perf/core: Drop kernel samples even though :u is specified" Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 51/60] staging: rtl8188eu: add TL-WN722N v2 support Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 52/60] drm/mst: Fix error handling during MST sideband message reception Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 53/60] drm/mst: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req() Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 54/60] drm/mst: Avoid processing partially received up/down message transactions Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 55/60] KVM: PPC: Book3S HV: Context-switch EBB registers properly Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 56/60] of: device: Export of_device_{get_modalias, uvent_modalias} to modules Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 57/60] spmi: Include OF based modalias in device uevent Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 58/60] tracing: Fix kmemleak in instance_rmdir Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 59/60] alarmtimer: dont rate limit one-shot timers Greg Kroah-Hartman
2017-07-25 19:16 ` [PATCH 3.18 60/60] MIPS: Send SIGILL for BPOSGE32 in `__compute_return_epc_for_insn Greg Kroah-Hartman
2017-07-26  3:10 ` [PATCH 3.18 00/60] 3.18.63-stable review Guenter Roeck
2017-07-26 14:23 ` Shuah Khan

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=20170725191616.885409128@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=stable@vger.kernel.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).