Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2510780imm; Mon, 24 Sep 2018 05:41:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ3LKNqgcjVFU32MT+3HGyiSlZxZMrmtup3RhEB+kD+i9pbJgAkRWupGywjEKwL6L4RoAxp X-Received: by 2002:aa7:850b:: with SMTP id v11-v6mr10304638pfn.165.1537792916464; Mon, 24 Sep 2018 05:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792916; cv=none; d=google.com; s=arc-20160816; b=dp9TSf3+nE/KF5YY7ZOi9304AdCCVhHO+4BScOIXy9RLTYn6Pho9aunIDJQvIo89k8 WK05BTx3/f/EZJbAiswP7q2q2avcUsGBWAXfO+bwohGzs31/R3ONVwABfqE/BQx+S4ZP 9DBWlm4lRocNy2GGm6JBWyYyGDpjWOQFAquAX8ACWvVtqVCPsRrTe26mVdpg090xZeJf T+bk4SVEoI3gK0c5oGUPSkYdRp2Oc1/UtYYLzWPlbHwcru8Au0ITJSXwvRFrpqZKc263 eLx1P/9GssXGIZX41juU5QRY4pq9b1oLpsSVADoRb1eG2tchVeQTrnJySzhcBk1Oq0vt Z34Q== 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; bh=PiZnoztzoAAH3nwnDHW4YO8+CW21rnmCXJ06hWg8Sb4=; b=AI86QjBAXV5W4flzgU7cMJU8HiFA3+L4+JcRNPIjYhSGT9jIyXx3U8lm55/5+5rdmD 8O+t/IHK+RxM6j33ZtNxJ51bAp8jbRz396hP6S5Nsw+XeN3JouSdDZYAYgW0T3X/grAj ZhkuARGgMruunzeUa6DCHiELbdJtUHwdOYwWljJMMTr9jVw9VeAvFOVdPJ1LahLYQEbv aEI0uxMGeLPjLsIzW+2xbkwUWWtZNXSOcArHJy083op3VM6sQQdRE5irmk3sPeKJ6RvF CnHWBoQ8RUNL7e2M4ZLvluK4w8AAqxPLPGGVf8S7ZvP3O7xkxit/hRt04Y7GwsUiuJmH LRYA== ARC-Authentication-Results: i=1; mx.google.com; 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 x11-v6si6426658pgk.81.2018.09.24.05.41.41; Mon, 24 Sep 2018 05:41:56 -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; 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 S2388589AbeIXSmW (ORCPT + 99 others); Mon, 24 Sep 2018 14:42:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58968 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733259AbeIXSmV (ORCPT ); Mon, 24 Sep 2018 14:42:21 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6D686109B; Mon, 24 Sep 2018 12:40:23 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , James Morris , Sasha Levin Subject: [PATCH 4.18 157/235] security: check for kstrdup() failure in lsm_append() Date: Mon, 24 Sep 2018 13:52:23 +0200 Message-Id: <20180924113120.948578853@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers [ Upstream commit 87ea58433208d17295e200d56be5e2a4fe4ce7d6 ] lsm_append() should return -ENOMEM if memory allocation failed. Fixes: d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm") Signed-off-by: Eric Biggers Signed-off-by: James Morris Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- security/security.c | 2 ++ 1 file changed, 2 insertions(+) --- a/security/security.c +++ b/security/security.c @@ -118,6 +118,8 @@ static int lsm_append(char *new, char ** if (*result == NULL) { *result = kstrdup(new, GFP_KERNEL); + if (*result == NULL) + return -ENOMEM; } else { /* Check if it is the last registered name */ if (match_last_lsm(*result, new))