Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1639641pxu; Thu, 8 Oct 2020 17:35:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz77tq9TxpWCtqklfBYMStXn8jY5o8Uw+D/FDZ/l+AyRod6POIwFjmIUqHPZgP2kd+p3KTG X-Received: by 2002:a17:906:39c8:: with SMTP id i8mr10708390eje.299.1602203716666; Thu, 08 Oct 2020 17:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602203716; cv=none; d=google.com; s=arc-20160816; b=rI8f3F2w5N4LtUCCcx1dgH0g+ABXTYyuUMaFlLQTHFLj2ZRPX+otu+O/YPk7NjK7K4 PEAaeEAjhTZ8ILD1461FL7Zr4VCvPhpRrExx6Hzm3Bz75V3uIWWmPhvlEJ8s4WnGV8OX woRr9IFnqNQd6IqK6enZ0Cw1gzqb8bgLq7LKaNC1DhiGsYxR6IX0mxHNxHTn9bdhdRzi zuHmRApA+uyPgQH96yPY1h72Ngnhkw/5/F0knpreTal5ZCoK6uEpQp6FiZEQO48b+m1G FgzAjRoNykxsatE6P+77kdeMAGVcn33zhAcQQBcvVvYu+iAqkJSNXxKkoTb4PZA1BKEm kluA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=huNoRIdSFpI9osYj0Zanh/sVIIaopm6n5nRrz69OQbw=; b=TDSDUokLryaqWYL6jqOL+xARc9O8wjPQfvGYNjtydSCCh/GnUljaJf4jjf5nIGrlgl 07xF1cD5on15Su/1gjnhxoKFywylJ5l8rKQ5MhSI488cyOXDcya/aFGsK6+bF1wzOYRr Gy5COqoKnsFyaK4LINpaMN8MujfgAUI/kWUaf5mWI99YoXk2xfRq906w9tnzZbm+65Lq LrZPOZTk0qYTyPcVtgwWDd+gcYlC8KdeI0BhZ5ThR8IFWBGmK5j6DCRUMR6fSgKSuFMn WVgyTa0aXFiFESyfJzdL20ngEzJsVbo2rKcIW46PWFTEOBjlHNaljnujpbZGsP/SvK90 8VLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="m4LWGF/t"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx14si5416990ejb.31.2020.10.08.17.34.53; Thu, 08 Oct 2020 17:35:16 -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; dkim=pass header.i=@chromium.org header.s=google header.b="m4LWGF/t"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbgJHXKj (ORCPT + 99 others); Thu, 8 Oct 2020 19:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgJHXKj (ORCPT ); Thu, 8 Oct 2020 19:10:39 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88BA9C0613D2 for ; Thu, 8 Oct 2020 16:10:39 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id r21so2234054pgj.5 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=q/cukKbAOXaPTabVhddJQFRX9ZUh7V3hINX8jTXwV110ysKGW2Ymmmb0gkEAckrEV5 aLo/7rgGcx/ltwx3PIWa/ZN3aOmdtkGaIiZcUMtgkpciKpPjmDne0au9NOYPabiTBk28 vvBbB8lJl4PPWz+85QfpmSBNooJg+aMYThv8no5Xg8lWM9Jp9jM4BjbOHEPc2CGMf8Wm S7SWwv0Rg6RSXeRsn55ZkN+XaUnZTs/dO1kzguP8no9hbsGEm3hU151I6PwkbqKK7jfx ARGq7IiU4YRitFQXEwVT7UWwPaH9EpAB9jNlxSDEkd8ePMloO3wQhclf1cygoo/pyVyL wpgw== X-Gm-Message-State: AOAM533ExBB/MEFhGLpCdmexSsuI2FfDx2P1GKEtNut1as4NFHsLU7F5 aM83xUSU9MSPJloTaa9nqnhZfA== 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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