From patchwork Thu Apr 12 06:05:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10337901 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 36E11603B5 for ; Thu, 12 Apr 2018 06:06:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22952285F5 for ; Thu, 12 Apr 2018 06:06:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17489285FC; Thu, 12 Apr 2018 06:06:22 +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, T_TVD_MIME_EPI 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 0D3E8285F5 for ; Thu, 12 Apr 2018 06:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751848AbeDLGGU (ORCPT ); Thu, 12 Apr 2018 02:06:20 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:37624 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbeDLGGT (ORCPT ); Thu, 12 Apr 2018 02:06:19 -0400 Received: by mail-pf0-f179.google.com with SMTP id p6so2752191pfn.4 for ; Wed, 11 Apr 2018 23:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=lh/RNztVM3/hZWcVM2jGPFOP2CJORFcG2xvQGyRgTDQ=; b=m3QujCwodsdVHhLfETbtkfK4AO/JUXPXkvuEGldeaHibVbPKIZBc+a9QUXVrNfxH5S 7NVet2JBmoqtn3rz1baZFgjZ1xRYbTyxSWILknyMs95p6UfaTKIvncXaiAgrfTwQi7Km TM7bDHYtlQrLewSNgQvyn/WGwfpeCCbJIfRsJ/Bqk/HWMF6fNpx1maeCerbQpyjSNRo5 dRYgs3ptP0enwYHygu1R4mVtHGOG+j/j+Gqq/+NqWfTObF/6439RfqPDeFEuQDbL+3Dp 2DMTElD4NUFHy1x+VnoWyfikf3Icxs56KIG3g9da4tOYn3mw3t4toNAYsXi+rk/3b4zo GVAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lh/RNztVM3/hZWcVM2jGPFOP2CJORFcG2xvQGyRgTDQ=; b=t2Vo7Tce4SlKTJ3hbQZDGQ8evBhwJsQfMBARZXNqFR0QwsnDZdWA/FzOmfmivoWjN8 lVUqPfELmP0StxNM4WyFvDhM901SwBdWYkUxYIQnUbrZTF7ZC2T/gWYjFlcIW/+bAeY0 tIjwoq7mhFXNJbriFMOxxACq5SDy0Dza0gBFEyxZhPEfFOomPjpN69Q5reODtBRLOX9c MAoE/+GShzU4+j0UA6QzJNK061wkfiiEluZfg7V2FxV3StiRgOYVuEJ5EtGAKLELAU/5 OPNiHFJsXmzATz/JxIYrtNiCrEWTK0ArntC/3k9znbCaa5Hyd0+Tzk0uqjKh5Fn6MuJU AyaA== X-Gm-Message-State: ALQs6tDhD/s8OzACFO20zBsb9UC4OY8QeetsigTmVgF+yAKIkZA4zXVh FKmbkXzhU4jPGJUmIyjGo6j38V9ZZ5L75+WD3Y5VNQ== X-Google-Smtp-Source: AIpwx49nhkJ3SlxU/tquzRvmFDZxQrevFrVRvozyWwV8wtq+u9Qz9oEddRFb50XySUtHUkhm2/TFNBPZtXj+bgIlLZI= X-Received: by 10.98.224.215 with SMTP id d84mr6468509pfm.23.1523513178386; Wed, 11 Apr 2018 23:06:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.152.97 with HTTP; Wed, 11 Apr 2018 23:05:57 -0700 (PDT) From: Steve French Date: Thu, 12 Apr 2018 01:05:57 -0500 Message-ID: Subject: Fix for Bug 13107 - two missing files if mount to Windows root (of drive) shares To: 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 Windows doesn't always return . and .. (e.g.) for when you mount to equivalent of C$ this causes first two directory entries to be skipped. Patch attached which seems to fix it (more testing would be appreciated) I suspect that there is a better way to fix this - anyone see a better way. Problem is that if we rely on ctx->pos to determine where we are in the buffer we end up starting on entry 3 in the serach results ... but entry 1 and 2 are not always . and .. (as we see in shares in windows to the root of a drive). Any better ideas? From 73101ab3ac801638efaa143f2b4d5a244c8d1fed Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 12 Apr 2018 00:52:49 -0500 Subject: [PATCH] SMB3: Fix missing files when server doesn't return . and .. If the server doesn't return . or .. then the starting file returned is wrong and the first two files from the directory will be skipped. You can see this on mounts to Windows shares that are on the root of a drive for example. Fixes https://bugzilla.samba.org/show_bug.cgi?id=13107 CC: Stable Signed-off-by: Steve French --- fs/cifs/readdir.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index a27fc8791551..3325cabe0850 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -779,6 +779,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) struct cifsFileInfo *cifsFile = NULL; char *current_entry; int num_to_fill = 0; + loff_t first_entry; char *tmp_buf = NULL; char *end_of_smb; unsigned int max_len; @@ -796,6 +797,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) goto rddir2_exit; } + first_entry = ctx->pos; if (!dir_emit_dots(file, ctx)) goto rddir2_exit; @@ -817,7 +819,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) } */ tcon = tlink_tcon(cifsFile->tlink); - rc = find_cifs_entry(xid, tcon, ctx->pos, file, ¤t_entry, + rc = find_cifs_entry(xid, tcon, first_entry, file, ¤t_entry, &num_to_fill); if (rc) { cifs_dbg(FYI, "fce error %d\n", rc); @@ -848,8 +850,8 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) break; } /* - * if buggy server returns . and .. late do we want to - * check for that here? + * if buggy server returns . and .. late + * it will be skipped in cifs_filldir */ *tmp_buf = 0; rc = cifs_filldir(current_entry, file, ctx, @@ -861,7 +863,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx) } ctx->pos++; - if (ctx->pos == + if (ctx->pos == 2 + cifsFile->srch_inf.index_of_last_entry) { cifs_dbg(FYI, "last entry in buf at pos %lld %s\n", ctx->pos, tmp_buf); -- 2.14.1