From patchwork Mon Feb 24 00:45:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 230576 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 6E5A2C35670 for ; Mon, 24 Feb 2020 00:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 441DE20880 for ; Mon, 24 Feb 2020 00:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582505103; bh=x4NRUEQT2b+6gUZ1mwOnv3jKroRBoj5tOM4zkVopOZQ=; h=Date:From:To:Subject:List-ID:From; b=TxmXmUTKkLtbtXnDbk6hG1panjWp/eZ4Hc3BiE32jONJRlv0Spyn1+mPKqonLSoge yfumGHffflKsgTwJykEMcRoqKr0DmNTjiMS/aEONrwORHev4NUNzUTk4Ee1FLaHN2I INAiHIoRDABuQILVN2pkoBY10bYq2vjip/QCq4ts= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727219AbgBXApC (ORCPT ); Sun, 23 Feb 2020 19:45:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:40232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727188AbgBXApC (ORCPT ); Sun, 23 Feb 2020 19:45:02 -0500 Received: from localhost.localdomain (c-71-198-47-131.hsd1.ca.comcast.net [71.198.47.131]) (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 A121D20836; Mon, 24 Feb 2020 00:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582505101; bh=x4NRUEQT2b+6gUZ1mwOnv3jKroRBoj5tOM4zkVopOZQ=; h=Date:From:To:Subject:From; b=XbFN9yovwaHN1oGyaqM2ZR+T3j3roJrL3TGBwxwyu4zaAFLvImUdGJGTTsdPacFIv K8bSrmuX23NtazRVcZdTzHiHNazydDGISg1tc4elYot4fNWWbaQUlKweq/ATzBevuy ml5poFBndoUbX/VQS+Yr7voy0sThDho2zyiR10E0= Date: Sun, 23 Feb 2020 16:45:01 -0800 From: akpm@linux-foundation.org To: dvyukov@google.com, glider@google.com, gregkh@linuxfoundation.org, jpoimboe@redhat.com, kstewart@linuxfoundation.org, matthias.bgg@gmail.com, mm-commits@vger.kernel.org, stable@vger.kernel.org, tglx@linutronix.de, walter-zh.wu@mediatek.com Subject: [merged] lib-stackdepot-fix-global-out-of-bounds-in-stack_slabs.patch removed from -mm tree Message-ID: <20200224004501.GAmhlki8G%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: lib/stackdepot.c: fix global out-of-bounds in stack_slabs has been removed from the -mm tree. Its filename was lib-stackdepot-fix-global-out-of-bounds-in-stack_slabs.patch This patch was dropped because it was merged into mainline or a subsystem tree ------------------------------------------------------ From: Alexander Potapenko Subject: 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 --- lib/stackdepot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/lib/stackdepot.c~lib-stackdepot-fix-global-out-of-bounds-in-stack_slabs +++ a/lib/stackdepot.c @@ -83,15 +83,19 @@ static bool init_stack_slab(void **preal 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; }