From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Laura Abbott <labbott@redhat.com>,
Thibaut Sautereau <thibaut.sautereau@clip-os.org>,
David Rientjes <rientjes@google.com>,
Alexander Potapenko <glider@google.com>,
Kees Cook <keescook@chromium.org>,
"David S. Miller" <davem@davemloft.net>,
Vlastimil Babka <vbabka@suse.cz>,
clipos@ssi.gouv.fr, Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5.3 45/48] mm: slub: really fix slab walking for init_on_free
Date: Tue, 19 Nov 2019 06:20:05 +0100 [thread overview]
Message-ID: <20191119051028.131345484@linuxfoundation.org> (raw)
In-Reply-To: <20191119050946.745015350@linuxfoundation.org>
From: Laura Abbott <labbott@redhat.com>
commit aea4df4c53f754cc229edde6c5465e481311cc49 upstream.
Commit 1b7e816fc80e ("mm: slub: Fix slab walking for init_on_free")
fixed one problem with the slab walking but missed a key detail: When
walking the list, the head and tail pointers need to be updated since we
end up reversing the list as a result. Without doing this, bulk free is
broken.
One way this is exposed is a NULL pointer with slub_debug=F:
=============================================================================
BUG skbuff_head_cache (Tainted: G T): Object already free
-----------------------------------------------------------------------------
INFO: Slab 0x000000000d2d2f8f objects=16 used=3 fp=0x0000000064309071 flags=0x3fff00000000201
BUG: kernel NULL pointer dereference, address: 0000000000000000
Oops: 0000 [#1] PREEMPT SMP PTI
RIP: 0010:print_trailer+0x70/0x1d5
Call Trace:
<IRQ>
free_debug_processing.cold.37+0xc9/0x149
__slab_free+0x22a/0x3d0
kmem_cache_free_bulk+0x415/0x420
__kfree_skb_flush+0x30/0x40
net_rx_action+0x2dd/0x480
__do_softirq+0xf0/0x246
irq_exit+0x93/0xb0
do_IRQ+0xa0/0x110
common_interrupt+0xf/0xf
</IRQ>
Given we're now almost identical to the existing debugging code which
correctly walks the list, combine with that.
Link: https://lkml.kernel.org/r/20191104170303.GA50361@gandi.net
Link: http://lkml.kernel.org/r/20191106222208.26815-1-labbott@redhat.com
Fixes: 1b7e816fc80e ("mm: slub: Fix slab walking for init_on_free")
Signed-off-by: Laura Abbott <labbott@redhat.com>
Reported-by: Thibaut Sautereau <thibaut.sautereau@clip-os.org>
Acked-by: David Rientjes <rientjes@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Acked-by: Alexander Potapenko <glider@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <clipos@ssi.gouv.fr>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.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/slub.c | 39 +++++++++------------------------------
1 file changed, 9 insertions(+), 30 deletions(-)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1432,12 +1432,15 @@ static inline bool slab_free_freelist_ho
void *old_tail = *tail ? *tail : *head;
int rsize;
- if (slab_want_init_on_free(s)) {
- void *p = NULL;
+ /* Head and tail of the reconstructed freelist */
+ *head = NULL;
+ *tail = NULL;
+
+ do {
+ object = next;
+ next = get_freepointer(s, object);
- do {
- object = next;
- next = get_freepointer(s, object);
+ if (slab_want_init_on_free(s)) {
/*
* Clear the object and the metadata, but don't touch
* the redzone.
@@ -1447,29 +1450,8 @@ static inline bool slab_free_freelist_ho
: 0;
memset((char *)object + s->inuse, 0,
s->size - s->inuse - rsize);
- set_freepointer(s, object, p);
- p = object;
- } while (object != old_tail);
- }
-
-/*
- * Compiler cannot detect this function can be removed if slab_free_hook()
- * evaluates to nothing. Thus, catch all relevant config debug options here.
- */
-#if defined(CONFIG_LOCKDEP) || \
- defined(CONFIG_DEBUG_KMEMLEAK) || \
- defined(CONFIG_DEBUG_OBJECTS_FREE) || \
- defined(CONFIG_KASAN)
-
- next = *head;
- /* Head and tail of the reconstructed freelist */
- *head = NULL;
- *tail = NULL;
-
- do {
- object = next;
- next = get_freepointer(s, object);
+ }
/* If object's reuse doesn't have to be delayed */
if (!slab_free_hook(s, object)) {
/* Move object to the new freelist */
@@ -1484,9 +1466,6 @@ static inline bool slab_free_freelist_ho
*tail = NULL;
return *head != NULL;
-#else
- return true;
-#endif
}
static void *setup_object(struct kmem_cache *s, struct page *page,
next prev parent reply other threads:[~2019-11-19 5:23 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 5:19 [PATCH 5.3 00/48] 5.3.12-stable review Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 01/48] scsi: core: Handle drivers which set sg_tablesize to zero Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 02/48] ax88172a: fix information leak on short answers Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 03/48] devlink: disallow reload operation during device cleanup Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 04/48] ipmr: Fix skb headroom in ipmr_get_route() Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 05/48] mlxsw: core: Enable devlink reload only on probe Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 06/48] net: gemini: add missed free_netdev Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 07/48] net/smc: fix fastopen for non-blocking connect() Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 08/48] net: usb: qmi_wwan: add support for Foxconn T77W968 LTE modules Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 09/48] slip: Fix memory leak in slip_open error path Greg Kroah-Hartman
2019-11-19 7:43 ` Oliver Hartkopp
2019-11-19 7:55 ` Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 10/48] tcp: remove redundant new line from tcp_event_sk_skb Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 11/48] dpaa2-eth: free already allocated channels on probe defer Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 12/48] devlink: Add method for time-stamp on reporters dump Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 13/48] net/smc: fix refcount non-blocking connect() -part 2 Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 14/48] ALSA: usb-audio: Fix missing error check at mixer resolution test Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 15/48] ALSA: usb-audio: not submit urb for stopped endpoint Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 16/48] ALSA: usb-audio: Fix incorrect NULL check in create_yamaha_midi_quirk() Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 17/48] ALSA: usb-audio: Fix incorrect size check for processing/extension units Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 18/48] Btrfs: fix log context list corruption after rename exchange operation Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 19/48] cgroup: freezer: call cgroup_enter_frozen() with preemption disabled in ptrace_stop() Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 20/48] Input: ff-memless - kill timer in destroy() Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 21/48] Input: synaptics-rmi4 - fix video buffer size Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 22/48] Input: synaptics-rmi4 - disable the relative position IRQ in the F12 driver Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 23/48] Input: synaptics-rmi4 - do not consume more data than we have (F11, F12) Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 24/48] Input: synaptics-rmi4 - clear IRQ enables for F54 Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 25/48] Input: synaptics-rmi4 - destroy F54 poller workqueue when removing Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 26/48] KVM: MMU: Do not treat ZONE_DEVICE pages as being reserved Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 27/48] IB/hfi1: Ensure r_tid_ack is valid before building TID RDMA ACK packet Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 28/48] IB/hfi1: Calculate flow weight based on QP MTU for TID RDMA Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 29/48] IB/hfi1: TID RDMA WRITE should not return IB_WC_RNR_RETRY_EXC_ERR Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 30/48] IB/hfi1: Ensure full Gen3 speed in a Gen4 system Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 31/48] IB/hfi1: Use a common pad buffer for 9B and 16B packets Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 32/48] i2c: acpi: Force bus speed to 400KHz if a Silead touchscreen is present Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 33/48] x86/quirks: Disable HPET on Intel Coffe Lake platforms Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 34/48] ecryptfs_lookup_interpose(): lower_dentry->d_inode is not stable Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 35/48] ecryptfs_lookup_interpose(): lower_dentry->d_parent is not stable either Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 36/48] io_uring: ensure registered buffer import returns the IO length Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 37/48] drm/i915: update rawclk also on resume Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 38/48] Revert "drm/i915/ehl: Update MOCS table for EHL" Greg Kroah-Hartman
2019-11-19 5:19 ` [PATCH 5.3 39/48] ntp/y2038: Remove incorrect time_t truncation Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 40/48] net: ethernet: dwmac-sun8i: Use the correct function in exit path Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 41/48] iommu/vt-d: Fix QI_DEV_IOTLB_PFSID and QI_DEV_EIOTLB_PFSID macros Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 42/48] mm: mempolicy: fix the wrong return value and potential pages leak of mbind Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 43/48] mm: memcg: switch to css_tryget() in get_mem_cgroup_from_mm() Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 44/48] mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup() Greg Kroah-Hartman
2019-11-19 5:20 ` Greg Kroah-Hartman [this message]
2019-11-19 5:20 ` [PATCH 5.3 46/48] mm/memory_hotplug: fix try_offline_node() Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 47/48] mm/page_io.c: do not free shared swap slots Greg Kroah-Hartman
2019-11-19 5:20 ` [PATCH 5.3 48/48] mmc: sdhci-of-at91: fix quirk2 overwrite Greg Kroah-Hartman
2019-11-19 10:16 ` [PATCH 5.3 00/48] 5.3.12-stable review Jon Hunter
2019-11-19 12:32 ` Greg Kroah-Hartman
2019-11-19 11:42 ` kernelci.org bot
2019-11-19 12:35 ` Holger Hoffstätte
2019-11-19 12:45 ` Greg Kroah-Hartman
2019-11-19 13:05 ` Holger Hoffstätte
2019-11-19 13:17 ` Naresh Kamboju
2019-11-19 18:45 ` Dan Rue
2019-11-20 6:00 ` Greg Kroah-Hartman
2019-11-19 20:34 ` 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=20191119051028.131345484@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=clipos@ssi.gouv.fr \
--cc=davem@davemloft.net \
--cc=glider@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=keescook@chromium.org \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=stable@vger.kernel.org \
--cc=thibaut.sautereau@clip-os.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/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).