Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp455166imu; Wed, 2 Jan 2019 09:46:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XGvEx+xcRHrP3xV+f6d8khiJOfJdnh8OriPle/85AXMB7IsKPqnO03NMg3/7YWS1KUeKJi X-Received: by 2002:a62:1212:: with SMTP id a18mr46573415pfj.217.1546451212956; Wed, 02 Jan 2019 09:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546451212; cv=none; d=google.com; s=arc-20160816; b=BbkIbj/S7IdJTaiKQpUrXrG0qZmT9HJwx88ABZ9dcSFlTPh/DknU9QHsXWoXKp+WwY zZ0pCZhLQoSXPD69jmMkyHBHSolIOXxNYPsH4x1K+VzDgPZ8nkUMAs5bLMxw33EmH+YL 1YQknJRZ5PSJAGfF3Mf826NNqM48rAqVyR4WM8sPxvpv2XHy40IrM6TML2jNmdbhXKog 7driDrd2YW06JUBneFfdL2YR6UMZT5q+636oaGyLGXISZUuQpyS9QAsrLCDpvnICRxAW m4mdcB/iRO7DZEy3WUQ4K7wzlbWyDHAqJoL+HZ05v9S8xJKc/6zZR4qLdM9CeYWBnSho GTZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=rEkE6Caj2p88PSsCUc8oU/jhCd4SVEFpbmMGCBsImRk=; b=K6KkZ2sqdN6f9ensQ9IZO2R0xbRomZHbetuwnDIXU87H1CDMu59fKs3FFN9TTpZT3Q JXFD080FrLwTHJ3CEvkIaNF+HExgizVvydaaieaVFNLdBZZ7BmkO1SLDK76m4d9dUIsn uH2miSTDmMUAnKgnrcw/eleNeM959dNhpeEIF/3+S9uJk6VWZSyuf6JVjPNKbnRs6VfB I9Y8lpYVueLA8MGEBMoU68NpyzqVkgT+VhiYVnguVdkhaEfXfFoE7Ex/H8yM7wkkW/01 5q916tjJr7cEiXd0QfJ2V0DdhVAuBQDoDctVuosIMA9wOHv6ETCuLrQKhNgCn2HycHJe Ccfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=E+ay9z6r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si47840964plp.215.2019.01.02.09.46.18; Wed, 02 Jan 2019 09:46:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=E+ay9z6r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730242AbfABPvN (ORCPT + 99 others); Wed, 2 Jan 2019 10:51:13 -0500 Received: from a9-30.smtp-out.amazonses.com ([54.240.9.30]:50846 "EHLO a9-30.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbfABPvN (ORCPT ); Wed, 2 Jan 2019 10:51:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1546444272; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=QrUfP2uIZHKXzgqGsLcs1smTdC8d+WI0qnJh55aBLBQ=; b=E+ay9z6r2ElMB3D6TaKMceeFTQChZVSdJ/tI015jziOWfgTHqD8pIvknKXq8bhCO OzAN+3av/7KCiiN5Ms+prXwen9ym67IxOnCFTJDogUhCVKdgPN6nSpFyCZSNbUWeVxF wQl+HZo6yvoqyQx5pu0jR4MFs4/N5YaPY/Rfulac= Date: Wed, 2 Jan 2019 15:51:12 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Dmitry Vyukov cc: syzbot , Dominique Martinet , David Miller , Eric Van Hensbergen , LKML , Latchesar Ionkov , netdev , syzkaller-bugs , v9fs-developer@lists.sourceforge.net, Linux-MM , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Subject: Re: BUG: unable to handle kernel NULL pointer dereference in setup_kmem_cache_node In-Reply-To: Message-ID: <010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com> References: <0000000000000f35c6057e780d36@google.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2019.01.02-54.240.9.30 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2 Jan 2019, Dmitry Vyukov wrote: > Am I missing something or __alloc_alien_cache misses check for > kmalloc_node result? > > static struct alien_cache *__alloc_alien_cache(int node, int entries, > int batch, gfp_t gfp) > { > size_t memsize = sizeof(void *) * entries + sizeof(struct alien_cache); > struct alien_cache *alc = NULL; > > alc = kmalloc_node(memsize, gfp, node); > init_arraycache(&alc->ac, entries, batch); > spin_lock_init(&alc->lock); > return alc; > } > True _alloc_alien_cache() needs to check for NULL From: Christoph Lameter Subject: slab: Alien caches must not be initialized if the allocation of the alien cache failed Callers of __alloc_alien() check for NULL. We must do the same check in __alloc_alien_cache to avoid NULL pointer dereferences on allocation failures. Signed-off-by: Christoph Lameter Index: linux/mm/slab.c =================================================================== --- linux.orig/mm/slab.c +++ linux/mm/slab.c @@ -666,8 +666,10 @@ static struct alien_cache *__alloc_alien struct alien_cache *alc = NULL; alc = kmalloc_node(memsize, gfp, node); - init_arraycache(&alc->ac, entries, batch); - spin_lock_init(&alc->lock); + if (alc) { + init_arraycache(&alc->ac, entries, batch); + spin_lock_init(&alc->lock); + } return alc; }