Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5286878imu; Tue, 15 Jan 2019 14:54:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN5r4oZyDmK0kjg5Wx4WYG4l4k3ppR6VQT9Ul6FuGrgXjQGG7L59yImfp7ttTA9ra0B0ucPK X-Received: by 2002:a17:902:720c:: with SMTP id ba12mr6548793plb.79.1547592862718; Tue, 15 Jan 2019 14:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547592862; cv=none; d=google.com; s=arc-20160816; b=ClZmbyZa5xHaNCduIiEqh0F1MNu1BrG4RRSX8f+Aopn4DwpsCd2+KGbTG+PMjzQ0yV VdXDU0CG3tKQL7gC6W87wRxZ5CsPY/OKlBO1Q6kWrgf6KIub+lf3sNrQjeufYEB+L6vb llmJzBYAnuF7sc8DPKTubYd8Ca2Y+flO8vaVcMZDAnXBSVFDUMN/y+GqW8oH6/3Gv6Fv SSruoI9G7LuIO/P3bMOH9033d5jx6rxrkxTxcSpjJ7Z7j6N7RRSi1pX/MCoX11mKNQdX J0GoPdb8IAWDMryazBXVtY07oUwp7FZXV/bRPAPv/ovtAxQ5dYGKWgKsmG260JFxTzA0 BZJw== 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=kc+NDcnl0cuopOOo8u2rSycWlQTa/VjSIrpF5AnZRHU=; b=BTRMK5VrLwhZ7WsGMlliauwkNAmhOE+/cXgt2WTdQqovkyA2kAXjiDCcVAWOd89X+6 GpT643TylEVaM6J+KfsJRPjA2QR3+SIgan5eDi55ewxupsa7WkPOXBgL5UfxaWyUjmEf PTZf0uc2DIlQ7AOowwb/Hkl+tQBUYccNrv4cd1L0Xq3qv9Ocn6639icHLOuAGqzOUcnB nuZBYyrVyEyZ9a8DHGgAJDqQIvx4kZWGESSvw1FpeS1FCL3iIXNETmieGJdvbbeUTtWw vUhBUWtlAfwG28iNQM1BmoUmCmYRup11ijpbk/6EJIzpvxHz0eRgzJIUqtln2GtmJ1sH cPlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FQeKMflk; 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 o68si5023291pfo.140.2019.01.15.14.54.05; Tue, 15 Jan 2019 14:54:22 -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=@kernel.org header.s=default header.b=FQeKMflk; 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 S2387572AbfAOQof (ORCPT + 99 others); Tue, 15 Jan 2019 11:44:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:34130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387554AbfAOQob (ORCPT ); Tue, 15 Jan 2019 11:44:31 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 AF1CF2054F; Tue, 15 Jan 2019 16:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547570671; bh=K4cOjncYTKTtvOD3R1e2IyucTZmJQSqeDvj1+JzQ0Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQeKMflkIJwMzAJ94A8t1Tt1xidSHN0NovkGYlmULRkM8HA/I2FAAzP4XKchSqxNn bw/lC9RkTJzaB9zUHxHQV/7GtZAoHF2Kk2jShhpbIkg/RIR1ZAl+EVZHxkRE3rKQ6/ qxeu4hyYx44iXd5WzrytaoNPCMbMxmo5sKP7pmx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Lameter , syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com, Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Linus Torvalds Subject: [PATCH 4.20 28/57] slab: alien caches must not be initialized if the allocation of the alien cache failed Date: Tue, 15 Jan 2019 17:36:09 +0100 Message-Id: <20190115154912.258071083@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115154910.734892368@linuxfoundation.org> References: <20190115154910.734892368@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoph Lameter commit 09c2e76ed734a1d36470d257a778aaba28e86531 upstream. 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. Link: http://lkml.kernel.org/r/010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com Fixes: 49dfc304ba241 ("slab: use the lock on alien_cache, instead of the lock on array_cache") Fixes: c8522a3a5832b ("Slab: introduce alloc_alien") Signed-off-by: Christoph Lameter Reported-by: syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com Reviewed-by: Andrew Morton Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/slab.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/mm/slab.c +++ b/mm/slab.c @@ -679,8 +679,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; }