VirtualBox

Changeset 77949 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Mar 29, 2019 1:07:19 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129674
Message:

linux/vboxsf: Detect kernel buffers for our iov_iter glue. Seems splice/senfile may use vector functions with kernel address and so may probably other kernel modules. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r77946 r77949  
    9393};
    9494# ifdef VBOX_STRICT
    95 #  define VBSF_IOV_ITER_INITIALIZER(a_cSegs, a_pIov, a_fWrite) { 0, a_fWrite, 0, a_cSegs, a_pIov, a_pIov, a_cSegs }
     95#  define VBSF_IOV_ITER_INITIALIZER(a_cSegs, a_pIov, a_fWrite) \
     96    { vbsf_iov_iter_detect_type(a_pIov, a_cSegs), a_fWrite, 0, a_cSegs, a_pIov, a_pIov, a_cSegs }
    9697# else
    97 #  define VBSF_IOV_ITER_INITIALIZER(a_cSegs, a_pIov, a_fWrite) { 0, a_fWrite, 0, a_cSegs, a_pIov }
     98#  define VBSF_IOV_ITER_INITIALIZER(a_cSegs, a_pIov, a_fWrite) \
     99    { vbsf_iov_iter_detect_type(a_pIov, a_cSegs), a_fWrite, 0, a_cSegs, a_pIov }
    98100# endif
    99101# define ITER_KVEC 1
     
    135137*********************************************************************************************************************************/
    136138#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     139
     140/**
     141 * Detects the vector type.
     142 */
     143static int vbsf_iov_iter_detect_type(struct iovec const *paIov, size_t cSegs)
     144{
     145    /* Check the first segment with a non-zero length. */
     146    while (cSegs-- > 0) {
     147        if (paIov->iov_len > 0) {
     148            if (access_ok(VERIFY_READ, paIov->iov_base, paIov->iov_len))
     149                return (uintptr_t)paIov->iov_base >= USER_DS.seg ? ITER_KVEC : 0;
     150            AssertMsgFailed(("%p LB %#zx\n", paIov->iov_base, paIov->iov_len));
     151            break;
     152        }
     153        paIov++;
     154    }
     155    return 0;
     156}
     157
    137158
    138159# undef  iov_iter_count
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette