Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4158132pxk; Tue, 8 Sep 2020 12:09:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs/0l9rkDwh4LzdFm4tesb9IIJ69VXE5Z3WriCRYK61lNnm5jjZhthgek0Jwup5C5560Kk X-Received: by 2002:a17:906:7fca:: with SMTP id r10mr27213602ejs.534.1599592182188; Tue, 08 Sep 2020 12:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592182; cv=none; d=google.com; s=arc-20160816; b=l0SBjnnbuysR6nwvJquqxMLaGceJimDJigUCL2vdfsczCdG+HyRxI7gn5/rfCJ/6Bj FbGlZmq53iZt9ZkLJG49tEq8Kt/d30eu8v/BXDQ/42SmyOyofa5JDX3AgfhQTsuCyhbG q2fZF1FjRKicw1u4/r0khh6RegGPZvXGRw5bDxLySpcrdLDrnhcHJp6Gzu9lWzbLW+g7 ZLTSpD4Xf8GY1e8haYKnQELesaWTSqDaPR9U+8p8eDtkcA5c15vlQmLsM914v9U8WklQ FGXw/djm50KR+KIA5jP6cxNMgmVzv8Z+rufVPaMl6Jc50ocy2EOZU1/CRuK93BmOXRAv oVPA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VPMm6oeJGtclTpumUeB7oQHpf8Ea5bHjcX7JwXCvf6c=; b=npxP5jayW47tdtkUZM9icpz5DKeTID+rIKJy5jMAn3qdlycidJWuofydFsfYahsAE2 Bu+0x6yYZqAl8NmVjcVLnRCnX/2aWW0EypREEfXvNw/TjvhPemh+Osgef9o8eoMIUPUH m9qJMDfcm9WNUncG8+afDDAEdHa/enACBNSC1ivK3gBlZtqkOnv4Peu5a7AIEsw/FY+1 AMAaIaPiw2YhROFTayX4CnEI810gkTIynZTnYrOHZaWvpFIhQmLltwnlqGWt9AqkduiO Sd6xWSIQxPE2hXFxWgSxqZl3tMzJYFn9w76KIVTvXTsoX5G1xMfnmE0c6PS1kvrkotox i58A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rNEacWKB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co28si12446695edb.562.2020.09.08.12.09.19; Tue, 08 Sep 2020 12:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rNEacWKB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731560AbgIHTIH (ORCPT + 99 others); Tue, 8 Sep 2020 15:08:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:52180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731248AbgIHQG6 (ORCPT ); Tue, 8 Sep 2020 12:06:58 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61FDB23DC2; Tue, 8 Sep 2020 15:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599580000; bh=dj+JlPWcOYv/4IzGZrhVLfRcyUyafVH/z9iYdjU8iy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNEacWKBaMj5R5gWbHb9RFXWQwBzC0vWc9qtyC8ohFQHOwLsvQn1evEltBKDL+zIi sGTdT3UkbDZ5ZW4V/rIdetcHRLoLpA9PUy3kMWLDcRn4PwLNhEaHga0QFsmfxHPvY3 ofNxKjY4Y/EB268bb/xzTPpbRpEV74KjfSXgNjLc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugeniu Rosca , Andrew Morton , Dongli Zhang , Joe Jin , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Linus Torvalds Subject: [PATCH 5.4 120/129] mm: slub: fix conversion of freelist_corrupted() Date: Tue, 8 Sep 2020 17:26:01 +0200 Message-Id: <20200908152235.845154178@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eugeniu Rosca commit dc07a728d49cf025f5da2c31add438d839d076c0 upstream. 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]. In addition, make freelist_corrupted() immune to passing NULL instead of &freelist. The issue has been spotted via static analysis and code review. [1] https://lore.kernel.org/linux-mm/20200331031450.12182-1-dongli.zhang@oracle.com/ Fixes: 52f23478081ae0 ("mm/slub.c: fix corrupted freechain in deactivate_slab()") Signed-off-by: Eugeniu Rosca Signed-off-by: Andrew Morton Cc: Dongli Zhang Cc: Joe Jin Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Link: https://lkml.kernel.org/r/20200824130643.10291-1-erosca@de.adit-jv.com Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/slub.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/mm/slub.c +++ b/mm/slub.c @@ -645,12 +645,12 @@ static void slab_fix(struct kmem_cache * } static bool freelist_corrupted(struct kmem_cache *s, struct page *page, - void *freelist, void *nextfree) + void **freelist, void *nextfree) { if ((s->flags & SLAB_CONSISTENCY_CHECKS) && - !check_valid_pointer(s, page, nextfree)) { - object_err(s, page, freelist, "Freechain corrupt"); - freelist = NULL; + !check_valid_pointer(s, page, nextfree) && freelist) { + object_err(s, page, *freelist, "Freechain corrupt"); + *freelist = NULL; slab_fix(s, "Isolate corrupted freechain"); return true; } @@ -1394,7 +1394,7 @@ static inline void dec_slabs_node(struct int objects) {} static bool freelist_corrupted(struct kmem_cache *s, struct page *page, - void *freelist, void *nextfree) + void **freelist, void *nextfree) { return false; } @@ -2086,7 +2086,7 @@ static void deactivate_slab(struct kmem_ * '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)) break; do {