Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2741178ybg; Fri, 5 Jun 2020 23:50:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBTQxkBQAeGwYrErmZUJWVOzi+iuXbi0jqjEl5ZTIDkFhsJfAlh+vMCcPEHB5qMoElvFSB X-Received: by 2002:a17:906:f115:: with SMTP id gv21mr11838684ejb.340.1591426201651; Fri, 05 Jun 2020 23:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591426201; cv=none; d=google.com; s=arc-20160816; b=WH7ODQyLocxAt4mLnLnGt+uaVYWkI9uBgjbxgU3rmzTGL9ToudcO/36XkSwmPhx+in L0djYky3HwUpJmqREaHGtQwWm9d+v63FPziBxM5zK90mevsH+qPFg3PViX6QlVZQhsmH wyyLQ2OI39Yrnq6nQ9WTgutIOE17Rs9AZ1sJmjsdyj4qOoofmVv39ylwxBkNULcha7N6 zBv2rqVHL7Wd/Lb1tzszXWWAR5OWY80HNczaWcdLAlUBfArB9Z+gOW2hjeYAk+Adxv9c XR2XVbCL74Bn0VkYQqd1gz+PAaYMCS412Cb2lZZML4TyjuVrhygv6XJxyHPR9ulzGFei /m+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=gwWaD5Q8IVHw1QydWU1MECvDrlkrGMlMpGEjvbM9ZfM=; b=TIU2ylW8GBTjR5VepTH2eezmMQtam9HRbXmP7PJDTbrMy8GseXSEnW90OuBARtY5tx 936FaWpqwrIaVSL6CWy8hvkwB5ct1rLvlJz7CDNDibqSAa71c2+G1WJB5M3qv3eKje+r pu6oHc1E3AQlaV7MaUDTG5H1BEq7WmcmP2QZQJOFDzdrIEJcYKap7aWui0jXENSPbp01 OnUMyH/m08erF3WS1OvgWV+Qkr9btN+RiCcyxojJhBFu771GJzhZ2csSbqNyk//SZ8aB D4B8tBfVCH9pLGq2pYamWK9JLFVzwhj7vtWInugLdnNGRl29Mm5D/kEI+cq0PoSqd7S2 Thog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si5239461eji.483.2020.06.05.23.49.26; Fri, 05 Jun 2020 23:50:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgFFGqz (ORCPT + 99 others); Sat, 6 Jun 2020 02:46:55 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:39758 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbgFFGqz (ORCPT ); Sat, 6 Jun 2020 02:46:55 -0400 Received: by mail-oi1-f195.google.com with SMTP id d67so10273326oig.6; Fri, 05 Jun 2020 23:46:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gwWaD5Q8IVHw1QydWU1MECvDrlkrGMlMpGEjvbM9ZfM=; b=skc17AceG0eTRbieph+TCKSJ5sBkDkP+Az3IZe+z4oMkmeP+pv5o6hncBJjwLl8Zv5 A93GF99rRBpd2zcO3r8T+ZvSTOJfXWVSnG98LXn6pK/T1SDeqIzfjpZxFplxV6eL5Q6G w59kpNthIh/YEH/nL5HUBr6BxfRv/jN49awkeNGgpN5hnG2CdJkKwHoI5XE8WjGtdzpG Jw5vOyn8NP4nBAuzcjlow+BaQnYL+8bvQUt/f6Kmrulg856noYuL1jOPLClF7lyyhMrq 3oogE97+Jcgc7vRLUpxW4hStMmBABxy6fsDiyDXZ6bsoBDxXzrUD0WicMYMJlWQbqKI8 UeWQ== X-Gm-Message-State: AOAM533+nyFt9rqaWU1UarnuGieaQos1ChNAoQ+xc0cYzaYCd4THvpex ONinYMXxt/zycPUkktIC3drOonkEBRA1rEfyJhU= X-Received: by 2002:aca:ad88:: with SMTP id w130mr4395472oie.103.1591426014336; Fri, 05 Jun 2020 23:46:54 -0700 (PDT) MIME-Version: 1.0 References: <7839183d-1c0b-da02-73a2-bf5e1e8b02b9@suse.cz> <94296941-1073-913c-2adb-bf2e41be9f0f@oracle.com> <202006041054.874AA564@keescook> <34455dce-6675-1fc2-8d61-45bf56f3f554@suse.cz> <6b2b149e-c2bc-f87a-ea2c-3046c5e39bf9@oracle.com> <894e8cee-33df-1f63-fb12-72dceb024ea7@oracle.com> <202006050828.F85A75D13@keescook> In-Reply-To: <202006050828.F85A75D13@keescook> From: "Rafael J. Wysocki" Date: Sat, 6 Jun 2020 08:46:42 +0200 Message-ID: Subject: Re: slub freelist issue / BUG: unable to handle page fault for address: 000000003ffe0018 To: Kees Cook Cc: Vegard Nossum , Vlastimil Babka , "Rafael J. Wysocki" , Robert Moore , Erik Kaneda , "Rafael J. Wysocki" , Christoph Lameter , Andrew Morton , Marco Elver , Waiman Long , LKML , Linux MM , ACPI Devel Maling List , Len Brown , Steven Rostedt Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 5, 2020 at 5:44 PM Kees Cook wrote: > > On Fri, Jun 05, 2020 at 04:44:51PM +0200, Vegard Nossum wrote: > > On 2020-06-05 16:08, Vlastimil Babka wrote: > > > On 6/5/20 3:12 PM, Rafael J. Wysocki wrote: > > > > On Fri, Jun 5, 2020 at 2:48 PM Vegard Nossum wrote: > > > > > > > > > > On 2020-06-05 11:36, Vegard Nossum wrote: > > > > > > > > > > > > On 2020-06-05 11:11, Vlastimil Babka wrote: > > > > > > > So, with Kees' patch reverted, booting with slub_debug=F (or even more > > > > > > > specific slub_debug=F,ftrace_event_field) also hits this bug below. I > > > > > > > wanted to bisect it, but v5.7 was also bad, and also v5.6. Didn't try > > > > > > > further in history. So it's not new at all, and likely very specific to > > > > > > > your config+QEMU? (and related to the ACPI error messages that precede > > > > > > > it?). > > > [...] > > > [ 0.140408] ------------[ cut here ]------------ > > > [ 0.140837] cache_from_obj: Wrong slab cache. Acpi-Namespace but object is from kmalloc-64 > > > [ 0.141406] WARNING: CPU: 0 PID: 1 at mm/slab.h:524 kmem_cache_free+0x1d3/0x250 > > Ah yes! Good. I had improved this check recently too, and I was worried > the freelist pointer patch was somehow blocking it, but I see now that > the failing config didn't have CONFIG_SLAB_FREELIST_HARDENED=y. Once > SLAB_CONSISTENCY_CHECKS was enabled ("slub_debug=F"), it started > tripping. Whew. > > I wonder if that entire test block should just be removed from > cache_from_obj(): > > if (!memcg_kmem_enabled() && > !IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) && > !unlikely(s->flags & SLAB_CONSISTENCY_CHECKS)) > return s; > > and make this test unconditional? It's mostly only called during free(), > and shouldn't be too expensive to be made unconditional. Hmm. > > > > And it seems ACPI is allocating an object via kmalloc() and then freeing it > > > via kmem_cache_free(<"Acpi-Namespace" kmem_cache>) which is wrong. > > > > > > > ./scripts/faddr2line vmlinux 'acpi_ns_root_initialize+0xb6' > > > acpi_ns_root_initialize+0xb6/0x2d1: > > > kmalloc at include/linux/slab.h:555 > > > (inlined by) kzalloc at include/linux/slab.h:669 > > > (inlined by) acpi_os_allocate_zeroed at include/acpi/platform/aclinuxex.h:57 > > > (inlined by) acpi_ns_root_initialize at drivers/acpi/acpica/nsaccess.c:102 > > > > > > > That's it :-) This fixes it for me: > > > > diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c > > index 2566e2d4c7803..b76bbab917941 100644 > > --- a/drivers/acpi/acpica/nsaccess.c > > +++ b/drivers/acpi/acpica/nsaccess.c > > @@ -98,14 +98,12 @@ acpi_status acpi_ns_root_initialize(void) > > * predefined names are at the root level. It is much easier > > to > > * just create and link the new node(s) here. > > */ > > - new_node = > > - ACPI_ALLOCATE_ZEROED(sizeof(struct > > acpi_namespace_node)); > > + new_node = acpi_ns_create_node(*ACPI_CAST_PTR (u32, > > init_val->name)); > > if (!new_node) { > > status = AE_NO_MEMORY; > > goto unlock_and_exit; > > } > > > > - ACPI_COPY_NAMESEG(new_node->name.ascii, init_val->name); > > new_node->descriptor_type = ACPI_DESC_TYPE_NAMED; > > new_node->type = init_val->type; > > I'm a bit confused by the internals of acpi_ns_create_note(). It can still > end up calling ACPI_ALLOCATE_ZEROED() via acpi_os_acquire_object(). No, it can't. Linux uses the one from include/acpi/platform/aclinuxex.h > Is this fix correct? Yes, it is, AFAICS. Cheers!