From patchwork Thu Apr 19 01:42:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10349055 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 D50A76053F for ; Thu, 19 Apr 2018 01:42:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C61FF283E7 for ; Thu, 19 Apr 2018 01:42:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA0E828420; Thu, 19 Apr 2018 01:42:44 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 58F86283E7 for ; Thu, 19 Apr 2018 01:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752499AbeDSBmn (ORCPT ); Wed, 18 Apr 2018 21:42:43 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:37630 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752262AbeDSBmn (ORCPT ); Wed, 18 Apr 2018 21:42:43 -0400 Received: by mail-pg0-f66.google.com with SMTP id r14so1715533pgq.4 for ; Wed, 18 Apr 2018 18:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Y2B+OXXHEKSyI3Xg1xHzaeAMgHnTexA4nTvU2JsVdBo=; b=qyjKIVR1Sf6RcMQuHkQZ4g1CSJSfG/Q/nZhDdC0vNg2M7agACpgumDh6ejGu6J7oKi E7Qw0Ck98XghNpapyk3/MV4YH/mUGKzenSQDuc6RVz4HIkyvnP99bEimIyqSr2YaKYuI DICiKdP7qdmA1uMoQQkJMYO1XWN1R3lYDh/uXI7j6XthloM2mhiMHQQtQs9aVxA586Fz 8FaTmZ4UJgDuoyXLMFekFGhXTcYdBU6Dccc/2vGspWXTqg64iScpZTgW6d9l4Gqzc9jm dbNkXCQe5NfF3qV1H44C9rhoBgnpONCUJR4bBll/fqEb7ujYhbl/Ik2MPoGNGxXbdi04 ntmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Y2B+OXXHEKSyI3Xg1xHzaeAMgHnTexA4nTvU2JsVdBo=; b=MPiyfiLapGculViWStDqK2EMULs7wVVbxR2WvuJ5kB44iiPqrTeHxEnbxLGjlV/trs H5G40492StSz88qy5dzCnHo3aeADNfBVzQUVevb7bp7GMSzpKeeNRSKEYM+al9DKIE7z ACGTNJUduRFRhUYv7A6knrH2t/Rbq5J9xwg9lGNR7b/aC1+RzIZB3Fc04ST7mMLNnKBZ wkWQOlqaz7Hzb7Fp0dWuyF/V8/DYXnCOsC4Ovc1K+fIBkDgGjPFgxscVF8YNwQjvAgyJ p0Pi/EPPD8RW0qRduqPBrzNyKQ1+3DnSNgNs5LIb6NbS6Ws1riUzT4L5WBX+G+CsbBgO Uw2Q== X-Gm-Message-State: ALQs6tA3JXhIJAdId+hmkzogM/81LMbrSm+gnVPwng9ys5faPoTAMdpa P6sqbPeJBVBIpl8xBlfqSvJVt2RTiag/LO1LkLogQ4hZ X-Google-Smtp-Source: AIpwx49b2nsz+8jt7zgOJ4aLWA1d8/V60EVlzYBRJSj5WbnwtKLUTrgl0lQFPIDaekf/tHM7rVwd3BkfhTPwCI6TA1Y= X-Received: by 10.98.18.67 with SMTP id a64mr3899088pfj.153.1524102162103; Wed, 18 Apr 2018 18:42:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.152.97 with HTTP; Wed, 18 Apr 2018 18:42:21 -0700 (PDT) In-Reply-To: <20180419005237.11404-2-lsahlber@redhat.com> References: <20180419005237.11404-1-lsahlber@redhat.com> <20180419005237.11404-2-lsahlber@redhat.com> From: Steve French Date: Wed, 18 Apr 2018 20:42:21 -0500 Message-ID: Subject: Re: [PATCH] cifs: do not allow creating sockets in SMB1 To: Ronnie Sahlberg Cc: linux-cifs 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 I think the safer patch is to catch all invalid special file types (not just S_ISSOCK) but putting in the missing "else" clause (see below) - but when I tested it I got a different return code than expected mapped by the caller ... so perhaps we need to return a different return code other than EOPNOTSUPP On Wed, Apr 18, 2018 at 7:52 PM, Ronnie Sahlberg wrote: > 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. > 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 > disallow creation of such sockets. > > Reported-by: Eryu Guan > Signed-off-by: Ronnie Sahlberg > --- > fs/cifs/dir.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c > index 81ba6e0d88d8..632a35be85ea 100644 > --- a/fs/cifs/dir.c > +++ b/fs/cifs/dir.c > @@ -684,6 +684,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, > goto mknod_out; > } > > + if (S_ISSOCK(mode)) > + return -EINVAL; > + > if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) > goto mknod_out; > > -- > 2.13.3 > diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 81ba6e0d88d8..ebb40ad7ec7f 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -742,7 +742,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, 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) */ + } else + rc = -EOPNOTSUPP; tcon->ses->server->ops->close(xid, tcon, &fid); d_drop(direntry);