Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4009474ybd; Tue, 25 Jun 2019 12:21:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOuxQ8yw8qY/9fC93FwfD4+MAwuQm6yjBAtXTrW5BLjA0F1+CDuOWGLdBJO4MvuadFNsZc X-Received: by 2002:a17:90a:d996:: with SMTP id d22mr513440pjv.86.1561490496557; Tue, 25 Jun 2019 12:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561490496; cv=none; d=google.com; s=arc-20160816; b=jBb7NC+IbkHSGSTgBn9vNSYfjP3oeNAXgkG2pQVd5ypeuD1vT55fnLXjlUWD0iolQy wxushGWNxIhuRhcxrpDuVGpjazBAVkW0j/eOjKVPxJsBGRgd676Vi2a/p+2106bTBFzO 0G863X4czsf7KzixvVtdUR86Sb2kIe0yPH8IKSFYxNx58FcQe1cT3HVtejeYKnha3/aJ r1rvhj6fZfSxdL+1+AREVEUeL+smbUBTcTl/5ikmRaygGNF/XKSP6Y/qOGZRGKhpdmZ0 QsrWrTTY6VI2pm6cOpTDMdbHZ/uVp5esKjg13D7H668U8vwliKQLcg2fCgGxMc+zcW6Q znqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bxHs3cMUSY/lcnTBaWC9lm65VMyS9xe/CNCPh9Pq+7Y=; b=kB9YzRjQU/ubL6E9Tc/KQyjV9A5eWlGj8GNN9o3794MFiW/RwI5t1zUEJIx+ZECUaD e0qI2wWyTAuP1iWzb/pZsv2tOPLpsA/4asnVTHgTRDYTjHy4+zor2wFOMadsFpB49q2O /Ng98+X5PCCSwo4ublI67qcV/X4BSZdOK11No8GoXRxq7tEbSIhdwtNUwepUowoVuQoQ L8ont7ce6XFUy/OpZz6bqoCbr92/RE5Ym2IOk6mCHGgFThYcbQUvms0wolIBGiSK5OlE HlK0abkr7NstlOjCwgiVv6o1+GLiLqZZvBm4ermRptnTh8o+zb/myGNnw/Eo2Ht1x5po 83Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lfU+EkDA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s6si1031333plp.229.2019.06.25.12.21.21; Tue, 25 Jun 2019 12:21:36 -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=@google.com header.s=20161025 header.b=lfU+EkDA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbfFYQQ4 (ORCPT + 99 others); Tue, 25 Jun 2019 12:16:56 -0400 Received: from mail-vk1-f196.google.com ([209.85.221.196]:45420 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbfFYQQ4 (ORCPT ); Tue, 25 Jun 2019 12:16:56 -0400 Received: by mail-vk1-f196.google.com with SMTP id e83so3569132vke.12 for ; Tue, 25 Jun 2019 09:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bxHs3cMUSY/lcnTBaWC9lm65VMyS9xe/CNCPh9Pq+7Y=; b=lfU+EkDAWcPLRsWFZdyEfPOrokoZXTJOFAaKyF3r6LE750Q13wN0o6eV2p2X6/qNh3 xlGQrTOAWphdM3tf5Q34V9WcKc5qb9CS3qnIXd4/GggBxU4ZWYv8/urgyGIE/WjwL9wu JBhXvzUzCj7LzikrH2PdogJbPcFyLBQSVovo2yg69817e8gHinU5WNLuBem3pzfcgKhm uwj1XNHUc/4wK7wKWvtPAIKoXhNIipBITpomNKuKYvub+6wZ7z9/OKSUdHzocg5uIVxn gjVsMiEuEbdySUgXhOjJfMxL6lLkNNocT19B5soH7h9dL3yAl4V0IUneDji3O4ZE3idz OLlA== 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:content-transfer-encoding; bh=bxHs3cMUSY/lcnTBaWC9lm65VMyS9xe/CNCPh9Pq+7Y=; b=jpjlm1yq2wXuTOrLqiOZLrW313QVhvn5WD9gsPb+YD1I8Xkuo2G6Le5rJP+iHjdM0D 7g6yydhnmbk+oEaGHw/TJgUHovXoo8YOmeLrjQqs5A8CFY7DxJGcWa/GEmVC95zq8MEg d/U4qoAavEHyyxlA30HTOExo67rY87Rl2NLyRA/+2SjEbuQ1zXbKB9th1an2aQoNumr9 XHpgQCL+2/83PYCtSwjAYWlH9JOhDoIGmU+1cFRKvZvrg9iFA++78lhA+OTJTEzM0aza CPulWcx6U8H1USp4bNN44TBn8OgKAPVWdUTwYASBJb3WQKa5scpej+9fs07FfL+U7d7A 3FUg== X-Gm-Message-State: APjAAAWHTbrsq5poAuy8vJZUJ8OxhcLCzTEBxyGYe6nke3gmx5OZ/SWt lnNsd7wqUB8cKkJs9rbvF/cD3PSO1outXsQaYMUHXA== X-Received: by 2002:a1f:b0b:: with SMTP id 11mr6742950vkl.64.1561479415224; Tue, 25 Jun 2019 09:16:55 -0700 (PDT) MIME-Version: 1.0 References: <1561058881-9814-1-git-send-email-cai@lca.pw> <201906201812.8B49A36@keescook> <201906201818.6C90BC875@keescook> <1561121745.5154.37.camel@lca.pw> In-Reply-To: <1561121745.5154.37.camel@lca.pw> From: Alexander Potapenko Date: Tue, 25 Jun 2019 18:16:43 +0200 Message-ID: Subject: Re: [PATCH -next] slub: play init_on_free=1 well with SLAB_RED_ZONE To: Qian Cai Cc: Kees Cook , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 2:55 PM Qian Cai wrote: > > On Thu, 2019-06-20 at 18:19 -0700, Kees Cook wrote: > > On Thu, Jun 20, 2019 at 06:14:33PM -0700, Kees Cook wrote: > > > On Thu, Jun 20, 2019 at 03:28:01PM -0400, Qian Cai wrote: > > > > diff --git a/mm/slub.c b/mm/slub.c > > > > index a384228ff6d3..787971d4fa36 100644 > > > > --- a/mm/slub.c > > > > +++ b/mm/slub.c > > > > @@ -1437,7 +1437,7 @@ static inline bool slab_free_freelist_hook(st= ruct > > > > kmem_cache *s, > > > > do { > > > > object =3D next; > > > > next =3D get_freepointer(s, object); > > > > - memset(object, 0, s->size); > > > > + memset(object, 0, s->object_size); > > > > > > I think this should be more dynamic -- we _do_ want to wipe all > > > of object_size in the case where it's just alignment and padding > > > adjustments. If redzones are enabled, let's remove that portion only. > > > > (Sorry, I meant: all of object's "size", not object_size.) > > > > I suppose Alexander is going to revise the series anyway, so he can proba= bly > take care of the issue here in the new version as well. Something like th= is, > > memset(object, 0, s->object_size); > memset(object, 0, s->size - s->inuse); Looks like we also need to account for the redzone size. I'm testing the fix right now. -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg