Bug in stats module causing endless write to file

"Dieterich, Peter-Simon" <[email protected]>
Newsgroups dev.linux.lists.connman
Message-ID <AM0PR09MB4500BF2A13FBACE6E7046E23881F2@AM0PR09MB4500.eurprd09.prod.outlook.com>
Dear maintainers of connman,

I would like to report a bug in the statistics module of connman that is caused when the definition of time_t changes from 32-bit to 64-bit, e.g., after a Yocto update from dunfell to scarthgap.

On systems that experience a high number of wifi reconnects this sometimes leads to an infinite loop when connman rotates its statistics, causing high cpu-load in the connman process and creating an ever increasing temporary file in /var/lib/connman/.

The bug can be traced to src/stats.c, where stats_record, the record type containing time_t, is written to /var/lib/connman/<profile>/data. The data file contains a header and a ring-buffer type structure with elements of type stats_record. When the data file is full, connman removes old entries by first writing them to a temporary file in /var/lib/connman/. During the rotation of the statistics in the process_file function, the abort criterium for the while loop processing the entries is effectively iter->it == iter->end, which may in some cases never become true if an existing data file contains records of mixed type.

As a workaround, I would suggest disabling the stats module with --disable-stats. A possible fix could involve saving the size of stats_record in the header on creation and invalidating an opened file on a discrepancy.

Best,
Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.