Skip to content
Snippets Groups Projects

smb2: fix timeout/busyloop with some SMBv1 servers

Closed Thomas Guillem requested to merge tguillem/vlc:smb-fixes into master
3 unresolved threads

Question: What timeout value should we use to detect that a server is responding?

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Thomas Guillem added 8 commits

    added 8 commits

    • d56dab09 - access: cache: don't call free_cb from entry_Delete
    • 7e45dbf4 - smb2: don't use sys->error_status while opening
    • e2ee8583 - smb2: rework error handling
    • 51651ed8 - smb2: destroy the context in case of error
    • 0fa55fb9 - smb2: remove teardown handling
    • 25b986cb - smb2: always use smb2 timeout
    • a346805b - smb2: timeout on first connection
    • d67f34bb - access: cache: interrupt when the cache is destroyed

    Compare with previous version

  • Author Maintainer

    Lot of rewriting to remove the teardown because it was hiding a serious issue.

  • Thomas Guillem mentioned in merge request !1606 (closed)

    mentioned in merge request !1606 (closed)

  • 345 346
    346 347 struct vlc_smb2_op op = VLC_SMB2_OP(access, sys->smb2);
    347 348
    348 if (smb2_lseek(op.smb2, sys->smb2fh, i_pos, SEEK_SET, NULL) < 0)
    349 int err = smb2_lseek(op.smb2, sys->smb2fh, i_pos, SEEK_SET, NULL);
    350 if (err < 0)
    349 351 {
    350 VLC_SMB2_SET_ERROR(&op, "smb2_seek_async", 1);
    351 sys->error_status = op.error_status;
    352 VLC_SMB2_SET_ERROR(&op, "smb2_seek_async", err);
    352 353 return VLC_EGENERIC;
  • 198 /* vlc_smb2_mainloop() can be called to clean-up after an error, but this
    199 * function can override the error_status (from async cbs). Therefore,
    200 * store the original error_status in order to restore it at the end of
    201 * this call (since we want to keep the first and original error status). */
    202 int original_error_status = op->error_status;
    203
    204 if (teardown)
    205 {
    206 /* Don't use vlc_poll_i11e that will return immediately with the EINTR
    207 * errno if VLC's input is interrupted. Use the posix poll with a
    208 * timeout to let a chance for a clean teardown. */
    209 timeout = TEARDOWN_TIMEOUT;
    210 poll_func = (void *)poll;
    211 op->error_status = 0;
    212 }
    201 #define FIRST_CONNECT_TIMEOUT 250 /* in ms */
    • Not sure what you base this on. If the device is in deep sleep state, the time between the TCP SYN/ACK and useful data may well be several seconds, or the time to the SYN/ACK for that matter.

    • Author Maintainer

      I could increase to 2 seconds, but in the worst case scenario, the user will always have to wait 2 seconds when parsing or player a file, unless !1399 (closed) is merged. In that case, the extra wait happen only once (per vlc instance).

    • 2 seconds is not sufficient. VLC uses 5 seconds normally and even that's occasionally insufficient.

      You can't break slow but correct/up-to-date implementations to support broken/obsolete ones, IMO.

    • Author Maintainer

      For the record, the samba project use a delay of 2seconds before trying the SMBv1 port but they don't kill the SMBv2 connection attempt like we must do (because smb2 and dsm are different modules).

      I already made a mistake in the past, half breaking SMBv1 for android users, we got ton of complaints. People are not ready to get rid of this shitty and dangerous protocol (but I'm personal).

    • Uh FWIW Samba disabled SMB1 2.5 years ago. But my point is not that SMB1 should or shouldn't be dropped.

      My point is that you can't downgrade because that's a security vulnerability, and in this particular case, an actively exploited one. In other words you MUST NOT use SMB1 with a server that supports SMB2, even if the server accepts SMB1-only clients.

    • Author Maintainer

      I agree. It should not be automatic. The user can still force smb v1 with some advanced option.

      Maybe we could pop up a dialog after 5 seconds telling the user that this might be a smbv1 server (after checking the port is responding).

    • In this particular case, frighteningasking the user is probably the only way short of dropping support entirely.

    • Please register or sign in to reply
  • Thomas Guillem mentioned in merge request !1622 (merged)

    mentioned in merge request !1622 (merged)

  • Thomas Guillem added 76 commits

    added 76 commits

    • a346805b...c8570567 - 69 commits from branch videolan:master
    • e126c4d5 - access: cache: don't call free_cb from entry_Delete
    • e6bda87f - smb2: don't use sys->error_status while opening
    • fe28dbcc - smb2: rework error handling
    • 606f7c09 - smb2: destroy the context in case of error
    • 05d68967 - smb2: remove teardown handling
    • bd4e92f9 - smb2: always use smb2 timeout
    • 4a4e42fc - smb2: timeout on first connection

    Compare with previous version

  • mentioned in issue #26825 (closed)

  • Please register or sign in to reply
    Loading