Re: [PATCH] libblkid: Fix crash while parsing config with libeconf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 20, 2025 at 04:24:07PM +0200, Stanislav Brabec wrote:
> Stanislav Brabec wrote:
> > As the whhole econf_file structure is freed by econf_free(file) at the end
> 
> > of blkid_read_config, econf_file structure cannot be defined as static and
> > initialized only once. The econf_free() is not robust enough and keeps a
> > pointer to the garbage after the first call. And if /etc/blkid.conf does
> > not exist, it is called second time.
> 
> However the patch is correct and fixes the crash, there are still open questions:
> 
> - Why blkid_read_config() and econf_readConfig() are called twice with the same parameters? Is it intended behavior?

This code pattern (e.g., libblkid/src/evaluate.c):

     conf = blkid_read_config(NULL);
     ...

     cachefile = blkid_get_cache_filename(conf);
     rc = blkid_get_cache(&c, cachefile);

If blkid_get_cache_filename() returns NULL, then blkid_get_cache()
reads the configuration again. Additionally, blkid_get_cache_filename() can read the
configuration if 'conf' is NULL.

Yes, it's not elegant.

> - And finally, is a similar code in logindefs.c vulnerable to a similar type of crash?

The `logindefs` uses a global `list` variable, which should be filled only once.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux