[LTP] [PATCH v3] madvise11.c:Check loadable module before rmmod

Wei Gao wegao@suse.com
Tue Mar 14 10:43:07 CET 2023


On Tue, Mar 14, 2023 at 09:15:05AM +0100, Cyril Hrubis wrote:
> Hi!
> > This is caused by "_" and "-", current search function not do this tricky translate part.
> > Input parameter is hwpoison_inject but actually string in modules.xxx is hwpoison-inject
> > 
> > /lib/modules/5.14.21-150400.24.41-default/modules.dep | grep hwpo
> > kernel/mm/hwpoison-inject.ko.zst:
> > 
> > Other info just FYI:
> > //modprobe can accept both "-" and "_"
> > localhost:/home/ltp # modprobe hwpoison-inject
> > localhost:/home/ltp # modprobe hwpoison_inject
> > 
> > //get info from lsmod and /proc use "_"
> > localhost:/home/ltp # lsmod | grep hwpo
> > hwpoison_inject        16384  0
> > localhost:/home/ltp # cat /proc/modules | grep hwp
> > hwpoison_inject 16384 0 - Live 0xffffffffc09d6000
> 
> Sounds like a bug that shoudl be fixed, we probably need to create two
> search strings, one with dashes and one with underscores and try to
> strstr() both.
> 
I found some logic handle both "_" and "-" in LTP other function such as:

static int tst_search_driver(const char *driver, const char *file)
{

        if (strrchr(driver, '-') || strrchr(driver, '_')) {
                char *driver2 = strdup(driver);
                char *ix = driver2;
                char find = '-', replace = '_';

                if (strrchr(driver, '_')) {
                        find = '_';
                        replace = '-';
                }

                while ((ix = strchr(ix, find)))
                        *ix++ = replace;

                ret = tst_search_driver_(driver2, file);
                free(driver2);
        }


I have sent my latest fix with patch v5(include some small reconstruct/clean work on current exit function)
> -- 
> Cyril Hrubis
> chrubis@suse.cz


More information about the ltp mailing list