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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 15154C4BA0B for ; Wed, 26 Feb 2020 10:56:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E144524684 for ; Wed, 26 Feb 2020 10:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582714578; bh=GKKjooyj9O8BwYOLVIQv+4nxEpETbqmXlXzN3S73g6E=; h=Subject:To:Cc:From:Date:List-ID:From; b=fzqTKOHtCTUgsn1dav0w1BIyvulymZC1j7urIe38jrdhZrz8XHRFTYE+T+/4HwI3X XrLbeW2LLo37jsKnxBxAVNWb87Q/Fx+wLs+XHVAwfBywNVmQCpKfYpPJ6r/ZVrNPpc I05uzn5+12gJuDXcGvKfuQ8/8Fxe8DbzZpLmW0VY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbgBZK4R (ORCPT ); Wed, 26 Feb 2020 05:56:17 -0500 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:36989 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbgBZK4Q (ORCPT ); Wed, 26 Feb 2020 05:56:16 -0500 X-Greylist: delayed 329 seconds by postgrey-1.27 at vger.kernel.org; Wed, 26 Feb 2020 05:56:16 EST Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 1C9916EF; Wed, 26 Feb 2020 05:50:49 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 26 Feb 2020 05:50:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=liscf2 AgnAP4WeuGtNroeRo0qkTKZOFXGwE4JfrPDbs=; b=a/rfhZdJjBpG/gP3iR/ijo kEaAyjkiSY2HF1CTvv2z2TjIsgPP7wZHuoZTbxJHB1G0X3VAZXP7HuZFuyMgN3Y5 CapIlijPEPUKgaDvG0z1P946I+NlBTKVsCCAVKoW2vc00iCDdlgCBZhEh4WelDol gSlGM4ajkrnFlSBnDoLrBpx8sj331KAA67L4h/UUqFHUlIRn15ylm8fDsElfuptl lEb7eB4eXMvrEuA3JM+vXZxTQE8sjoTAfgDknbn3TlwC70S1k0toUolA9vGAJmVz joIAQayVJ20wrjuzNwqgWBoE+yeRZYbkIiYqkLEvgWxJEL2AuioQfb4VgcYSQ+jQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrleeggddvudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeekfedrkeeirdekledrud dtjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehg rhgvgheskhhrohgrhhdrtghomh X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 41163328005A; Wed, 26 Feb 2020 05:50:48 -0500 (EST) Subject: FAILED: patch "[PATCH] lib/stackdepot.c: fix global out-of-bounds in stack_slabs" failed to apply to 4.14-stable tree To: glider@google.com, akpm@linux-foundation.org, dvyukov@google.com, gregkh@linuxfoundation.org, jpoimboe@redhat.com, kstewart@linuxfoundation.org, matthias.bgg@gmail.com, stable@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, walter-zh.wu@mediatek.com Cc: From: Date: Wed, 26 Feb 2020 11:49:43 +0100 Message-ID: <1582714183119146@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.14-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 305e519ce48e935702c32241f07d393c3c8fed3e Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Thu, 20 Feb 2020 20:04:30 -0800 Subject: [PATCH] lib/stackdepot.c: fix global out-of-bounds in stack_slabs Walter Wu has reported a potential case in which init_stack_slab() is called after stack_slabs[STACK_ALLOC_MAX_SLABS - 1] has already been initialized. In that case init_stack_slab() will overwrite stack_slabs[STACK_ALLOC_MAX_SLABS], which may result in a memory corruption. Link: http://lkml.kernel.org/r/20200218102950.260263-1-glider@google.com Fixes: cd11016e5f521 ("mm, kasan: stackdepot implementation. Enable stackdepot for SLAB") Signed-off-by: Alexander Potapenko Reported-by: Walter Wu Cc: Dmitry Vyukov Cc: Matthias Brugger Cc: Thomas Gleixner Cc: Josh Poimboeuf Cc: Kate Stewart Cc: Greg Kroah-Hartman Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds diff --git a/lib/stackdepot.c b/lib/stackdepot.c index ed717dd08ff3..81c69c08d1d1 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -83,15 +83,19 @@ static bool init_stack_slab(void **prealloc) return true; if (stack_slabs[depot_index] == NULL) { stack_slabs[depot_index] = *prealloc; + *prealloc = NULL; } else { - stack_slabs[depot_index + 1] = *prealloc; + /* If this is the last depot slab, do not touch the next one. */ + if (depot_index + 1 < STACK_ALLOC_MAX_SLABS) { + stack_slabs[depot_index + 1] = *prealloc; + *prealloc = NULL; + } /* * This smp_store_release pairs with smp_load_acquire() from * |next_slab_inited| above and in stack_depot_save(). */ smp_store_release(&next_slab_inited, 1); } - *prealloc = NULL; return true; }