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 71B73C54FD0 for ; Mon, 27 Apr 2020 13:29:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2EC52206B9 for ; Mon, 27 Apr 2020 13:29:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RtX1Iyz0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EC52206B9 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 B44088E0005; Mon, 27 Apr 2020 09:29:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF4278E0001; Mon, 27 Apr 2020 09:29:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A098F8E0005; Mon, 27 Apr 2020 09:29:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 878CF8E0001 for ; Mon, 27 Apr 2020 09:29:51 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3FCBC2DFC for ; Mon, 27 Apr 2020 13:29:51 +0000 (UTC) X-FDA: 76753717782.08.news33_1bc6034e79e1a X-HE-Tag: news33_1bc6034e79e1a X-Filterd-Recvd-Size: 3724 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Mon, 27 Apr 2020 13:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587994190; 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=gS95wjKy60cEwsXFyEUIQThnhVIXKZuaJZ5nhfw8iW4=; b=RtX1Iyz0CpyMM0cXV4H2oRifzR3jor+HcCdNGgdeMQQt2PzH4mD2CwsCP/XCTv4XfHaEym 1nLmER/lwrHRemR9wamH21/XC/hO7natP5JQ5gUz1RuFs+EyYqldvNSEaOA5n3tueB3/iR Rqbc+fkVumFqnUixTvUXIJayUZFrhdk= 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-503-KzTyk5ORMKy8UcvAq6OMsw-1; Mon, 27 Apr 2020 09:29:46 -0400 X-MC-Unique: KzTyk5ORMKy8UcvAq6OMsw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8ACC0835B41; Mon, 27 Apr 2020 13:29:44 +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 35C1E50A9C; Mon, 27 Apr 2020 13:29:42 +0000 (UTC) Subject: Re: [PATCH] mm/slub: Fix incorrect checkings of s->offset From: Waiman Long 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> <891a7635-9074-d320-9571-74f584401f01@redhat.com> Organization: Red Hat Message-ID: Date: Mon, 27 Apr 2020 09:29:41 -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: <891a7635-9074-d320-9571-74f584401f01@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Content-Transfer-Encoding: quoted-printable 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 9:18 AM, Waiman Long wrote: > 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=20 >>> 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 wi= th >>> the system in panic afterwards. >>> >>> To fix it, use the check "s->offset =3D=3D s->inuse" instead. >> I think a little refactoring would make this more clear. >> >> unsigned int track_offset(const struct kmem_cache *s) >> { >> =C2=A0=C2=A0=C2=A0=C2=A0return s->inuse + (s->offset =3D=3D s->inuse) = ? sizeof(void *) : 0; >> } > > Yes, that was what I am thinking of doing in v2.=20 BTW, "+" has a higher priority than "?:". So we need a parenthesis=20 around "?:". Cheers, Longman