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=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 7A2EFC433DF for ; Fri, 14 Aug 2020 19:43:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 212CE20771 for ; Fri, 14 Aug 2020 19:43:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MjWbKYfR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 212CE20771 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9DA696B000A; Fri, 14 Aug 2020 15:43:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 963A46B000C; Fri, 14 Aug 2020 15:43:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82B7F6B000D; Fri, 14 Aug 2020 15:43:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 684E96B000A for ; Fri, 14 Aug 2020 15:43:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 235E1758D for ; Fri, 14 Aug 2020 19:43:30 +0000 (UTC) X-FDA: 77150198580.04.boys85_590997826fff Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id EC59880142E5 for ; Fri, 14 Aug 2020 19:43:29 +0000 (UTC) X-HE-Tag: boys85_590997826fff X-Filterd-Recvd-Size: 6220 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Aug 2020 19:43:28 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07EJh8sL074634; Fri, 14 Aug 2020 19:43:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=SwHfYaaNmDMFFSwAZIoB8OOdCgTGZkhKQNO1QCQNdrY=; b=MjWbKYfR+HXY70mJ3a2m4Y7w4XzU8Dy9964Ak1VpzBEpwpENuw4v/IGnriaU04v0ShJu pznO3DdPRrBvf7iRswTASLNKLrnea7lsX2WcOAHGM/xuQwr4nm0YIn+gFigMDNhqQF90 k00dKCjcmzOvFIZ7YMGI8RXFnhz/OMCT1G3bJPvNjuuXBSsjkYkjdyqCbBX8qUA6T9ju NRMZ2MZ7Xve5YvoLpGaUaDcGJOVGy+vIkTYbwHZVIT3cKCXVosYuSbvcQroSB+O5Q4g6 CzNEO9tWOoJRS/9/k7Ufma7ql3Dc0l2yIShwW372xGxO2s8BAz2Do7GwdiGsbiRptfPL 8g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 32wvp11ctg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 14 Aug 2020 19:43:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07EJbjV3138011; Fri, 14 Aug 2020 19:43:19 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 32wvqjhh6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Aug 2020 19:43:18 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07EJhFOR030753; Fri, 14 Aug 2020 19:43:15 GMT Received: from [10.159.235.234] (/10.159.235.234) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Aug 2020 19:43:15 +0000 Subject: Re: [PATCH] mm: slub: fix conversion of freelist_corrupted() To: Eugeniu Rosca Cc: Andrew Morton , linux-mm@kvack.org, stable@vger.kernel.org, Eugeniu Rosca References: <20200811124656.10308-1-erosca@de.adit-jv.com> <20200814074644.GA7943@lxhi-065.adit-jv.com> From: Dongli Zhang Message-ID: Date: Fri, 14 Aug 2020 12:43:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200814074644.GA7943@lxhi-065.adit-jv.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9713 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008140146 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9713 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 impostorscore=0 adultscore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008140146 X-Rspamd-Queue-Id: EC59880142E5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 8/14/20 12:46 AM, Eugeniu Rosca wrote: > Hello Dongli, > > On Thu, Aug 13, 2020 at 11:57:51PM -0700, Dongli Zhang wrote: >> On 8/11/20 5:46 AM, Eugeniu Rosca wrote: >>> Commit 52f23478081ae0 ("mm/slub.c: fix corrupted freechain in >>> deactivate_slab()") suffered an update when picked up from LKML [1]. >>> >>> Specifically, relocating 'freelist = NULL' into 'freelist_corrupted()' >>> created a no-op statement. Fix it by sticking to the behavior intended >>> in the original patch [1]. Prefer the lowest-line-count solution. >>> >>> [1] https://urldefense.com/v3/__https://lore.kernel.org/linux-mm/20200331031450.12182-1-dongli.zhang@oracle.com/__;!!GqivPVa7Brio!LkxH4qJ3WzKnO_nmONLWV-HAougEaefnp8UnI6qC_8j0SS9_9fkO6bOe68flixlQzx8$ >>> >>> Fixes: 52f23478081ae0 ("mm/slub.c: fix corrupted freechain in deactivate_slab()") >>> Cc: Andrew Morton >>> Cc: Dongli Zhang >>> Cc: >>> Signed-off-by: Eugeniu Rosca >>> --- >>> mm/slub.c | 5 +++-- >>> 1 file changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/mm/slub.c b/mm/slub.c >>> index 68c02b2eecd9..9a3e963b02a3 100644 >>> --- a/mm/slub.c >>> +++ b/mm/slub.c >>> @@ -677,7 +677,6 @@ static bool freelist_corrupted(struct kmem_cache *s, struct page *page, >>> if ((s->flags & SLAB_CONSISTENCY_CHECKS) && >>> !check_valid_pointer(s, page, nextfree)) { >>> object_err(s, page, freelist, "Freechain corrupt"); >>> - freelist = NULL; >>> slab_fix(s, "Isolate corrupted freechain"); >>> return true; >>> } >>> @@ -2184,8 +2183,10 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page, >>> * 'freelist' is already corrupted. So isolate all objects >>> * starting at 'freelist'. >>> */ >>> - if (freelist_corrupted(s, page, freelist, nextfree)) >>> + if (freelist_corrupted(s, page, freelist, nextfree)) { >>> + freelist = NULL; >> >> This is good to me. >> >> However, this would confuse people when CONFIG_SLUB_DEBUG is not defined. >> >> While reading the source code, people may be curious why to reset freelist when >> CONFIG_SLUB_DEBUG is even not defined. > > This is a fair point. To address it, the `freelist = NULL` assignment > should be then moved into the body of freelist_corrupted(). If no > concerns on that, I will soon push a v2 implementing this proposal. > I do have have concern with that if that can make both of static analysis tool and the people reading code happy :) Thank you very much! Dongli Zhang