Opened 12 months ago

Closed 11 months ago

Last modified 8 months ago

#28861 closed defect (fixed)

torsocks: Unsupported syscall number 217

Reported by: ilf Owned by: dgoulet
Priority: Medium Milestone:
Component: Core Tor/Torsocks Version: Tor: 0.3.4.9
Severity: Normal Keywords: torsocks, syscall, 217
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

% torsocks --version
Torsocks 2.3.0

% torsocks mutt
<quit>
1544962729 WARNING torsocks[21365]: [syscall] Unsupported syscall number 217. Denying the call (in tsocks_syscall() at syscall.c:568)
1544962729 WARNING torsocks[21367]: [syscall] Unsupported syscall number 217. Denying the call (in tsocks_syscall() at syscall.c:568)
1544962729 WARNING torsocks[21369]: [syscall] Unsupported syscall number 217. Denying the call (in tsocks_syscall() at syscall.c:568)
1544962729 WARNING torsocks[21371]: [syscall] Unsupported syscall number 217. Denying the call (in tsocks_syscall() at syscall.c:568)
1544962729 WARNING torsocks[21373]: [syscall] Unsupported syscall number 217. Denying the call (in tsocks_syscall() at syscall.c:568)

https://gitweb.torproject.org/torsocks.git/tree/src/lib/syscall.c#n567

Child Tickets

Change History (16)

comment:1 Changed 12 months ago by onirony

Here is a patched torsocks that can run getdents and getdents64 (the syscall it's rejecting in your error message): https://github.com/seisvelas/torsocks/tree/getdent_fix

The getdents code I used to test my patch is just the example from the Linux man page and can be found here: http://man7.org/linux/man-pages/man2/getdents.2.html#EXAMPLE

When I compiled that getdents example code and attempted to run it through standard torsocks this happened:

hc01@HC01:~$ /usr/bin/torsocks ./a.out 
[Dec 19 16:31:02] WARNING torsocks[16567]: [syscall] Unsupported syscall number 78.
Denying the call (in tsocks_syscall() at syscall.c:465)
getdents: Function not implemented

Then, using my patched torsocks:

hc01@HC01:~$ torsocks ./a.out
--------------- nread=1008 ---------------
i-node#  file type  d_reclen  d_off   d_name
23068679  directory    32 22651653883364612  .cache
23069803  directory    32 72324196525406672  .compiz
...

When I modified the code to use getdents64, I received the same error from torsocks. With my patch it ran properly. I'm going to bother David Goulet and set this ticket to 'needs review' to see if my patch is safe and can be accepted upstream.

Last edited 12 months ago by onirony (previous) (diff)

comment:2 Changed 12 months ago by onirony

Status: assignedneeds_review

comment:3 Changed 12 months ago by onirony

As a side note for why I think this merits whitelisting (unless there's a security issue with torsocks enabling getdents that I'm not aware of): A quick Google of the error msg plus the getdents and getdents64 syscall numbers reveals that a lot of people complain about applications failing bc of lack of getdents support in torsocks.

Pretty lengthy threads can be found on a number of forums in which people unsuccessfully guess at why torsocks fails on some system call, to the point where it seems prudent that we amend the error message to include a link to some torsocks documentation explaining the nature of the whitelist system. Most forum threads I found re the error message came to incorrect conclusions about the cause of the error. But for now, considering getdents/getdents64 seem to be a very major cause of application incompatibility I think it's a great candidate for inclusion in the whitelist.

comment:4 Changed 11 months ago by traumschule

Hi! I get the following error. Did you possibly miss to commit a header file?

make[2]: Entering directory '/home/user/torsocks-seisvelas/src/lib'
  CC       syscall.lo                                                    
syscall.c: In function ‘handle_getdents’:             
syscall.c:453:29: error: ‘TSOCKS_NR_GETDENTS’ undeclared (first use in this function)
  return tsocks_libc_syscall(TSOCKS_NR_GETDENTS, fd, dirp, count);   
                             ^~~~~~~~~~~~~~~~~~       
syscall.c:453:29: note: each undeclared identifier is reported only once for each function it appears in
syscall.c: In function ‘handle_getdents64’:
syscall.c:468:29: error: ‘TSOCKS_NR_GETDENTS64’ undeclared (first use in this function)
  return tsocks_libc_syscall(TSOCKS_NR_GETDENTS64, fd, dirp, count);
                             ^~~~~~~~~~~~~~~~~~~~
syscall.c: In function ‘tsocks_syscall’:
syscall.c:592:7: error: ‘TSOCKS_NR_GETDENTS’ undeclared (first use in this function)
  case TSOCKS_NR_GETDENTS:
       ^~~~~~~~~~~~~~~~~~
syscall.c:595:7: error: ‘TSOCKS_NR_GETDENTS64’ undeclared (first use in this function)
  case TSOCKS_NR_GETDENTS64:
       ^~~~~~~~~~~~~~~~~~~~
Makefile:470: recipe for target 'syscall.lo' failed

edit: After applying this commit i get the same output as above.

$ /usr/bin/torsocks --version
Torsocks 2.2.0
/usr/bin/torsocks ./a.out
1546704938 WARNING torsocks[9687]: [syscall] Unsupported syscall number 141. Denying the call (in tsocks_syscall() at syscall.c:488)
getdents: Function not implemented

torsocks# make install
$ torsocks --version
Torsocks 2.3.0
$ torsocks ./a.out
1546704119 WARNING torsocks[9431]: [syscall] Unsupported syscall number 141. Denying the call (in tsocks_syscall() at syscall.c:568)
getdents: Function not implemented

torsocks-seisvelas# make install
$ torsocks ./a.out
--------------- nread=628 ---------------  
inode#    file type  d_reclen  d_off   d_name
  659085  regular      24   59533437  autogen.sh
  688747  directory    20  282648487  tests     
  688742  directory    20  386899293  include
  659424  regular      20  416462606  Makefile  
  659390  regular      24  437768886  configure 
  688719  directory    16  518915911  .git      
  659474  regular      20  553246746  libtool       
  659079  regular      24  613726131  .travis.yml
  659080  regular      24  652068980  ChangeLog
  688718  directory    16 1055405100  .  
  659184  regular      28 1127103152  config.status
  659102  regular      24 1139214666  gpl-2.0.txt        
  688741  directory    20 1204858234  extras
  659082  regular      20 1257734922  LICENSE
  659081  regular      20 1304322103  INSTALL
  659083  regular      24 1335198446  Makefile.am
  659084  regular      24 1995239999  README.md
  688743  directory    16 2094777189  src
  659089  regular      24 2147483647  configure.a
Last edited 11 months ago by traumschule (previous) (diff)

comment:5 Changed 11 months ago by onirony

Thank you so much for pointing this out. getdent_fix now should work without issues.

Last edited 11 months ago by onirony (previous) (diff)

comment:6 Changed 11 months ago by dgoulet

Status: needs_reviewneeds_revision

Thanks onirony!

  • The getdents64() should be using struct linux_dirent64 according to the man page.
  • The unsigned int count; seems to have an extra white space at the start. And the unsigned int fd; in both functions has a extra white space at the end.

Rest lgtm;

comment:7 Changed 11 months ago by onirony

Thanks for the feedback, dgoulet. Updated the branch: https://github.com/seisvelas/torsocks/tree/getdent_fix

comment:8 Changed 11 months ago by traumschule

Status: needs_revisionneeds_review

The branch now compiles and runs error free for me.

$ git log
commit 05bad537d2ffc4beb2695a4bdf861876790b759f
Author: Alejandro Alvarado
Date:   Mon Jan 7 22:59:11 2019 -0600
...
$ sh autogen.sh && ./configure && make
...
$ sh ./src/bin/torsocks
torsocks 2.3.0

./src/bin/torsocks [OPTIONS] [COMMAND [arg ...]]

usage: ./src/bin/torsocks command args
...

comment:9 in reply to:  7 Changed 11 months ago by dgoulet

Status: needs_reviewneeds_revision

Replying to onirony:

Thanks for the feedback, dgoulet. Updated the branch: https://github.com/seisvelas/torsocks/tree/getdent_fix

Looks great. Can I ask you one last thing. To squash together all commits into one? I see 7 commits with roughly the same title so it doesn't tell us much about what it is or does.

If you have question about it, let me know on IRC/email or I can do it myself if you prefer. Whatever suits you!

Thanks to everyone for the testing as well!

comment:10 Changed 11 months ago by onirony

Status: needs_revisionneeds_review

comment:11 in reply to:  10 Changed 11 months ago by dgoulet

Status: needs_reviewmerge_ready

Replying to onirony:

No problem, I squashed them into a single commit: https://github.com/seisvelas/torsocks/commit/085f5675a6ea23e5733a4eba26e5129d13d7546e

Can you point me to a branch that I can pull and merged based on current torsocks master branch? Would prefer that than cherry-picking the commit :S.

comment:13 in reply to:  12 Changed 11 months ago by dgoulet

Status: merge_readyneeds_revision

Replying to onirony:

Sure, here you go!

https://gitlab.com/seisvelas/torsocks/tree/fix_getdents

Hmmm... that branch still has all the commits that are supposed to be merged into a single one. Can you git rebase -i and squash them all into one? I can't merge it like that :S

comment:14 Changed 11 months ago by onirony

dgoulet, I think you might be mistaken! The git history for that branch reads like so:

hc-19@hc19-HP-Compaq-6005-Pro-MT-PC:~$ git clone --branch fix_getdents https://gitlab.com/seisvelas/torsocks.git
Cloning into 'torsocks'...
remote: Enumerating objects: 3053, done.
remote: Counting objects: 100% (3053/3053), done.
remote: Compressing objects: 100% (866/866), done.
remote: Total 3053 (delta 2177), reused 3034 (delta 2165)
Receiving objects: 100% (3053/3053), 1.12 MiB | 0 bytes/s, done.
Resolving deltas: 100% (2177/2177), done.
Checking connectivity... done.
hc-19@hc19-HP-Compaq-6005-Pro-MT-PC:~$ cd torsocks/
hc-19@hc19-HP-Compaq-6005-Pro-MT-PC:~/torsocks$ git log

commit 4c00ec8773fd63fa48ef49e1ccf2adac598427be
Author: Alejandro Alvarado <44826516+seisvelas@users.noreply.github.com>
Date:   Mon Dec 17 19:25:18 2018 -0600

    Add getdents / getdents64 support re ticket 28861

commit cec4a733c081e09fb34f0aa4224ffd7b687fb310
Author: David Goulet <dgoulet@torproject.org>
Date:   Mon Nov 19 10:42:40 2018 -0500

    Update version to v2.3.0
    
    Signed-off-by: David Goulet <dgoulet@torproject.org>

commit 47b10b686e8e94fe0a2096135d4d9b195afb5267
Author: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Date:   Tue Jan 23 10:01:17 2018 -0500

    Fix a bunch of stuff in the wrapper script, #24967

commit 446ce04bb31a023712f5ff74a6a0649606286662
Author: David Goulet <dgoulet@torproject.org>
Date:   Mon Nov 19 10:18:04 2018 -0500

There's just the one commit that's a rebase of all those other commits from before. Also, looking at the commit history in Gitlab itself:

https://i.ibb.co/pLXRrjt/commits.jpg

Let me know if I'm the one who's mistaken! Otherwise, should be good to go, no?

comment:15 Changed 11 months ago by dgoulet

Resolution: fixed
Status: needs_revisionclosed

Oh indeed! You moved to Gitlab :). I corrected my remote branch, it looks good thanks!

Merged! Thanks!

comment:16 Changed 8 months ago by intrigeri

FTR this fixes Totem run with torsocks, that would otherwise crash on Debian Buster in some configurations: https://redmine.tails.boum.org/code/issues/16618

Note: See TracTickets for help on using tickets.