Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp785222ybh; Wed, 11 Mar 2020 10:45:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsp1KZ+/e+MU5BzVAAZAI2k6fHqqIlz4bq6CEzBVVzq/CuPCMMyW33H1BR2o6ZsfoYXRzS0 X-Received: by 2002:a9d:3ea4:: with SMTP id b33mr3122248otc.136.1583948703411; Wed, 11 Mar 2020 10:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583948703; cv=none; d=google.com; s=arc-20160816; b=dTzGAXk9IiAxf6fjm389/qw06CxSFNLDm6Dxs/O2blbmy11i2OIJTaFDQvDpIJbGqe N24JK/JmLc86RHRs5f4vaDVLU6IBCGRmFL7kH1T+HFNL1JBFh4WN7+fExegtjElHJa6G q1DMTBb0Jv8k7uxsB6lLNgKRUUQ75vPBG5G3WKqFgWX/HXVCv7vE48515bdK+g36oYu0 dy7sEMu6BJIqi1Gf7Ju3XLyQ4DjtHxSte3gN9bXNEaJf7DiQiE4i+S7g3vNys9Yr3Ryw aTsAtjt4WCf22EXHzUy1JYyv1KBtwz+zpKi6mx73/A9akB+WZn1kc2bQTJWZ1lNb+Rys Ovfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=95hfOnFS8XcE0SzCSwHywUOSO3ehRo621FiZoRz9T2U=; b=XI8LAE2MMeS7nQyN1cPuiIvvIlvaBfaJu8xz77yA+nCuR1bGOpfFMdN/u6+6FuKzXt iTbVUgIEJZlR/ZVwnEvfYoeoWusyU4CW6ita1tVcYJA9UNaGRG12h8wXJCK+baOuTy9g USehyU8GT7mKbbdDQ3F8VWRlHzKlSXuZgnSIXFAtp4hmiALicu6iiAIbS0uFFv9yr7LH 6eeFFIlFITvPa7QKq5QPVMIYDWDT8lJ+Z9R6jTDN4mhMA0y7fTL4IX2SWStxHycB8wuu ypP4HXpMG2iacPOLU6i0xGrTLqXy3t6KC88IWUcBBiP5wwOd7la3nbxaFBVDEhQGA3Gw VUIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S72xrfKy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id k201si1570670oib.94.2020.03.11.10.44.52; Wed, 11 Mar 2020 10:45:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S72xrfKy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730575AbgCKRoN (ORCPT + 99 others); Wed, 11 Mar 2020 13:44:13 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36431 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730385AbgCKRoM (ORCPT ); Wed, 11 Mar 2020 13:44:12 -0400 Received: by mail-pl1-f194.google.com with SMTP id g12so1434388plo.3 for ; Wed, 11 Mar 2020 10:44:11 -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=Y4n3sfZR2myVhT3Z/3MY0/kP8w5jHRJjwrTcV0xLgvVaqyaxR/9sdwYujNtos+DEZ4 Xo1AhcO0XA+8wD5PA+3Cz/sAWvsaDNd7f3NMN5bXvCXgWbUUugQd0InrxgK+8gUzD6UZ y1MsI+iKD3Ro3Nh2mqh5GtdzbBOaJkKXUglIXmbJ1uZUp3ujkNiYafkn5H7uXVgTamjh EK+oYG00J+AFkrorHjMT7b+rgz0Az1cgTDuZUTEzlXj7/hdCl8ckNiHrBH1sydknm3ZH UljV+PoKWHXPWDbpuAztiwdoI4DdRY+yLrfK9ZqLb/s42RkQlezEydjGR9cFDv4tHs0m /vbA== X-Gm-Message-State: ANhLgQ0aW7mOWKwExS/xmFXcxBtM3cUcwfNObBihVyzkHTH6n9kwMETp r0kpwOshriQ2GZguWRquK0MJXw== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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