linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH cifs segfault ]
@ 2021-04-06 12:17 Seth Thielemann
  2021-04-06 14:28 ` Aurélien Aptel
  0 siblings, 1 reply; 5+ messages in thread
From: Seth Thielemann @ 2021-04-06 12:17 UTC (permalink / raw)
  To: CIFS

From e14cbf048c40d565e31d28479794d1feff9474f0 Mon Sep 17 00:00:00 2001                                                                                                                                                                                                          
From: "J. Seth Thielemann" <sthielemann@barracuda.com>                                                                                                                                                                                                                          
Date: Mon, 5 Apr 2021 14:58:59 -0400                                                                                                                                                                                                                                            
Subject: [PATCH] BNBS-45422: cifs segfault 6.5.03                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                
- Observed segfaults during cifs share backups, core investigation and strace revealed that files were being opened                                                                                                                                                             
  but upon read the syscall was returning a 32-bit error code:                                                                                                                                                                                                                  
open("/mnt/datasource/12/USERS8/pjabbia/data/MailPersonalFolders/Personal Folders.pst", O_RDONLY) = 10 <0.001080>                                                                                                                                                               
....                                                                                                                                                                                                                                                                            
read(10, "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ)6 \26
5ZZZZ\3274\325\16\250\177\0\0h%\1\0\0\0\0\0Y\f\0\0\0\0\0\0\27C\225\231ZZZZh\232\202\33\250\177\0\0h\232\202\33\250\177\0\0\320\234\206\33\250\177\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ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ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"..., 8192) = 4294967283 <0.000144>                                                                                                                                      
                                                                                                                                                                                                                                                                                
- Above is an impossible situation, the sign extension was at fault. The two functions using the trinary assignment of rc                                                                                                                                                       
in the cifs asio context:                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                
Before:                                                                                                                                                                                                                                                                         
   188d6:       bb f0 fe 00 00          mov    ebx,0xfef0                                                                                                                                                                                                                       
   188db:       45 85 e4                test   r12d,r12d                                                                                                                                                                                                                        
   188de:       44 89 e0                mov    eax,r12d   <- msl cleared
   188e1:       0f 84 6a 01 00 00       je     18a51 <cifs_uncached_writev_complete+0x371>
   188e7:       48 8b 7c 24 18          mov    rdi,QWORD PTR [rsp+0x18]
   188ec:       49 89 85 a8 00 00 00    mov    QWORD PTR [r13+0xa8],rax <- saved

After:
   189ce:       bb f0 fe 00 00          mov    ebx,0xfef0
   189d3:       48 85 ed                test   rbp,rbp
   189d6:       74 7c                   je     18a54 <cifs_uncached_writev_complete+0x374>
   189d8:       48 8b 7c 24 18          mov    rdi,QWORD PTR [rsp+0x18]
   189dd:       49 89 ae a8 00 00 00    mov    QWORD PTR [r14+0xa8],rbp

- Use ssize_t here to make sure the sign extension is handled properly.

Signed-off-by: J. Seth Thielemann <sthielemann@barracuda.com>
---
 fs/cifs/file.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 31d5787..b2640fc 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2988,7 +2988,7 @@ static void collect_uncached_write_data(struct cifs_aio_ctx *ctx)
        struct cifs_tcon *tcon;
        struct cifs_sb_info *cifs_sb;
        struct dentry *dentry = ctx->cfile->dentry;
-       int rc;
+       ssize_t rc;

        tcon = tlink_tcon(ctx->cfile->tlink);
        cifs_sb = CIFS_SB(dentry->d_sb);
@@ -3075,7 +3075,7 @@ static ssize_t __cifs_writev(
        struct cifs_aio_ctx *ctx;
        struct iov_iter saved_from = *from;
        size_t len = iov_iter_count(from);
-       int rc;
+       ssize_t rc;

        /*
         * iov_iter_get_pages_alloc doesn't work with ITER_KVEC.
@@ -3689,7 +3689,7 @@ static int cifs_resend_rdata(struct cifs_readdata *rdata,
        struct cifs_readdata *rdata, *tmp;
        struct iov_iter *to = &ctx->iter;
        struct cifs_sb_info *cifs_sb;
-       int rc;
+       ssize_t rc;

        cifs_sb = CIFS_SB(ctx->cfile->dentry->d_sb);

@@ -3910,7 +3910,7 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to)
        struct cifsFileInfo *cfile = (struct cifsFileInfo *)
                                                iocb->ki_filp->private_data;
        struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
-       int rc = -EACCES;
+       ssize_t rc = -EACCES;

        /*
         * In strict cache mode we need to read from the server all the time
--
1.8.3.1

===========================================================
Get the 13 Email Threat Types eBook

https://www.barracuda.com/13-threats-report?utm_source=email_signature&utm_campaign=13tt&utm_medium=email&utm_content=13tt-ebook

DISCLAIMER:
This e-mail and any attachments to it contain confidential and proprietary material of Barracuda, its affiliates or agents, and is solely for the use of the intended recipient. Any review, use, disclosure, distribution or copying of this transmittal is prohibited except by or on behalf of the intended recipient. If you have received this transmittal in error, please notify the sender and destroy this e-mail and any attachments and all copies, whether electronic or printed.
===========================================================

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-09  4:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 12:17 [PATCH cifs segfault ] Seth Thielemann
2021-04-06 14:28 ` Aurélien Aptel
2021-04-06 16:35   ` Seth Thielemann
2021-04-07 14:16     ` Aurélien Aptel
2021-04-09  4:18       ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).