Received: by 10.192.165.148 with SMTP id m20csp802007imm; Fri, 27 Apr 2018 07:45:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqg7jRa4pDV0pKJrYbFAHvU5mFR10DzT9rsJNBa5YcKzTi1/jqFOO6VcL1NlEkvVDdx83qP X-Received: by 2002:a17:902:8d81:: with SMTP id v1-v6mr2476386plo.383.1524840322896; Fri, 27 Apr 2018 07:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524840322; cv=none; d=google.com; s=arc-20160816; b=xtWJsbvN+yFH8fWTjW/rdvpBq562HgpnpVb1xwlJCnK48hXrU0DOeJIySTaHpTvbYv yWs3dWlVzBXfSFeXarpJ5RywJ9KkFsRU0yg5YdWC1eVigH1k27v3RAmiAfCeozevDvxN NaQ4vtRAS2daAmEV5wgnDGaFbYsHq+Z6Y11pQMkSvU6Ejribql38UnTsAX+2o4iam7dm 9p9mb2v93Z2qtxS7BbnuhjxnI9R5kB2ZG9dPtlJdCHlqy4T17OIMy3lrXPhGF1r8bN8x uhc0Yi6KdyXcso+nvRAfzsN5nX5vnzG84Xn6CufgVZq44ugUhksWuN8Rjed8Se7K7Dgq yjdg== 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=j9MWW2fvEwlyN/5iVL9sQhV7sBR80PlMXvjbt27kVRU=; b=v9wkI7RiX8gc4G7zBWRxz9SL8fYVtqOwg8s5noqu1rfhT+plxqq0BIa04asKD7WWl3 JsntbSGDiFW1M9FUoboS+6axxJNrC2YFSk+NKibeWKfUf4lpxQbOb/yRZBNXhVkqqCz9 FwCG7A0yh/hl4qEZwY5OUcsIumTbPQwsuZ8r/mstII3icfkWM/O3Ih18AB4QBnFdlEIM nbY4VeJS82iI0iFuUgzNH6a1QJDsx3ewNmg4iojI1dJFNrShO5E3lHYZu6awlOkQMvfE plwRzEW5B3YuUREFDhz0CURZt+TSOeOFEop27iO4KwgXL+CdVF+qbaEctXYhlMh5TgJA nGgw== 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 72si1427812pfn.44.2018.04.27.07.45.09; Fri, 27 Apr 2018 07:45:22 -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 S934641AbeD0OoF (ORCPT + 99 others); Fri, 27 Apr 2018 10:44:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:54108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934503AbeD0OIc (ORCPT ); Fri, 27 Apr 2018 10:08:32 -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 3F066218D1; Fri, 27 Apr 2018 14:08:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F066218D1 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.14 64/80] commoncap: Handle memory allocation failure. Date: Fri, 27 Apr 2018 15:58:57 +0200 Message-Id: <20180427135736.214606832@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@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.14-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);