From patchwork Thu Aug 10 12:21:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9893549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CBEB760384 for ; Thu, 10 Aug 2017 12:24:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD389286BF for ; Thu, 10 Aug 2017 12:24:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1BF728707; Thu, 10 Aug 2017 12:24:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F6CB286BF for ; Thu, 10 Aug 2017 12:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752667AbdHJMYI (ORCPT ); Thu, 10 Aug 2017 08:24:08 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:37213 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbdHJMYG (ORCPT ); Thu, 10 Aug 2017 08:24:06 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7ACNlFf011015 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Aug 2017 12:23:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v7ACNkXX014223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Aug 2017 12:23:47 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v7ACNkmg031990; Thu, 10 Aug 2017 12:23:46 GMT Received: from mwanda (/197.157.0.19) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Aug 2017 05:23:41 -0700 Date: Thu, 10 Aug 2017 15:21:43 +0300 From: Dan Carpenter To: Steve French Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, kernel-janitors@vger.kernel.org Subject: [PATCH] cifs: don't send invalid setxattr requests Message-ID: <20170810122143.2o4jln4x6cvz5r2l@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is a static checker warning here because we're taking a "size" from the user which is in the 1-XATTR_SIZE_MAX range and we're assuming it's large enough to hold a sizeof(struct cifs_ntsd). This doesn't cause a buffer overflow or anything, we just end up sending an invalid sized command to the server. The server checks for that in CIFSSMBGetCIFSACL() and rejects it. Signed-off-by: Dan Carpenter Acked-by: Pavel Shilovsky --- Not tested. Please review this one carefully. -- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index de50e749ff05..70bdce5add24 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c @@ -93,6 +93,10 @@ static int cifs_xattr_set(const struct xattr_handler *handler, if (!value) goto out; + if (size < sizeof(struct cifs_ntsd)) { + rc = -EINVAL; + goto out; + } pacl = kmalloc(size, GFP_KERNEL); if (!pacl) { rc = -ENOMEM;