Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp324769pxk; Fri, 11 Sep 2020 07:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh0pe46OQXzz2fSiNWtxoKu9Xi3DnVznFYiqE2w5t5ZKPXfpGle/3b9+pTETffgcPUO94+ X-Received: by 2002:a17:906:faec:: with SMTP id lu44mr2371572ejb.527.1599836302698; Fri, 11 Sep 2020 07:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599836302; cv=none; d=google.com; s=arc-20160816; b=ABH/nb5uaza1MZ5CAkxOj3jQJaTR4S2BXFiw+IPGXZ5rOWYFmQ33X/FxrSX7Y+Qpag 2bXqjDwFqxMUzlkaMrPMqBxYjfNOAK916cIJaHW21qBW3Q6aDTrxc8JXt0WieTlfIewH L58DlI6uRPKQrXpCX/z7w+GC9ycip01k8IKhGNSeKqz8vLi+oE4RElayO4iUJNfS/EmG qXj0COHpfBGlBZf/Ay3ZL8eapqz9H3PXURfu0b8K8w53qHbV0VCTkZnVZ+TaK7X1lH8Z 382bU2epk0L+BFLRuzzXCbbDriVvHyfL5U3Gqo359hLC7S5sYQ3s1qCexBw32S9zaTlR 01kQ== 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=hL/waXezA6SS9Y53oPcG7BrFN3MbGLtFnmNQwNusjZw=; b=R55JvjUP+ceQC2c+prTkc6fvJWEcBEMxB3hECPXJuQWoF73nNYeo+YC4WZcq1ju0pa 5wnS7RP5rxDdaeHM15WZcWsB4Bc5MWwKzd6fGsVOvXvshIdAZHPsqYhW+6di24k4e1Bp iCZ6Ont/V2raZpjYK/uS9SW2qxOC2plCtVmFQnv9P+7urkwYVUjOfFEegDLlCbCdHutF eYncwO4rcPYbpfPrvl1bTCh4lhSm6oRfz3m0c9sur+tFZ5gF+5SXTStXkaiAYmx2rqHM bKDJvRBW8k51Hxnag3UADYqMKRP+dOAddZJnqsvrF717e3ugCDFXhSbEmr+8HhvdT6CA y6Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GYhfyos2; 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 d12si1522161edo.423.2020.09.11.07.57.59; Fri, 11 Sep 2020 07:58:22 -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=GYhfyos2; 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 S1726225AbgIKO4Z (ORCPT + 99 others); Fri, 11 Sep 2020 10:56:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:54388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgIKNCU (ORCPT ); Fri, 11 Sep 2020 09:02:20 -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 3EB1622243; Fri, 11 Sep 2020 12:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599829052; bh=msF5bf0BUlSzBRo/Fv0SbhSCTalssUiDIJoh9XsA56g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GYhfyos27EKkXpSwhMU9liHyRCOpWrJBTHwILYEIP+fAkFnKn6mRWhjBd8kozw0cp 3e3c1PzUncUJgTaXEDqnYLR7+Rx5Ncyy3xq+8prjrz4EYGqrRtfGNY4V+eM0Jum0kX qQfTzvBvDOMfwI3xj6NPtErGDGWhYspzc9BU2r00= 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 4.9 48/71] mm: slub: fix conversion of freelist_corrupted() Date: Fri, 11 Sep 2020 14:46:32 +0200 Message-Id: <20200911122507.315341477@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@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 @@ -625,12 +625,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; } @@ -1320,7 +1320,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; } @@ -2040,7 +2040,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 {