Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3162654imm; Tue, 29 May 2018 02:06:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZot253rpNB2z960yVmSVPaAbwkyTszlHH+TOjKNGW/p/w6nbgXdQc2LSCECqjfRqkYwRc0M X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr16453025plo.305.1527584808295; Tue, 29 May 2018 02:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527584808; cv=none; d=google.com; s=arc-20160816; b=c3Cw6bUX9pIxJZdnjPjiiWX2oC7mot+pU6hjmpqh+LjDE3qxmY1nw3BARfsQfOFReL su8Be9C9eydAEWajnDm5T1Gm0+AeIOCX/AAFKwDDcz2Xbq1TOofdaWNUkA58tmv/UzwB Zo6uDSOrcA6zyizDEpdaJn6p+DNSmFvR3pGlwHoHhTJs7tpeFVmRH3swaALxl/8OyJoZ mG3ger7A1qiApNE3BciciLdY7s+ELchzOaGaIeR1n7EiCxTl8cDBf5WE2xBKm6Qv6gGd P0SFfhKZGySx4Me1EeDKUk8mgRzMA4bxV7OlubLBznpqYpl1lOOs7oFsS1O8pfnMYRDA ac6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=F9UKTq4kdmVj8Zk3MLNIxCPiyvDm5zhzBnnQU0slMYc=; b=iKtIoZd9pwwTQs/hacny73DFu6Ips97PwrS1oHO0WsXqBb+qkMV2ITQ6xfaQBrYO8w pgQoi5fQNt6URrT54SY8iBMq17MxqBV5mTARQ4SzDUfwgbcB+Abbn2DJd9RjctRfFpFA ObCsNTJBeocvJf+jmnOz5sl5JYouqhhwjvjqDRs6CfyRm/Z0Zwtn9S9iRK2jem7I80g3 jAr4rNvmHS0AzgCFi6xQ1HdEGMr3MuoEQkj9uKo6SjAxybvHd74Vpy1POy9nqTcHowGK C5RNWRxS1UFUyNi70vldGrVPBrkuyS6SUBGcrDcikc0kBDLIjYPvwl9tpclzUwS0MKWZ XuOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Rlp13NGb; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si32879599pfe.214.2018.05.29.02.06.34; Tue, 29 May 2018 02:06:48 -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=@oracle.com header.s=corp-2017-10-26 header.b=Rlp13NGb; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932582AbeE2JFO (ORCPT + 99 others); Tue, 29 May 2018 05:05:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46842 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932288AbeE2JFL (ORCPT ); Tue, 29 May 2018 05:05:11 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4T94slJ148422; Tue, 29 May 2018 09:05:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=F9UKTq4kdmVj8Zk3MLNIxCPiyvDm5zhzBnnQU0slMYc=; b=Rlp13NGbtlhjeZZK0X24HiaGvN2EAPBxqCmDAL7mn0/neCzYIbyOkPcMi0ADFYVi1aBu yg3OF+En8HLUD6qoGcPmaszJFv3vfDrvaN2rKjDrHlkidwzCgiFV6FcOO8j/6Hw1yv/N H+cW3EFHg5EBCQiAc6PauNQFxKz76qbZFG8qxOYfnmd8WTdXE+vVDwg1rS0r4AySsPM/ rAQyZtFazSDIfg66lXHxwr8tF+LtzQ+SnYdbEBxKV/yWlZ54mCdSm1cJ6CzllXO9bWhI shFVSYWNPs7vXxT2Xm+ouFJ36SZUinc7gpPI0QKGmGLqDh8yNTSmDL31XzsBASB4DdgI Bw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2j7085068q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 May 2018 09:05:01 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4T951jw001329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 May 2018 09:05:01 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4T950VK005556; Tue, 29 May 2018 09:05:00 GMT Received: from mwanda (/197.157.0.20) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 May 2018 02:04:59 -0700 Date: Tue, 29 May 2018 12:05:04 +0300 From: Dan Carpenter To: Colin King Cc: Matthew Garrett , Mimi Zohar , James Morris , "Serge E . Hallyn" , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] EVM: Fix null dereference on xattr when xattr fails to allocate Message-ID: <20180529090504.6dpdadjyjxo45nu2@mwanda> References: <20180527225510.25612-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180527225510.25612-1-colin.king@canonical.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8907 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=580 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805290106 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Not really related to this patch except I was looking at the function: security/integrity/evm/evm_secfs.c 191 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_EVM_XATTR); 192 if (IS_ERR(ab)) 193 return PTR_ERR(ab); 194 195 xattr = kmalloc(sizeof(struct xattr_list), GFP_KERNEL); 196 if (!xattr) { 197 err = -ENOMEM; 198 goto out; 199 } 200 201 xattr->name = memdup_user_nul(buf, count); 202 if (IS_ERR(xattr->name)) { 203 err = PTR_ERR(xattr->name); 204 xattr->name = NULL; 205 goto out; 206 } 207 208 /* Remove any trailing newline */ 209 len = strlen(xattr->name); 210 if (xattr->name[len-1] == '\n') strlen() could be zero, leading to a read underflow here. 211 xattr->name[len-1] = '\0'; 212 213 if (strcmp(xattr->name, ".") == 0) { 214 evm_xattrs_locked = 1; 215 newattrs.ia_mode = S_IFREG | 0440; 216 newattrs.ia_valid = ATTR_MODE; 217 inode = evm_xattrs->d_inode; 218 inode_lock(inode); 219 err = simple_setattr(evm_xattrs, &newattrs); 220 inode_unlock(inode); 221 audit_log_format(ab, "locked"); 222 if (!err) 223 err = count; 224 goto out; 225 } regards, dan carpenter