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=-2.4 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,USER_AGENT_SANE_1 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 3899AC54FD0 for ; Mon, 27 Apr 2020 13:18:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D556B2064C for ; Mon, 27 Apr 2020 13:18:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iV8L8OXw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D556B2064C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 273158E0005; Mon, 27 Apr 2020 09:18:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 222D48E0001; Mon, 27 Apr 2020 09:18:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1123D8E0005; Mon, 27 Apr 2020 09:18:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id EE9098E0001 for ; Mon, 27 Apr 2020 09:18:55 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B344752CE for ; Mon, 27 Apr 2020 13:18:55 +0000 (UTC) X-FDA: 76753690230.24.self93_4de81aadf7624 X-HE-Tag: self93_4de81aadf7624 X-Filterd-Recvd-Size: 3458 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Mon, 27 Apr 2020 13:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587993534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eMggmePdezXBpkt3EQMsDMNJymVegCMfPLGhSAkJGro=; b=iV8L8OXwv8iyrOu3AzdKOHegavqZYejCFE344e0HcsDlvSBgGwvCk3oSiSTGhXKo6bqGbf pT9PYtcGzBSh21v0zvyvM/3dHaDlOEX7bbkDe1eMGYJ65KU8UfyebmsqhvV1Npxpsp3yiy tuti20tAzyMYkHb0M88TRryAmhmtUHs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-0sGGArDHPwCdsY9wqytrng-1; Mon, 27 Apr 2020 09:18:50 -0400 X-MC-Unique: 0sGGArDHPwCdsY9wqytrng-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5BC6100CC9D; Mon, 27 Apr 2020 13:18:37 +0000 (UTC) Received: from llong.remote.csb (ovpn-118-57.rdu2.redhat.com [10.10.118.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFE3419697; Mon, 27 Apr 2020 13:18:35 +0000 (UTC) Subject: Re: [PATCH] mm/slub: Fix incorrect checkings of s->offset To: Matthew Wilcox Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Kees Cook , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Changbin Du References: <20200427020212.5222-1-longman@redhat.com> <20200427123814.GE29705@bombadil.infradead.org> From: Waiman Long Organization: Red Hat Message-ID: <891a7635-9074-d320-9571-74f584401f01@redhat.com> Date: Mon, 27 Apr 2020 09:18:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200427123814.GE29705@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 4/27/20 8:38 AM, Matthew Wilcox wrote: > On Sun, Apr 26, 2020 at 10:02:12PM -0400, Waiman Long wrote: >> In a couple of places in the slub memory allocator, the code uses >> "s->offset" as a check to see if the free pointer is put right after the >> object. That check is no longer true with commit 3202fa62fb43 ("slub: >> relocate freelist pointer to middle of object"). >> >> As a result, echoing "1" into the validate sysfs file, e.g. of dentry, >> may cause a bunch of "Freepointer corrupt" error reports to appear with >> the system in panic afterwards. >> >> To fix it, use the check "s->offset == s->inuse" instead. > I think a little refactoring would make this more clear. > > unsigned int track_offset(const struct kmem_cache *s) > { > return s->inuse + (s->offset == s->inuse) ? sizeof(void *) : 0; > } Yes, that was what I am thinking of doing in v2. Thanks, Longman