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=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 2136FC0044D for ; Wed, 11 Mar 2020 17:44:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8FE582074F for ; Wed, 11 Mar 2020 17:44:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="S72xrfKy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FE582074F 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 6791F6B0003; Wed, 11 Mar 2020 13:44:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 629AB6B0005; Wed, 11 Mar 2020 13:44:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F1476B0006; Wed, 11 Mar 2020 13:44:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 307A96B0003 for ; Wed, 11 Mar 2020 13:44:13 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id ECD104DB7 for ; Wed, 11 Mar 2020 17:44:12 +0000 (UTC) X-FDA: 76583805144.10.play23_5ef9a0eb98516 X-HE-Tag: play23_5ef9a0eb98516 X-Filterd-Recvd-Size: 4245 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 17:44:12 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id ay11so1439817plb.0 for ; Wed, 11 Mar 2020 10:44:12 -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=95hfOnFS8XcE0SzCSwHywUOSO3ehRo621FiZoRz9T2U=; b=S72xrfKyT6ehcjzIlNPRULiD7x0Ry14Ev5yh8+oY7+cEOwLlgoUzbRYHhkyUTRyJY3 1F6KkDlrXFMvSPXpAgoXaW+KFeOB5zRs/27RpIE3k/lCBcJhTwCvTgd0TNoh5K81SfUx bt0J9C43UMfm+SwtHPVMonayJX3loJX1Bot1c= 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=95hfOnFS8XcE0SzCSwHywUOSO3ehRo621FiZoRz9T2U=; b=eQVa2T6nOD4kj9QFYM3Tvs2oAQ6p61NuJQFv+z5WGbz0GblefAf50scB3PKAVKtnKN AUQC4XhoxkM1G4srVfcltw0SMj1lohZK8WU0dFHbPwz91MoADLayX28uMdA/OCE4bYws Ulu5UPv9f0rhinscoCpCJSvjS3K4uYyEJsBli7JDzOY/uasJYbQpLUB3fkqhQcye8sCo 3D0LT04s1mR495Ai9gzPyG4n+lALuA1b5K5beQXeCBCyyvxgVb8AtVHxQNVXoRrHtUUO H1jzSsoMyfseThvjyXZMgOcmVbUfP7WiR51lD5lWgAbxu088IAoGIybsAboZMTNJJMxg bhvA== X-Gm-Message-State: ANhLgQ3SzfmZllK4PeSzSAHhfNtQnn1i34s/HqH04HxuqHbqFoCk+ocp qKgwFoqXZRQ16G867csOBn34SQ== X-Google-Smtp-Source: ADFU+vt1E7WV6q/CcNOlqwjmSB7ni8eqk0Pkds5Yk5WBpGtM41QjlcCGsbMYxNIMZIokJn1Rpuq08w== X-Received: by 2002:a17:90a:fa16:: with SMTP id cm22mr4679988pjb.137.1583948651386; Wed, 11 Mar 2020 10:44:11 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d84sm1265231pfd.197.2020.03.11.10.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:44:10 -0700 (PDT) Date: Wed, 11 Mar 2020 10:44:09 -0700 From: Kees Cook To: 'Christopher Lameter' Cc: David Laight , Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Daniel Micay , Vitaly Nikolenko , Silvio Cesare , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] slub: Relocate freelist pointer to middle of object Message-ID: <202003111039.24B8A0B@keescook> References: <202003051624.AAAC9AECC@keescook> <6fbf67b5936a44feaf9ad5b58d39082b@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6fbf67b5936a44feaf9ad5b58d39082b@AcuMS.aculab.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000143, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Christopher Lameter > Sent: 08 March 2020 19:21 > > On Thu, 5 Mar 2020, Kees Cook wrote: > > > Instead of having the freelist pointer at the very beginning of an > > allocation (offset 0) or at the very end of an allocation (effectively > > offset -sizeof(void *) from the next allocation), move it away from > > the edges of the allocation and into the middle. This provides some > > protection against small-sized neighboring overflows (or underflows), > > for which the freelist pointer is commonly the target. (Large or well > > controlled overwrites are much more likely to attack live object contents, > > instead of attempting freelist corruption.) > > Sounds good. You could even randomize the position to avoid attacks on via > the freelist pointer. That's a good point. "offset" is just calculated once, and for many slabs, the available space is quite large. I wonder what the best practice might be for how far from the edge to stay. Hmmm. Maybe simply carve it into thirds, and randomize the offset within the middle third? -- Kees Cook