Ubuntu – vsftpd not starting on EC2

amazon ec2ftpUbuntuvsftpd

I am running Ubuntu 13.10 on an EC2 micro instance (want to keep running on free tier until I am more confident on EC2). I have successfully installed the LAMP stack, but I'm having problems setting up vsftpd. I followed this tutorial, which got me to the point where I could make a local ftp connection (ftp 127.0.0.1) using virtual users and it seemed like Active ftp connections worked from outside. At that stage, my vsftpd.conf file contained:

#Basic settings
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/sites/$USER
chroot_local_user=YES
hide_ids=YES

# Home directories determined by files placed in this directory
user_config_dir=/var/www/ftp_users

I then made changes to support Passive mode;
Opened the needed port range on the EC2 instance.
Added the following to vsftpd.conf:

# Passive mode (Ensure that the server's firewall leaves ports in the specified range open)
pasv_enable=YES
pasv_max_port=XXXX
pasv_min_port=XXXX
port_enable=YES
pasv_address=XXXX

Where XXX had been the correct ports and ip.
After vsftpd service restart it did not work (I think I just got connection refused). I thought it might be the ports that are not opened yet and I rebooted the EC2 instance.

From there I could not get vsftpd to run, I rolled back all the changes I had made, even uninstalled and reinstalled vsftpd. With the default setup (fresh install), it still does not run.

Now:
When I run the vsftpd service i get "start/pre-start" (it does not run) with no error message. The vsftpd log file contains no errors (it is empty), even after I added all possible log related settings to vsftpd.conf. If I tail syslog, I get the following:

Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851970] [] unmap_single_vma+0x81/0xf0
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851974] [] unmap_vmas+0x49/0x90
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851978] [] exit_mmap+0x9c/0x170
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851983] [] mmput+0x5c/0x110
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851987] [] do_exit+0x278/0xa40
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851991] [] do_group_exit+0x3f/0xa0
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.851995] [] SyS_exit_group+0x14/0x20
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.852001] [] system_call_fastpath+0x1a/0x1f
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.852086] BUG: Bad rss-counter state mm:ffff8800031fc000 idx:0 val:-1
Feb 27 10:30:30 ip-172-31-12-98 kernel: [1084249.852095] BUG: Bad rss-counter state mm:ffff8800031fc000 idx:1 val:1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045035] BUG: Bad page map in process vsftpd pte:8000000000000165 pmd:242e8067
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045056] page:ffffea0000000000 count:-99 mapcount:-99 mapping: (null) index:0x0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045064] page flags: 0x10(dirty)
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045073] addr:00007f3caefe9000 vm_flags:00100071 anon_vma:ffff880023dd7e40 mapping: (null) index:7f3caefe9
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045083] CPU: 0 PID: 4266 Comm: vsftpd Tainted: G B 3.11.0-17-generic #31-Ubuntu
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045086] ffff8800242e5228 ffff8800235b1c68 ffffffff816e7645 00007f3caefe9000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045091] ffff8800235b1cb0 ffffffff81163c68 8000000f80e24165 00000007f3caefe9
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045095] ffff8800242e8f48 ffffea0000000000 00007f3caefe9000 00007f3caefea000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045099] Call Trace:
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045112] [] dump_stack+0x45/0x56
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045120] [] print_bad_pte+0x1a8/0x240
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045124] [] unmap_page_range+0x70e/0x7f0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045128] [] unmap_single_vma+0x81/0xf0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045132] [] unmap_vmas+0x49/0x90
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045137] [] exit_mmap+0x9c/0x170
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045143] [] mmput+0x5c/0x110
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045148] [] do_exit+0x278/0xa40
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045152] [] do_group_exit+0x3f/0xa0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045156] [] SyS_exit_group+0x14/0x20
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045163] [] system_call_fastpath+0x1a/0x1f
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045257] BUG: Bad rss-counter state mm:ffff8800031fda40 idx:0 val:-1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.045266] BUG: Bad rss-counter state mm:ffff8800031fda40 idx:1 val:1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076745] BUG: Bad page map in process vsftpd pte:8000000000000165 pmd:242cf067
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076763] page:ffffea0000000000 count:-100 mapcount:-100 mapping: (null) index:0x0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076770] page flags: 0x14(referenced|dirty)
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076780] addr:00007f10b0663000 vm_flags:00100071 anon_vma:ffff880023dd7640 mapping: (null) index:7f10b0663
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076790] CPU: 0 PID: 4270 Comm: vsftpd Tainted: G B 3.11.0-17-generic #31-Ubuntu
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076793] ffff880023dedcf0 ffff8800235b3c68 ffffffff816e7645 00007f10b0663000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076798] ffff8800235b3cb0 ffffffff81163c68 8000000f80e24165 00000007f10b0663
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076802] ffff8800242cf318 ffffea0000000000 00007f10b0663000 00007f10b0664000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076806] Call Trace:
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076818] [] dump_stack+0x45/0x56
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076824] [] print_bad_pte+0x1a8/0x240
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076829] [] unmap_page_range+0x70e/0x7f0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076833] [] unmap_single_vma+0x81/0xf0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076836] [] unmap_vmas+0x49/0x90
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076841] [] exit_mmap+0x9c/0x170
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076847] [] mmput+0x5c/0x110
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076851] [] do_exit+0x278/0xa40
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076855] [] do_group_exit+0x3f/0xa0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076859] [] SyS_exit_group+0x14/0x20
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076866] [] system_call_fastpath+0x1a/0x1f
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076957] BUG: Bad rss-counter state mm:ffff8800031fc780 idx:0 val:-1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.076966] BUG: Bad rss-counter state mm:ffff8800031fc780 idx:1 val:1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110274] BUG: Bad page map in process vsftpd pte:8000000000000165 pmd:235b6067
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110293] page:ffffea0000000000 count:-101 mapcount:-101 mapping: (null) index:0x0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110300] page flags: 0x10(dirty)
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110308] addr:00007fbdab202000 vm_flags:00100071 anon_vma:ffff880023dd7080 mapping: (null) index:7fbdab202
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110319] CPU: 0 PID: 4274 Comm: vsftpd Tainted: G B 3.11.0-17-generic #31-Ubuntu
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110321] ffff8800242e5000 ffff8800235b5c68 ffffffff816e7645 00007fbdab202000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110326] ffff8800235b5cb0 ffffffff81163c68 8000000f80e24165 00000007fbdab202
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110330] ffff8800235b6010 ffffea0000000000 00007fbdab202000 00007fbdab203000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110334] Call Trace:
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110346] [] dump_stack+0x45/0x56
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110353] [] print_bad_pte+0x1a8/0x240
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110357] [] unmap_page_range+0x70e/0x7f0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110361] [] unmap_single_vma+0x81/0xf0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110365] [] unmap_vmas+0x49/0x90
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110369] [] exit_mmap+0x9c/0x170
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110375] [] mmput+0x5c/0x110
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110380] [] do_exit+0x278/0xa40
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110384] [] do_group_exit+0x3f/0xa0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110388] [] SyS_exit_group+0x14/0x20
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110394] [] system_call_fastpath+0x1a/0x1f
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110504] BUG: Bad rss-counter state mm:ffff8800031fda40 idx:0 val:-1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.110513] BUG: Bad rss-counter state mm:ffff8800031fda40 idx:1 val:1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146320] BUG: Bad page map in process vsftpd pte:8000000000000165 pmd:235fb067
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146339] page:ffffea0000000000 count:-102 mapcount:-102 mapping: (null) index:0x0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146346] page flags: 0x14(referenced|dirty)
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146356] addr:00007f47b9932000 vm_flags:00100071 anon_vma:ffff880023dd7f40 mapping: (null) index:7f47b9932
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146366] CPU: 0 PID: 4278 Comm: vsftpd Tainted: G B 3.11.0-17-generic #31-Ubuntu
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146369] ffff880023dc4c38 ffff8800242b7c68 ffffffff816e7645 00007f47b9932000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146374] ffff8800242b7cb0 ffffffff81163c68 8000000f80e24165 00000007f47b9932
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146378] ffff8800235fb990 ffffea0000000000 00007f47b9932000 00007f47b9933000
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146382] Call Trace:
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146394] [] dump_stack+0x45/0x56
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146401] [] print_bad_pte+0x1a8/0x240
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146405] [] unmap_page_range+0x70e/0x7f0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146409] [] unmap_single_vma+0x81/0xf0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146413] [] unmap_vmas+0x49/0x90
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146418] [] exit_mmap+0x9c/0x170
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146424] [] mmput+0x5c/0x110
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146428] [] do_exit+0x278/0xa40
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146432] [] do_group_exit+0x3f/0xa0
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146436] [] SyS_exit_group+0x14/0x20
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.146441] [] system_call_fastpath+0x1a/0x1f
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.148847] BUG: Bad rss-counter state mm:ffff8800031fda40 idx:0 val:-1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.148859] BUG: Bad rss-counter state mm:ffff8800031fda40 idx:1 val:1
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.181465] BUG: Bad page map in process vsftpd pte:8000000000000165 pmd:242dd067
Feb 27 10:31:40 ip-172-31-12-98 kernel: [1084320.181483] page:ffffea0000000000 count:-103 mapcount:-103 mapping: (null) index:0x0

(Only the first 100/252 lines shown, the rest is similar). The only references to erros that I can see is:
BUG: Bad rss-counter state and
BUG: Bad page map in process vsftpd

But I cannot find any information on what this means and how to fix it (assuming it is actually related in the first place).

My knowledge and skill on Linux is limited, could someone please shed light on what happened/is happening/how to fix this.

Thanks

PS I know SFTP is better, I need to set FTP up.

Edit

Note that the dump supplied above is resulting after a FRESH install of vsftpd, so the default config options are used, namely

listen=YES
anonymous_enable=NO
local_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

I have setup a www group, containing the default user (ubuntu) that owns /var/www/ (as per this). Due to the fact that the default settings and the ubuntu user are used to produce the errors, I do not think that the user/usergroups are related. (I might be wrong of course)

In the tutorial I followed, I did setup libpam-pwdfile, which I left untouched when purging vsftpd. I do not want to try and remove this package as I am unsure if it had been installed and in use before I started. The current vsftpd settings do not utilise this library any more, so I do not think that it relates to the error.

Please explain what the errors that I get mean and why I am getting it. I would like to understand what is going on, or at least have something new to search for in solving this.

Best Answer

After having the same issue, I can confirm that with vsftpd 3.02 and kernel versions 3.11.0-17 and 3.11.0-18 (just updated this morning) the FTP server crash at start.

[   19.711407] BUG: Bad rss-counter state mm:ffff88003cf0b680 idx:0 val:-1
[   19.711417] BUG: Bad rss-counter state mm:ffff88003cf0b680 idx:1 val:1
[   19.716021] init: vsftpd main process (1053) terminated with status 2
[   19.716224] init: vsftpd respawning too fast, stopped

As a workaround, booting from kernel 3.11.0-15 do the trick and the service starts again.