lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 27 Sep 2007 05:19:06 +0000 (UTC)
From:	Shreyansh Jain <shreyansh.jain@...il.com>
To:	linux-kernel@...r.kernel.org
Subject:  try_module_get code understanding

Dear List,

I agree that this issue certainly doesn't require to be in this list (rightful
place being kernewbies) but I tried that and got no response - so trying my luck
here.

I was going through try_module_get function in include/linux/module.h file
(2.6.22 stock kernel) - which is like:

-----
static inline int try_module_get(struct module *module){
  int ret = 1;   <--- error case when !module
    if (module) {
         unsigned int cpu = get_cpu();
         if (likely(module_is_live(module)))
                local_inc(&module->ref[cpu].count);
         else
                ret = 0;   <--- error case
         put_cpu();
  }
  return ret;   <----
}
----

What I understand about the code flow is:
-- module live would return the flag stating that this module can be reference
and is NOT being removed currently.

1. In case the module pointer passed is invalid (NULL) this function would
return 1 (error case)
2. In case the module pointer is OK, and module is currently not being removed,
reference count would be incremented and 1 returned (non error case)
3. In case the module pointer is OK, and module reference count can NOT be
increased, 0 would be returned (error case).

As you can observe from above points, 0 and 1 are returned for error cases. I am
a little confused and wondering if there is something which I am missing in this
code??.

Can anyone help me out with this? Any help would be highly appreciated.

Regards
Shreyansh

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ