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=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 0AA50C54FD0 for ; Mon, 27 Apr 2020 16:10:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6943205C9 for ; Mon, 27 Apr 2020 16:10:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6943205C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F10C48E0005; Mon, 27 Apr 2020 12:10:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC1388E0001; Mon, 27 Apr 2020 12:10:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD76A8E0005; Mon, 27 Apr 2020 12:10:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id C35A38E0001 for ; Mon, 27 Apr 2020 12:10:32 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8357852D9 for ; Mon, 27 Apr 2020 16:10:32 +0000 (UTC) X-FDA: 76754122704.07.quiet83_7917d0d830938 X-HE-Tag: quiet83_7917d0d830938 X-Filterd-Recvd-Size: 2415 Received: from gentwo.org (gentwo.org [3.19.106.255]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 27 Apr 2020 16:10:31 +0000 (UTC) Received: by gentwo.org (Postfix, from userid 1002) id 82DFF3F4ED; Mon, 27 Apr 2020 16:10:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id 81ACC3E8A0; Mon, 27 Apr 2020 16:10:31 +0000 (UTC) Date: Mon, 27 Apr 2020 16:10:31 +0000 (UTC) From: Christopher Lameter X-X-Sender: cl@www.lameter.com To: Waiman Long cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Changbin Du , Matthew Wilcox Subject: Re: [PATCH v2] mm/slub: Fix incorrect interpretation of s->offset In-Reply-To: <20200427140822.18619-1-longman@redhat.com> Message-ID: References: <20200427140822.18619-1-longman@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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, 27 Apr 2020, Waiman Long wrote: > > To fix it, use the check "s->offset == s->inuse" in the new helper > function freeptr_after_object() instead. Also add another helper function > get_info_end() to return the end of info block (inuse + free pointer > if not overlapping with object). > > Fixes: 3202fa62fb43 ("slub: relocate freelist pointer to middle of object") > Signed-off-by: Waiman Long > --- > mm/slub.c | 37 ++++++++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 15 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 0e736d66bb42..68f1b4b1c309 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -551,15 +551,29 @@ static void print_section(char *level, char *text, u8 *addr, > metadata_access_disable(); > } > > +static inline bool freeptr_after_object(struct kmem_cache *s) bool freeptr_outside_of_object()? > +{ > + return s->offset == s->inuse; s->offset >= s->inuse? There may be a redzone after the object. > +static inline unsigned int get_info_end(struct kmem_cache *s) static inline track_offset()?