All of lore.kernel.org
 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,
	Robert Kolchmeyer <rkolchmeyer@google.com>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH 4.16 64/81] fsnotify: Fix fsnotify_mark_connector race
Date: Fri, 27 Apr 2018 15:59:06 +0200	[thread overview]
Message-ID: <20180427135747.053318680@linuxfoundation.org> (raw)
In-Reply-To: <20180427135743.216853156@linuxfoundation.org>

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

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

From: Robert Kolchmeyer <rkolchmeyer@google.com>

commit d90a10e2444ba5a351fa695917258ff4c5709fa5 upstream.

fsnotify() acquires a reference to a fsnotify_mark_connector through
the SRCU-protected pointer to_tell->i_fsnotify_marks. However, it
appears that no precautions are taken in fsnotify_put_mark() to
ensure that fsnotify() drops its reference to this
fsnotify_mark_connector before assigning a value to its 'destroy_next'
field. This can result in fsnotify_put_mark() assigning a value
to a connector's 'destroy_next' field right before fsnotify() tries to
traverse the linked list referenced by the connector's 'list' field.
Since these two fields are members of the same union, this behavior
results in a kernel panic.

This issue is resolved by moving the connector's 'destroy_next' field
into the object pointer union. This should work since the object pointer
access is protected by both a spinlock and the value of the 'flags'
field, and the 'flags' field is cleared while holding the spinlock in
fsnotify_put_mark() before 'destroy_next' is updated. It shouldn't be
possible for another thread to accidentally read from the object pointer
after the 'destroy_next' field is updated.

The offending behavior here is extremely unlikely; since
fsnotify_put_mark() removes references to a connector (specifically,
it ensures that the connector is unreachable from the inode it was
formerly attached to) before updating its 'destroy_next' field, a
sizeable chunk of code in fsnotify_put_mark() has to execute in the
short window between when fsnotify() acquires the connector reference
and saves the value of its 'list' field. On the HEAD kernel, I've only
been able to reproduce this by inserting a udelay(1) in fsnotify().
However, I've been able to reproduce this issue without inserting a
udelay(1) anywhere on older unmodified release kernels, so I believe
it's worth fixing at HEAD.

References: https://bugzilla.kernel.org/show_bug.cgi?id=199437
Fixes: 08991e83b7286635167bab40927665a90fb00d81
CC: stable@vger.kernel.org
Signed-off-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/fsnotify_backend.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -217,12 +217,10 @@ struct fsnotify_mark_connector {
 	union {	/* Object pointer [lock] */
 		struct inode *inode;
 		struct vfsmount *mnt;
-	};
-	union {
-		struct hlist_head list;
 		/* Used listing heads to free after srcu period expires */
 		struct fsnotify_mark_connector *destroy_next;
 	};
+	struct hlist_head list;
 };
 
 /*

  parent reply	other threads:[~2018-04-27 13:59 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27 13:58 [PATCH 4.16 00/81] 4.16.6-stable review Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 01/81] Revert "pinctrl: intel: Initialize GPIO properly when used through irqchip" Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 02/81] drm: bridge: dw-hdmi: Fix overflow workaround for Amlogic Meson GX SoCs Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 03/81] i40e: Fix attach VF to VM issue Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 04/81] tpm: cmd_ready command can be issued only after granting locality Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 05/81] tpm: tpm-interface: fix tpm_transmit/_cmd kdoc Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 06/81] tpm: add retry logic Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 07/81] Revert "ath10k: send (re)assoc peer command when NSS changed" Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 08/81] bonding: do not set slave_dev npinfo before slave_enable_netpoll in bond_enslave Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 09/81] docs: ip-sysctl.txt: fix name of some ipv6 variables Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 10/81] ipv6: add RTA_TABLE and RTA_PREFSRC to rtm_ipv6_policy Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 11/81] ipv6: sr: fix NULL pointer dereference in seg6_do_srh_encap()- v4 pkts Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 12/81] KEYS: DNS: limit the length of option strings Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 13/81] l2tp: check sockaddr length in pppol2tp_connect() Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 14/81] llc: delete timers synchronously in llc_sk_free() Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 15/81] net: af_packet: fix race in PACKET_{R|T}X_RING Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 16/81] net: fix deadlock while clearing neighbor proxy table Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 17/81] net: mvpp2: Fix DMA address mask size Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 18/81] net: qmi_wwan: add Wistron Neweb D19Q1 Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 19/81] net/smc: fix shutdown in state SMC_LISTEN Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 20/81] net: stmmac: Disable ACS Feature for GMAC >= 4 Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 21/81] packet: fix bitfield update race Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 22/81] pppoe: check sockaddr length in pppoe_connect() Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 23/81] Revert "macsec: missing dev_put() on error in macsec_newlink()" Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 24/81] sctp: do not check port in sctp_inet6_cmp_addr Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 25/81] strparser: Do not call mod_delayed_work with a timeout of LONG_MAX Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 26/81] strparser: Fix incorrect strp->need_bytes value Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 27/81] tcp: clear tp->packets_out when purging write queue Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 28/81] tcp: dont read out-of-bounds opsize Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 29/81] tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT on established sockets Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 30/81] team: avoid adding twice the same option to the event list Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 31/81] team: fix netconsole setup over team Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 32/81] tipc: add policy for TIPC_NLA_NET_ADDR Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 33/81] vlan: Fix reading memory beyond skb->tail in skb_vlan_tagged_multi Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 34/81] vmxnet3: fix incorrect dereference when rxvlan is disabled Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 35/81] amd-xgbe: Add pre/post auto-negotiation phy hooks Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 36/81] amd-xgbe: Improve KR auto-negotiation and training Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 37/81] amd-xgbe: Only use the SFP supported transceiver signals Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 38/81] net: sched: ife: signal not finding metaid Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 39/81] net: sched: ife: handle malformed tlv length Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 40/81] net: sched: ife: check on metadata length Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 41/81] l2tp: hold reference on tunnels in netlink dumps Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 42/81] l2tp: hold reference on tunnels printed in pppol2tp proc file Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 43/81] l2tp: hold reference on tunnels printed in l2tp/tunnels debugfs file Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 44/81] l2tp: fix {pppol2tp, l2tp_dfs}_seq_stop() in case of seq_file overflow Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 45/81] llc: hold llc_sap before release_sock() Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 46/81] llc: fix NULL pointer deref for SOCK_ZAPPED Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 47/81] s390/qeth: fix error handling in adapter command callbacks Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 48/81] s390/qeth: avoid control IO completion stalls Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 49/81] s390/qeth: handle failure on workqueue creation Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 50/81] net: ethernet: ti: cpsw: fix tx vlan priority mapping Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 51/81] net: validate attribute sizes in neigh_dump_table() Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 52/81] bnxt_en: Fix memory fault in bnxt_ethtool_init() Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 53/81] virtio-net: add missing virtqueue kick when flushing packets Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 54/81] VSOCK: make af_vsock.ko removable again Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 55/81] net: aquantia: Regression on reset with 1.x firmware Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 56/81] tun: fix vlan packet truncation Greg Kroah-Hartman
2018-04-27 13:58 ` [PATCH 4.16 57/81] net: aquantia: oops when shutdown on already stopped device Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 58/81] virtio_net: split out ctrl buffer Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 59/81] virtio_net: fix adding vids on big-endian Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 60/81] Revert "mm/hmm: fix header file if/else/endif maze" Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 61/81] commoncap: Handle memory allocation failure Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 62/81] scsi: mptsas: Disable WRITE SAME Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 63/81] cdrom: information leak in cdrom_ioctl_media_changed() Greg Kroah-Hartman
2018-04-27 13:59 ` Greg Kroah-Hartman [this message]
2018-04-27 13:59 ` [PATCH 4.16 65/81] m68k/mac: Dont remap SWIM MMIO region Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 66/81] block/swim: Check drive type Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 67/81] block/swim: Dont log an error message for an invalid ioctl Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 68/81] block/swim: Remove extra put_disk() call from error path Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 69/81] block/swim: Rename macros to avoid inconsistent inverted logic Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 70/81] block/swim: Select appropriate drive on device open Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 71/81] block/swim: Fix array bounds check Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 72/81] block/swim: Fix IO error at end of medium Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 73/81] tracing: Fix missing tab for hwlat_detector print format Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 74/81] hwmon: (k10temp) Add temperature offset for Ryzen 2700X Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 75/81] hwmon: (k10temp) Add support for AMD Ryzen w/ Vega graphics Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 76/81] s390/cio: update chpid descriptor after resource accessibility event Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 77/81] s390/dasd: fix IO error for newly defined devices Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 78/81] s390/uprobes: implement arch_uretprobe_is_alive() Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 79/81] s390/cpum_cf: rename IBM z13/z14 counter names Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 80/81] kprobes: Fix random address output of blacklist file Greg Kroah-Hartman
2018-04-27 13:59 ` [PATCH 4.16 81/81] ACPI / video: Only default only_lcd to true on Win8-ready _desktops_ Greg Kroah-Hartman
2018-04-27 18:15 ` [PATCH 4.16 00/81] 4.16.6-stable review Shuah Khan
2018-04-27 20:41 ` Dan Rue
2018-04-28  5:50   ` Greg Kroah-Hartman
2018-04-27 20:44 ` kernelci.org bot
2018-04-28 14:32 ` Guenter Roeck
2018-04-28 15:52   ` Greg Kroah-Hartman

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=20180427135747.053318680@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkolchmeyer@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.