bugacl - Bugs: bug #66074, setfacl is not atomic and...

 
 

bug #66074: setfacl is not atomic and corresponding repair solution

Submitter:  Dai Shixin <daishixin>
Submitted:  Sun 11 Aug 2024 09:04:37 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 11 Aug 2024 09:04:37 AM UTC, original submission:  

Hi,
1. Issue description: we update ACL rules for a same directory when multiple containers launched, but the ACL rules may be lost occasionally. However, no error is reported by setfacl.For example, after running command `setfacl-R-m u: 1234 :rwx/mnt`., the command is executed successfully, but the/mnt directory does not have the ACL rule for user 1234.

2. Cause analysis: It is found that the read/write process of the ACL rule set by setfacl is not atomic.. For example, setfacl instance A will overwrites the rule saved by instance B.
setfacl instance A:      get_acl()                               set_acl()
setfacl instance B:                 get_acl()           set_acl()

3. Recommended solution: using the flock mechanism provided by kernel to guarantee the read/write process is atomic.The approximate solution is described as follows:
```
int
do_set(
const char *path_p,
const struct stat *st,
int walk_flags,
void *arg)
{
........
+   /* skip setting if the rule is redundant */
+ if (do_set_need_skip()):
    return;

+   /* add lock to guarantee the atomic read-write process */
+ flock(path_p);
RETRIEVE_ACL(cmd->c_type); get acl rules
.............

if (acl_set_file(path_p, ACL_TYPE_ACCESS, acl) != 0) { set acl rules
+   unlock();
.......
}
```
for details, refer to the attachment.

Dai Shixin <daishixin>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by daishixin (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-08-11 daishixin Attached File- Added 0guarantee_setfacl_process_is_atomic.patch, #56343

    Back to the top

    Powered by Savane 3.14-04e1.
    Corresponding source code