From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68487C433DF for ; Thu, 8 Oct 2020 23:10:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 92F6F2224C for ; Thu, 8 Oct 2020 23:10:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="m4LWGF/t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92F6F2224C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 559CD6B005C; Thu, 8 Oct 2020 19:10:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 509E06B005D; Thu, 8 Oct 2020 19:10:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F91C6B0062; Thu, 8 Oct 2020 19:10:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 10C976B005C for ; Thu, 8 Oct 2020 19:10:41 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 90660180AD804 for ; Thu, 8 Oct 2020 23:10:40 +0000 (UTC) X-FDA: 77350304640.24.rail39_0e12d27271db Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 720D11A4A0 for ; Thu, 8 Oct 2020 23:10:40 +0000 (UTC) X-HE-Tag: rail39_0e12d27271db X-Filterd-Recvd-Size: 4632 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 8 Oct 2020 23:10:39 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id k8so5253566pfk.2 for ; Thu, 08 Oct 2020 16:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=huNoRIdSFpI9osYj0Zanh/sVIIaopm6n5nRrz69OQbw=; b=m4LWGF/tsX9ES7Pg2pKcZIC8l64KYx/UzR2x6lpLCzQTfCXYw11yP5EmAFa37yNKFU gapizvmE/3LmANm9YRL8DBkIG6a6TRaG48/aYtl+i7aL7BuR12BMnX+BvX59MqFJwXJM GQnZUkNb9/+vJ9MZQLttwxNXodwBiSK8A6hZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=huNoRIdSFpI9osYj0Zanh/sVIIaopm6n5nRrz69OQbw=; b=K5YpsdVbnbwv4rSk5TQUDg6M9knTGdUn14ScMDAFmNy3FEla8x6lr0tEsDc6A/uw2F hZX1jueYRBteEFve25OMPKQnoYfXTK0XW6pWVdl946HInPrbWg/eLpU6hl9fdC/VVfFY ECKSOQPM/KPYQhK6jiS281Zoo5gkuCGz8qFENcYdD1ePG1DWYOpIYnHDJEQ4ZdTfLFHS 56OqXGI4IIBwGIG/PgVHJCAxi0kbW2LYCcUb4d0iHDDzyDlniPAFhh4R1RzJJO/xIj16 xRVPfTbAl1eMXdU5V+vxwBY1jQa6l3FK+o2yNU/QOeAnMcjeXC29/jKQGbDYxEzqVRgv 7HGA== X-Gm-Message-State: AOAM530MXLSes3uEeW4HPEvHA16PuLadetmY4//idY5UHbmR259QAE4U woXaHo4UIZx8ix7OMl7zRYoxYg== X-Google-Smtp-Source: ABdhPJz9MNSH7R58VxI81YC9Wu68n7SohNOGAow2G71lbVpzp/qQZq+clc+42N5sqiR7/n6+knThDw== X-Received: by 2002:aa7:94a4:0:b029:151:d786:d5c2 with SMTP id a4-20020aa794a40000b0290151d786d5c2mr9273480pfl.50.1602198639047; Thu, 08 Oct 2020 16:10:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w187sm8143383pfb.93.2020.10.08.16.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 16:10:37 -0700 (PDT) Date: Thu, 8 Oct 2020 16:10:36 -0700 From: Kees Cook To: Marco Elver Cc: Pekka Enberg , Alexander Potapenko , Andrew Morton , David Rientjes , Joonsoo Kim , Christoph Lameter , kasan-dev , LKML , "linux-mm@kvack.org" Subject: Re: Odd-sized kmem_cache_alloc and slub_debug=Z Message-ID: <202010081608.E1401C067@keescook> References: <20200807160627.GA1420741@elver.google.com> <20200807171849.GA1467156@elver.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Aug 17, 2020 at 08:31:35PM +0200, Marco Elver wrote: > On Fri, 7 Aug 2020 at 21:06, Pekka Enberg wrote: > ... > > Yeah, it reproduces with defconfig too, as long as you remember to > > pass "slub_debug=Z"... :-/ > > > > The following seems to be the culprit: > > > > commit 3202fa62fb43087387c65bfa9c100feffac74aa6 > > Author: Kees Cook > > Date: Wed Apr 1 21:04:27 2020 -0700 > > > > slub: relocate freelist pointer to middle of object > > > > Reverting this commit and one of it's follow up fixes from Kees from > > v5.8 makes the issue go away for me. Btw, please note that caches with > > size 24 and larger do not trigger this bug, so the issue is that with > > small enough object size, we're stomping on allocator metadata (I > > assume part of the freelist). > > Was there a patch to fix this? Checking, just in case I missed it. Hi! I've finally carved out time to look at this, and I've figured it out. My prior redzoning fix was actually wrong; I'll send a patch to fix it harder. In the meantime, I've also discovered that the redzoning code wasn't safe for sizes smaller than sizeof(void *). This oversight is, I think, what caused me to incorrectly handle the changed offset the first time. :P Anyway, patches incoming... -- Kees Cook