Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1685944

Summary: WORM-XLator: Maybe integer overflow when computing new atime
Product: [Community] GlusterFS Reporter: david.spisla
Component: coreAssignee: bugs <bugs>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: mainlineCC: bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-07 12:04:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description david.spisla 2019-03-06 11:20:38 UTC
Description of problem:
May integer overflow in WORM Xlator possibly.

The structs:

typedef struct {
    uint8_t worm : 1;
    uint8_t retain : 1;
    uint8_t legal_hold : 1;
    uint8_t ret_mode : 1;
    int64_t ret_period;
    int64_t auto_commit_period;
} worm_reten_state_t;

typedef struct {
    gf_boolean_t readonly_or_worm_enabled;
    gf_boolean_t worm_file;
    gf_boolean_t worm_files_deletable;
    int64_t reten_period;
    int64_t com_period;
    int reten_mode;
    time_t start_time;
} read_only_priv_t;

from read-only.h are using uint64_t values to store periods of retention and autocommmit. This seems to be dangerous since in worm-helper.c the function worm_set_state computes in line 97:

stbuf->ia_atime = time(NULL) + retention_state->ret_period;

stbuf->ia_atime is using int64_t because auf the settings of struct iattr. So if there is a very very high retention period stored , there is maybe an integer overflow. 

What can be the solution? Using int64_t instead if uint64_t may reduce the probability of the occurance.



Version-Release number of selected component (if applicable):

Gluster v5.4

Comment 1 Worker Ant 2019-03-06 11:28:23 UTC
REVIEW: https://review.gluster.org/22309 (WORM-Xlator: Maybe integer overflow when computing new atime) posted (#1) for review on master by David Spisla

Comment 2 Worker Ant 2019-03-07 12:04:45 UTC
REVIEW: https://review.gluster.org/22309 (WORM-Xlator: Maybe integer overflow when computing new atime) merged (#4) on master by Amar Tumballi