Received: by 10.192.165.148 with SMTP id m20csp578821imm; Wed, 25 Apr 2018 04:35:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx49S9lq8bEMoZc8xceTmwZnD2YNcUhLewFZlP6EOVy7uUAsYP9HPKsk/ZyMt9bVUPWB3ZuKS X-Received: by 10.98.214.218 with SMTP id a87mr23338782pfl.200.1524656159228; Wed, 25 Apr 2018 04:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524656159; cv=none; d=google.com; s=arc-20160816; b=GuHSZbAN3AuW4+2ZrLJuJVrK4+3jsafrfUcBSyPXlClWzrmixL/s88O7tIS5aeOPA5 ZRGQLIvvOh1Wxberm+XwtFGpP6leTHHTMOw5p56R/tTcycvRHYBKtzVUHwH1HeHOsgt4 Twwo4Pa4UN3qPMV3r0Hr9bOOn99vpc/wOyanRtNGrSXc5Dekfw7EOjA+jdbvCtYEfpBv l9fPhygStL2rpEOLzv/cIGaPh9FvVsiv/LYNbDNZ02lqOCVcosyvVTpwfrX4T7CPMY9u Rri0GJXxxBVMpjZyBcR4jMh/cmMG8NaJH5AFRGwc0yjzt8Ayw2ubXqyTlD1P2QvGALPZ +ZlQ== 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 :arc-authentication-results; bh=EDNfTCeqxVgQod08+yQj7zpUP5TBJskokbJozq2srdw=; b=x7VhAjFyCQMzemc+46O5gQ0FyZlZxYz/IGbI/4g1vImgB19Ko866UmXOGbjUa/13bz E1rvwp8v2rV7ACsy+s0qSv/Iq5+nqnVUUQYYFE4jQs6JihYIkUk/MpUwb4LTGaFV5/bp isTQ+2mDcxmq803Ft4wYKQ5fRPKqlWUWI6GMRZ2FS5WC7EfGYkZ0AGbPnh6pfyGGAa7l pw6IXHJpmuFn73QlROjjKv63dInOsBx7+QCw0Ln8rEbE3cPza36hapltp8vBgl7FMpC/ c5s4Q1R+jQ/4tSvDmzfFROGW+sJ6tFWMgAyQJlh9kC/xuWlRT48hRxikuojVTaHLN7Ts CsRw== 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 s14si5529118pfh.11.2018.04.25.04.35.44; Wed, 25 Apr 2018 04:35:59 -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 S1753219AbeDYLes (ORCPT + 99 others); Wed, 25 Apr 2018 07:34:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50826 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623AbeDYKeV (ORCPT ); Wed, 25 Apr 2018 06:34:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id ECC99481; Wed, 25 Apr 2018 10:34:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Colin Ian King , Pavel Shilovsky , Eryu Guan , Ronnie Sahlberg , Steve French Subject: [PATCH 4.16 02/26] cifs: do not allow creating sockets except with SMB1 posix exensions Date: Wed, 25 Apr 2018 12:33:11 +0200 Message-Id: <20180425103314.939162098@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103314.842517924@linuxfoundation.org> References: <20180425103314.842517924@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: Steve French commit 1d0cffa674cfa7d185a302c8c6850fc50b893bed upstream. RHBZ: 1453123 Since at least the 3.10 kernel and likely a lot earlier we have not been able to create unix domain sockets in a cifs share when mounted using the SFU mount option (except when mounted with the cifs unix extensions to Samba e.g.) Trying to create a socket, for example using the af_unix command from xfstests will cause : BUG: unable to handle kernel NULL pointer dereference at 00000000 00000040 Since no one uses or depends on being able to create unix domains sockets on a cifs share the easiest fix to stop this vulnerability is to simply not allow creation of any other special files than char or block devices when sfu is used. Added update to Ronnie's patch to handle a tcon link leak, and to address a buf leak noticed by Gustavo and Colin. Acked-by: Gustavo A. R. Silva CC: Colin Ian King Reviewed-by: Pavel Shilovsky Reported-by: Eryu Guan Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/cifs/dir.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -684,6 +684,9 @@ int cifs_mknod(struct inode *inode, stru goto mknod_out; } + if (!S_ISCHR(mode) && !S_ISBLK(mode)) + goto mknod_out; + if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) goto mknod_out; @@ -692,10 +695,8 @@ int cifs_mknod(struct inode *inode, stru buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); if (buf == NULL) { - kfree(full_path); rc = -ENOMEM; - free_xid(xid); - return rc; + goto mknod_out; } if (backup_cred(cifs_sb)) @@ -742,7 +743,7 @@ int cifs_mknod(struct inode *inode, stru pdev->minor = cpu_to_le64(MINOR(device_number)); rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms, &bytes_written, iov, 1); - } /* else if (S_ISFIFO) */ + } tcon->ses->server->ops->close(xid, tcon, &fid); d_drop(direntry);