Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5223262yba; Mon, 13 May 2019 07:24:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYUy8sYEyC+EWHDiw21LFkb4VDVeCVbBVV9kbnLOofFE44aXRF3BTTHEIVTVXJGRB2653J X-Received: by 2002:a62:164f:: with SMTP id 76mr34052785pfw.172.1557757454119; Mon, 13 May 2019 07:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557757454; cv=none; d=google.com; s=arc-20160816; b=Mn7hJfXY+8O/2tugHdUBO1Twnv9Wu8+lUmemRXB2FUnwl6TIcchEiy6jXJxU1/yJyI V40sXTdCijrqrBRVM2odL9Xgutc4iEeOv9N7E1r64+JZrejWf0YcXV3h5eUyFDqOOvTQ K/10rj9MvHGrGQccS0PJ0JmbcEEqnLeIiXpvIhU1Yk+gPM2dV0S5CIrhQcl1+o3dnQ5C hOeSEso8fJ/V178RDQG+jmuZIRS1YhRWbG/PxATx7ne/qe1iff6OHlB0IfX5VzVfRFzJ DTE3GVvibQ61xV0YTWO2cYMPU/RpX+NdNZuK8JVIgbf/0+/E/B+VPmbfI7LuKG3fTQtX 8k1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=awWr7CqE/VI7koIkZm/vLnS/8LIohJ8DzEhbOAp8yVw=; b=vTVHQ8ytSz4JYsBQ1/udR81gFhGV9ZUPNT4OyF4RfMV30w3z1rg6DtETD/aQk+hISV WIkhfDY1tO3+RgBPrAnPmQMZawPSg0q7VSb6CibWxpweumiFHHt1AphAMXWVnY6v5LxP q0CyZZVTrUSj7cN0/l9Dph+uybHYGapkKwZZpkLeaVsjapUNrH26VvEIydluXPsxjepJ 5u/xGyrt9d8gT8afvQ8DhHGgGID4f5OGjg5tyY7rz9z7wKR768oLYfdAQ7maYWijksen UZml41lxNfLGeWG3L39k15xSjZ/sA2T/BdW8ui5UV1Q+aFKBmhneCAp+ByL55H0s7DQP k+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YhJhEZZF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si15424865pgp.587.2019.05.13.07.23.57; Mon, 13 May 2019 07:24:14 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=YhJhEZZF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730167AbfEMOTj (ORCPT + 99 others); Mon, 13 May 2019 10:19:39 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38991 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728867AbfEMOTj (ORCPT ); Mon, 13 May 2019 10:19:39 -0400 Received: by mail-pf1-f196.google.com with SMTP id z26so7302070pfg.6 for ; Mon, 13 May 2019 07:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=awWr7CqE/VI7koIkZm/vLnS/8LIohJ8DzEhbOAp8yVw=; b=YhJhEZZFYzK8XrLCBR7QP0KcHYkAuOejGc2vAR+p/yDUiI91M/U/3U6IMsgfeHDpC5 lGb5YJw1eKXj9ujYsOZAcoPWhDZh5rL/TwHHAnbaTHC1ai7zzyoQlgD8Ot9oUaBVwQwh bvWq89sDRgn8BzFN11K90Ihj/6Pv/HaI9jfZo0JLcC7RKDqTBaBddjcV07UDs5HX7HH+ q+UdWb1tSqk3J71c9RnSuWdR+aOiUDrY3HURn9p0PBvnZlnsf9Cj8NRxr9RDqXAV7XgO kwnVdxFi4YPVsdF09GWLheBH12yz+7Wrd4IRRcCc6tueU6F16tVSse9GbLefeY97/aAk Pc+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=awWr7CqE/VI7koIkZm/vLnS/8LIohJ8DzEhbOAp8yVw=; b=kcOeOFJFIqjAqrMlBc5K3K2Uv1sJPTDvsIaqKFQLwCfX0HL/m537wG+4snineRrTWc 9eJHJa8CNjf6jUAbgZgJcknT2flXb1/GHvwQdY9ZrI+RNakP8giRrSlFQ9bYvQa1xg22 BgVUMdPNDYoCJJhMfFrInL5ApM4oWDBiHi9flguwYhNW/kEsGGPuP6YuK9qC/UvN210j p/oNneCV8vo6yG4Ew9SsToyU1LjlR0cKhX8BrRwrzJqA0pVk9r+OAPiDkX7IlZmoGQx7 lJdLtxOonjEFstpZG8d0dTenc8wANc4hXd41j5/fmkPm0zKsWG30lDlH+3W2qA2MkNwQ om6g== X-Gm-Message-State: APjAAAXKh+VXETkc1TmXC543NDra95Z6uclQ2wN+oaLfZoHh1Zrtxk1g dqvb3M7dAo9aspECM+F1aodbRhrK0Ww= X-Received: by 2002:a65:6559:: with SMTP id a25mr7534897pgw.33.1557757178744; Mon, 13 May 2019 07:19:38 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id p2sm16907604pgd.63.2019.05.13.07.19.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 07:19:38 -0700 (PDT) Date: Mon, 13 May 2019 22:18:31 +0800 From: Gen Zhang To: cl@linux.com, penberg@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [Patch] slub: Fix a missing-check bug in mm/slub.c file of Linux 5.1.1 Message-ID: <20190513141831.GA9502@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pointer s is allocated with kmem_cache_zalloc(). And s is used in the follwoing codes. However, when kmem_cache_zalloc fails, using s will cause null pointer dereference and the kernel will go wrong. Thus we check whether the kmem_cache_zalloc fails. Signed-off-by: Gen Zhang --- --- mm/slub.c +++ mm/slub.c @@ -4201,6 +4201,8 @@ static struct kmem_cache * __init bootst { int node; struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT); + if (!s) + return ERR_PTR(-ENOMEM); struct kmem_cache_node *n; memcpy(s, static_cache, kmem_cache->object_size); ---