Received: by 10.192.165.148 with SMTP id m20csp767324imm; Fri, 27 Apr 2018 07:13:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr3WXXhkmxswYhG4JudpZ77vQPgW41mSEQ4bRhoeruB6kBZYDn6nArlo9YuwY0Ta7MUR2fi X-Received: by 2002:a65:6585:: with SMTP id u5-v6mr2267514pgv.396.1524838400512; Fri, 27 Apr 2018 07:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838400; cv=none; d=google.com; s=arc-20160816; b=VRz5l9cjTJR8FHp7PKQ2EHrD7MBZC05ixTs4iN2oxeJXu7qHzc8UCK2z9F+QJ8ofzV aok+Vnr6TdpSNJLLIESXDFmTDys6gp3Cpk498UEsc6h1FUqKYyksteiDos6ODEMB2tf8 M1gG3UCmnfB0kuffj4ltEwYYjW/kJEXSAELZ1tpdnJ4MF+iYt+OZ3b8EZJl2jff3upQV lznXJ0btfrd4x0xQP911qqBI3mwg8+m0qIpAUmQzo2BAq7k61nHLfMrFe9ZVFrjhGVRX Zoz/aSKGtTUToOZbYU6/UvJimowTBQjOIM0E9mmrWOwgb/ry66Hrws3CoP2BKnO/6Uhb HcQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=zjHRU3U62LIvrWGVV8ihEUcuxBZt+GY5SII+aYKzDzE=; b=lpu9XKXFnAUe0lmHd8cj9vLiMck1I/0s/9XsgaDotNiOWQYi+xsMie7tGQrNnRfzTB cXsaENEVrYGVhAofEsTh23h09aFZ/ecgCSXd3/kXoKQADDzj/Je8s//BXuj4yxCbCTL/ kh9bN+At/iIQglyn15fpqOSH5r9dyYoEIdIiV1WXoEToKgo9L+JnpLxbYWmsxJKHWtxF 1daRIOYEkAbhvzGRKterzn95nka8eOqOT8RGHNfaa6mCdjm/6BF0jvrGYRiJgL4+Lq/4 EULSSvu1xHdjiq5z2hQeR6j5hQpmX6Bcdvvwj1yeKj1qIhnMhgG9wrlHjo/D9a9/Gw0m /B8w== 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 d16-v6si1300390pgn.563.2018.04.27.07.13.06; Fri, 27 Apr 2018 07:13:20 -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 S935120AbeD0OMF (ORCPT + 99 others); Fri, 27 Apr 2018 10:12:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934628AbeD0OMC (ORCPT ); Fri, 27 Apr 2018 10:12:02 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 AA77D21892; Fri, 27 Apr 2018 14:12:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA77D21892 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , syzbot , "Serge E. Hallyn" , James Morris , "Eric W. Biederman" Subject: [PATCH 4.16 61/81] commoncap: Handle memory allocation failure. Date: Fri, 27 Apr 2018 15:59:03 +0200 Message-Id: <20180427135746.913943828@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa commit 1f5781725dcbb026438e77091c91a94f678c3522 upstream. syzbot is reporting NULL pointer dereference at xattr_getsecurity() [1], for cap_inode_getsecurity() is returning sizeof(struct vfs_cap_data) when memory allocation failed. Return -ENOMEM if memory allocation failed. [1] https://syzkaller.appspot.com/bug?id=a55ba438506fe68649a5f50d2d82d56b365e0107 Signed-off-by: Tetsuo Handa Fixes: 8db6c34f1dbc8e06 ("Introduce v3 namespaced file capabilities") Reported-by: syzbot Cc: stable # 4.14+ Acked-by: Serge E. Hallyn Acked-by: James Morris Signed-off-by: Eric W. Biederman Signed-off-by: Greg Kroah-Hartman --- security/commoncap.c | 2 ++ 1 file changed, 2 insertions(+) --- a/security/commoncap.c +++ b/security/commoncap.c @@ -449,6 +449,8 @@ int cap_inode_getsecurity(struct inode * magic |= VFS_CAP_FLAGS_EFFECTIVE; memcpy(&cap->data, &nscap->data, sizeof(__le32) * 2 * VFS_CAP_U32); cap->magic_etc = cpu_to_le32(magic); + } else { + size = -ENOMEM; } } kfree(tmpbuf);