From patchwork Fri Jun 22 21:43:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 933620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41CBst5wsmz9s31; Sat, 23 Jun 2018 07:44:18 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fWTql-0004Me-JH; Fri, 22 Jun 2018 21:44:11 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fWTqi-0004L4-7Z for kernel-team@lists.ubuntu.com; Fri, 22 Jun 2018 21:44:08 +0000 Received: from mail-it0-f72.google.com ([209.85.214.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fWTqh-00029H-TW for kernel-team@lists.ubuntu.com; Fri, 22 Jun 2018 21:44:08 +0000 Received: by mail-it0-f72.google.com with SMTP id 13-v6so2804485itl.7 for ; Fri, 22 Jun 2018 14:44:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=/A6QKo3F1PHHE0krrO5oajSvX3/OsGMXePuWzI5n/tA=; b=CjmZo2IFQP2Maad+I/HttIqTRR5oCekUiRlyn4xkcNI3TFyy+tmRX4MlgcwX1DDBKP LN3N503RPImo3393LZCR1qVxNxH0lMBq4SLCOm4oGFcactMmg1H7U3+wN+tyCKEoTka6 mhNxIM/uSBz82+nJc2FH9FF6e6m/fMExaXiv6U6WCFLsV/Ly+6OLfxOkaGIdvxQpfLq1 LCGmNke/ZGvmNyvUPU1d07gQjsNtPLAVCCWd+Vf2q4wO3ZOoXE3jgDXmiY4mMU+MvNri Xt8WY2/ZYSwlHHPfzJbfbcRzfRxJGsA6mohPkmdVt/QP4qmiPkdh/QcmUzuB9kd50cd/ HZQg== X-Gm-Message-State: APt69E1FIs+6rW0ndBp6i9peTr+/bLuoIdVie/ZM9niLZf1FtdIET3Ah ofGwKF/4cF4tInbJmjF3lsdf4MXJeUChNZYP7ONM8nBTsTvGVAZaur4pHnDHJhgCw3cdd7Ba/+5 PbLmVpzYlwDBvYHZmVxiqtfw3A51WackLbN/ECpzAqw== X-Received: by 2002:a6b:cd05:: with SMTP id d5-v6mr2789837iog.150.1529703846671; Fri, 22 Jun 2018 14:44:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKE9L/rBbymDzPYgxmXsgej/Si24S1cwN4rkKKT9yMNbMSo4tK+sk4PcV9rx/4YMm6u4cz+vg== X-Received: by 2002:a6b:cd05:: with SMTP id d5-v6mr2789828iog.150.1529703846398; Fri, 22 Jun 2018 14:44:06 -0700 (PDT) Received: from localhost ([2605:a601:ac7:2a20:110:4491:9f96:3555]) by smtp.gmail.com with ESMTPSA id n204-v6sm1178090itg.7.2018.06.22.14.44.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 14:44:05 -0700 (PDT) From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [SRU][Xenial][PATCH 4/4] commoncap: Handle memory allocation failure. Date: Fri, 22 Jun 2018 16:43:59 -0500 Message-Id: <20180622214359.17903-5-seth.forshee@canonical.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180622214359.17903-1-seth.forshee@canonical.com> References: <20180622214359.17903-1-seth.forshee@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Tetsuo Handa BugLink: http://bugs.launchpad.net/bugs/1778286 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 (cherry picked from commit 1f5781725dcbb026438e77091c91a94f678c3522) Signed-off-by: Seth Forshee --- security/commoncap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/commoncap.c b/security/commoncap.c index d42373adb762..814324f7f057 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -460,6 +460,8 @@ int cap_inode_getsecurity(const struct inode *inode, const char *name, 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);