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, Jamie Iles <jamie.iles@oracle.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <alexander.levin@verizon.com>
Subject: [PATCH 4.9 89/93] signal: protect SIGNAL_UNKILLABLE from unintentional clearing.
Date: Wed,  9 Aug 2017 11:14:22 -0700	[thread overview]
Message-ID: <20170809181339.265557532@linuxfoundation.org> (raw)
In-Reply-To: <20170809181335.658857427@linuxfoundation.org>

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

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

From: Jamie Iles <jamie.iles@oracle.com>


[ Upstream commit 2d39b3cd34e6d323720d4c61bd714f5ae202c022 ]

Since commit 00cd5c37afd5 ("ptrace: permit ptracing of /sbin/init") we
can now trace init processes.  init is initially protected with
SIGNAL_UNKILLABLE which will prevent fatal signals such as SIGSTOP, but
there are a number of paths during tracing where SIGNAL_UNKILLABLE can
be implicitly cleared.

This can result in init becoming stoppable/killable after tracing.  For
example, running:

  while true; do kill -STOP 1; done &
  strace -p 1

and then stopping strace and the kill loop will result in init being
left in state TASK_STOPPED.  Sending SIGCONT to init will resume it, but
init will now respond to future SIGSTOP signals rather than ignoring
them.

Make sure that when setting SIGNAL_STOP_CONTINUED/SIGNAL_STOP_STOPPED
that we don't clear SIGNAL_UNKILLABLE.

Link: http://lkml.kernel.org/r/20170104122017.25047-1-jamie.iles@oracle.com
Signed-off-by: Jamie Iles <jamie.iles@oracle.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/sched.h |   10 ++++++++++
 kernel/signal.c       |    4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -830,6 +830,16 @@ struct signal_struct {
 
 #define SIGNAL_UNKILLABLE	0x00000040 /* for init: ignore fatal signals */
 
+#define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \
+			  SIGNAL_STOP_CONTINUED)
+
+static inline void signal_set_stop_flags(struct signal_struct *sig,
+					 unsigned int flags)
+{
+	WARN_ON(sig->flags & (SIGNAL_GROUP_EXIT|SIGNAL_GROUP_COREDUMP));
+	sig->flags = (sig->flags & ~SIGNAL_STOP_MASK) | flags;
+}
+
 /* If true, all threads except ->group_exit_task have pending SIGKILL */
 static inline int signal_group_exit(const struct signal_struct *sig)
 {
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -346,7 +346,7 @@ static bool task_participate_group_stop(
 	 * fresh group stop.  Read comment in do_signal_stop() for details.
 	 */
 	if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) {
-		sig->flags = SIGNAL_STOP_STOPPED;
+		signal_set_stop_flags(sig, SIGNAL_STOP_STOPPED);
 		return true;
 	}
 	return false;
@@ -845,7 +845,7 @@ static bool prepare_signal(int sig, stru
 			 * will take ->siglock, notice SIGNAL_CLD_MASK, and
 			 * notify its parent. See get_signal_to_deliver().
 			 */
-			signal->flags = why | SIGNAL_STOP_CONTINUED;
+			signal_set_stop_flags(signal, why | SIGNAL_STOP_CONTINUED);
 			signal->group_stop_count = 0;
 			signal->group_exit_code = 0;
 		}

  parent reply	other threads:[~2017-08-09 18:14 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 18:12 [PATCH 4.9 00/93] 4.9.42-stable review Greg Kroah-Hartman
2017-08-09 18:12 ` [PATCH 4.9 01/93] parisc: Handle vmas whose context is not current in flush_cache_range Greg Kroah-Hartman
2017-08-09 18:12 ` [PATCH 4.9 02/93] cgroup: create dfl_root files on subsys registration Greg Kroah-Hartman
2017-08-09 18:12 ` [PATCH 4.9 03/93] cgroup: fix error return value from cgroup_subtree_control() Greg Kroah-Hartman
2017-08-09 18:12 ` [PATCH 4.9 04/93] libata: array underflow in ata_find_dev() Greg Kroah-Hartman
2017-08-09 18:12 ` [PATCH 4.9 05/93] workqueue: restore WQ_UNBOUND/max_active==1 to be ordered Greg Kroah-Hartman
2017-08-09 18:12 ` [PATCH 4.9 06/93] iwlwifi: dvm: prevent an out of bounds access Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 07/93] brcmfmac: fix memleak due to calling brcmf_sdiod_sgtable_alloc() twice Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 08/93] NFSv4: Fix EXCHANGE_ID corrupt verifier issue Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 09/93] mmc: sdhci-of-at91: force card detect value for non removable devices Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 10/93] device property: Make dev_fwnode() public Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 11/93] mmc: core: Fix access to HS400-ES devices Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 12/93] mm, mprotect: flush TLB if potentially racing with a parallel reclaim leaving stale TLB entries Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 13/93] cpuset: fix a deadlock due to incomplete patching of cpusets_enabled() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 14/93] ALSA: hda - Fix speaker output from VAIO VPCL14M1R Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 16/93] ASoC: do not close shared backend dailink Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 18/93] mm/page_alloc: Remove kernel address exposure in free_reserved_area() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 19/93] timers: Fix overflow in get_next_timer_interrupt Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 20/93] powerpc/tm: Fix saving of TM SPRs in core dump Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 21/93] powerpc/64: Fix __check_irq_replay missing decrementer interrupt Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 22/93] iommu/amd: Enable ga_log_intr when enabling guest_mode Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 23/93] gpiolib: skip unwanted events, dont convert them to opposite edge Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 24/93] ext4: fix SEEK_HOLE/SEEK_DATA for blocksize < pagesize Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 25/93] ext4: fix overflow caused by missing cast in ext4_resize_fs() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 26/93] ARM: dts: armada-38x: Fix irq type for pca955 Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 27/93] ARM: dts: tango4: Request RGMII RX and TX clock delays Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 28/93] media: platform: davinci: return -EINVAL for VPFE_CMD_S_CCDC_RAW_PARAMS ioctl Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 29/93] iscsi-target: Fix initial login PDU asynchronous socket close OOPs Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 30/93] mmc: dw_mmc: Use device_property_read instead of of_property_read Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 31/93] mmc: core: " Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 32/93] media: lirc: LIRC_GET_REC_RESOLUTION should return microseconds Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 33/93] f2fs: sanity check checkpoint segno and blkoff Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 34/93] Btrfs: fix early ENOSPC due to delalloc Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 35/93] [media] saa7164: fix double fetch PCIe access condition Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 36/93] tcp_bbr: cut pacing rate only if filled pipe Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 37/93] tcp_bbr: introduce bbr_bw_to_pacing_rate() helper Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 38/93] tcp_bbr: introduce bbr_init_pacing_rate_from_rtt() helper Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 39/93] tcp_bbr: remove sk_pacing_rate=0 transient during init Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 40/93] tcp_bbr: init pacing rate on first RTT sample Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 41/93] ipv4: ipv6: initialize treq->txhash in cookie_v[46]_check() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 42/93] net: Zero terminate ifr_name in dev_ifname() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 43/93] ipv6: avoid overflow of offset in ip6_find_1stfragopt Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 44/93] net: dsa: b53: Add missing ARL entries for BCM53125 Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 45/93] ipv4: initialize fib_trie prior to register_netdev_notifier call Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 46/93] rtnetlink: allocate more memory for dev_set_mac_address() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 47/93] mcs7780: Fix initialization when CONFIG_VMAP_STACK is enabled Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 48/93] openvswitch: fix potential out of bound access in parse_ct Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 49/93] packet: fix use-after-free in prb_retire_rx_blk_timer_expired() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 50/93] ipv6: Dont increase IPSTATS_MIB_FRAGFAILS twice in ip6_fragment() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 51/93] net: ethernet: nb8800: Handle all 4 RGMII modes identically Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 52/93] dccp: fix a memleak that dccp_ipv6 doesnt put reqsk properly Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 53/93] dccp: fix a memleak that dccp_ipv4 " Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 54/93] dccp: fix a memleak for dccp_feat_init err process Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 55/93] sctp: dont dereference ptr before leaving _sctp_walk_{params, errors}() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 56/93] sctp: fix the check for _sctp_walk_params and _sctp_walk_errors Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 57/93] net/mlx5: Consider tx_enabled in all modes on remap Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 58/93] net/mlx5: Fix command bad flow on command entry allocation failure Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 59/93] net/mlx5e: Fix outer_header_zero() check size Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 60/93] net/mlx5e: Fix wrong delay calculation for overflow check scheduling Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 61/93] net/mlx5e: Schedule overflow check work to mlx5e workqueue Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 62/93] net: phy: Correctly process PHY_HALTED in phy_stop_machine() Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 63/93] xen-netback: correctly schedule rate-limited queues Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 64/93] sparc64: Measure receiver forward progress to avoid send mondo timeout Greg Kroah-Hartman
2017-08-09 18:13 ` [PATCH 4.9 65/93] sparc64: Prevent perf from running during super critical sections Greg Kroah-Hartman
2017-08-10 16:20   ` Greg Kroah-Hartman
2017-08-10 16:45     ` David Miller
2017-08-11  5:00     ` David Miller
2017-08-11 19:33       ` Greg KH
2017-08-09 18:13 ` [PATCH 4.9 66/93] sparc64: Fix exception handling in UltraSPARC-III memcpy Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 67/93] wext: handle NULL extra data in iwe_stream_add_point better Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 68/93] sh_eth: fix EESIPR values for SH77{34|63} Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 69/93] sh_eth: R8A7740 supports packet shecksumming Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 70/93] net: phy: dp83867: fix irq generation Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 71/93] tg3: Fix race condition in tg3_get_stats64() Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 72/93] x86/boot: Add missing declaration of string functions Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 73/93] spi: spi-axi: Free resources on error path Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 74/93] ASoC: rt5645: set sel_i2s_pre_div1 to 2 Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 75/93] netfilter: use fwmark_reflect in nf_send_reset Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 76/93] phy state machine: failsafe leave invalid RUNNING state Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 77/93] ipv4: make tcp_notsent_lowat sysctl knob behave as true unsigned int Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 78/93] clk/samsung: exynos542x: mark some clocks as critical Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 79/93] scsi: qla2xxx: Get mutex lock before checking optrom_state Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 80/93] drm/virtio: fix framebuffer sparse warning Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 81/93] ARM: dts: sun8i: Support DTB build for NanoPi M1 Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 82/93] ARM: dts: sunxi: Change node name for pwrseq pin on Olinuxino-lime2-emmc Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 83/93] iw_cxgb4: do not send RX_DATA_ACK CPLs after close/abort Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 84/93] nbd: blk_mq_init_queue returns an error code on failure, not NULL Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 85/93] virtio_blk: fix panic in initialization error path Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 86/93] ARM: 8632/1: ftrace: fix syscall name matching Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 87/93] mm, slab: make sure that KMALLOC_MAX_SIZE will fit into MAX_ORDER Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 88/93] lib/Kconfig.debug: fix frv build failure Greg Kroah-Hartman
2017-08-09 18:14 ` Greg Kroah-Hartman [this message]
2017-08-09 18:14 ` [PATCH 4.9 90/93] mm: dont dereference struct page fields of invalid pages Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 91/93] net/mlx5: E-Switch, Re-enable RoCE on mode change only after FDB destroy Greg Kroah-Hartman
2017-08-09 18:14 ` [PATCH 4.9 92/93] ipv4: Should use consistent conditional judgement for ip fragment in __ip_append_data and ip_finish_output Greg Kroah-Hartman
2017-08-09 23:33 ` [PATCH 4.9 00/93] 4.9.42-stable review Holger Hoffstätte
2017-08-09 23:58   ` Greg KH
2017-08-10  0:18     ` Holger Hoffstätte
2017-08-10 16:29       ` Greg KH
2017-08-10  0:15 ` Shuah Khan
2017-08-10  0:41 ` Guenter Roeck
2017-08-10  3:04 ` Sumit Semwal

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=20170809181339.265557532@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.levin@verizon.com \
    --cc=jamie.iles@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).