mount.cifs incorrectly update /etc/mtab when -o remount is used

Bug #1144612 reported by Louis Bouchard
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cifs-utils (Ubuntu)
Fix Released
Undecided
Louis Bouchard
Precise
Fix Released
Medium
Louis Bouchard
Quantal
Fix Released
Undecided
Unassigned

Bug Description

SRU justification :

During a remount of a cifs filesystem, the mtab file is not properly
updated, which leads to a doubled entry of the same filesystem in the
/etc/mtab file.

Impact :

df and other tools incorrectly report the CIFS file system as mounted twice

Fix :

This has been fixed upstream in version 5.3 which is present in Quantal and more recent releases. The following upstream commit provides the fix :

https://git.samba.org/?p=cifs-utils.git;a=commitdiff_plain;h=f46dd7661cfb87257c95081fc2071c934bfbbb16

Test Case :

- An accessible SAMBA share is required on host 'sambahost'
- the user=,password= options are only required to avoid password prompt

 $ mkdir /mnt/target
 $ mount -o user=,password= //sambahost/test /mnt/target
 $ mount -o remount /mnt/target
 $ df | grep target
//sambahost/test 7033648 1278124 5402656 20% /mnt/target
//sambahost/test 7033648 1278124 5402656 20% /mnt/target

With the proposed fix, there would be only one /mnt/target entry

Regression :

This fix is already present in Q & R. It only introduce a del_mtab function that is only called when MS_REMOUNT is set on the file system.

Original description of the problem :

Create a file with the following contents, making sure that the samba location is available and is mountable by guests and that the mountpoint also exists and is a directory:

# cat /etc/puppet/manifests/tst.pp
package{'samba-client': }

mount{'home directory mount':
 name => '/mnt/target',
 atboot => 'true',
 device => '//localhost/test',
 ensure => 'mounted',
 fstype => 'cifs',
 require => [Package['samba-client']]
}

4.2- Apply the puppet config:

# puppet apply /etc/puppet/manifests/tst.pp

4.3- Verify that the mounted FS shows twice:

root@ubuntu:~# mount -t cifs
//localhost/test on /mnt/target type cifs (rw)
//localhost/test on /mnt/target type cifs (rw)

Revision history for this message
Louis Bouchard (louis) wrote :
Changed in puppet (Ubuntu):
status: New → Confirmed
assignee: nobody → Louis Bouchard (louis-bouchard)
Revision history for this message
Louis Bouchard (louis) wrote :

Just updated the upstream bug as the problem is easily reproducible with instructions above

Louis Bouchard (louis)
Changed in puppet (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Louis Bouchard (louis) wrote :

transcript from the upstream bug report :

After doing an analysis of the code, most particularly lib/puppet/type/mount.rb it appears that the problem doesn’t lie with puppet but with cifs-utils.

When puppet does a ‘mount -o remount’, it triggers a bug in cifs-utils that makes a double entry in /etc/mtab. This is the commit of the fix for this bug :

http://git.samba.org/?p=cifs-utils.git;a=commit;h=f46dd7661cfb87257c95081fc2071c934bfbbb16

“During a remount of a cifs filesystem, the mtab file is not properly updated, which leads to a doubled entry of the same filesystem in the /etc/mtab file. This patch adds a new function del_mtab() which is called before the add_mtab() in case the fs is being remounted.”

A potential workaround is to use remounts => ‘false’ but a safer solution would be to get a version of cifs-utils higher than 5.3 :

https://lists.samba.org/archive/samba/2012-January/165958.html

To confirm this outside of puppet control, simply do the following :

$ mount //sambahost/test /mnt/target
$ mount -o remount /mnt/target

$ df | grep target
//sambahost/test 7033648 1278120 5402660 20% /mnt/target
//sambahost/test 7033648 1278120 5402660 20% /mnt/target

affects: puppet (Ubuntu) → cifs-utils (Ubuntu)
Revision history for this message
Louis Bouchard (louis) wrote :

For info, this is fixed in versions from Quantal and after

Changed in cifs-utils (Ubuntu):
status: In Progress → Fix Released
Changed in cifs-utils (Ubuntu Quantal):
status: New → Fix Released
Changed in cifs-utils (Ubuntu Precise):
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Louis Bouchard (louis-bouchard)
Revision history for this message
Louis Bouchard (louis) wrote :

debdiff with the proposed fix

description: updated
summary: - puppet double mounts CIFS mounts
+ mount.cifs double mounts CIFS mounts
summary: - mount.cifs double mounts CIFS mounts
+ mount.cifs incorrectly update /etc/mtab when -o remount is used
Changed in cifs-utils (Ubuntu Precise):
status: Confirmed → In Progress
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work Louis, I've sponsored the SRU to precise

Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Louis, or anyone else affected,

Accepted cifs-utils into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/cifs-utils/2:5.1-1ubuntu2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in cifs-utils (Ubuntu Precise):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Eduardo Damato (edamato) wrote :

Verified on a precise system, Problem fixed on

ii cifs-utils 2:5.1-1ubuntu2

tags: added: verification-done
removed: verification-needed
Revision history for this message
Adam Conrad (adconrad) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cifs-utils - 2:5.1-1ubuntu2

---------------
cifs-utils (2:5.1-1ubuntu2) precise-proposed; urgency=low

  * mount.cifs: Properly update mtab during remount (LP: #1144612)

  During a remount of a cifs filesystem, the mtab file is not properly
  updated, which leads to a doubled entry of the same filesystem in the
  /etc/mtab file. This patch adds a new function del_mtab() which is
  called before the add_mtab() in case the fs is being remounted.

  The del_mtab() function will delete from the mtab, the old entry from
  the filesystem which is being remounted, and then, calls add_mtab() to
  add an updated entry to the mtab file.
 -- Louis Bouchard <email address hidden> Fri, 26 Apr 2013 15:15:32 +0200

Changed in cifs-utils (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.