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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 30 Apr 2009 10:23:50 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Nikanth Karthikesan <knikanth@...ell.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Jens Axboe <jens.axboe@...cle.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Detect and warn on atomic_inc/atomic_dec wrapping
	around


* Nikanth Karthikesan <knikanth@...ell.com> wrote:

> Add a debug option to detect and warn when the 32-bit atomic_t 
> wraps around during atomic_inc and atomic_dec.
> 
> Signed-off-by: Nikanth Karthikesan <knikanth@...e.de>

hm, what's the motivation?

As a generic debug helper this is not appropriate i think - counts 
can easily have a meaning when going negative as well. (we have no 
signed-atomic primitives)

>  static inline void atomic_inc(atomic_t *v)
>  {
> +#if defined(CONFIG_ENABLE_WARN_ATOMIC_INC_WRAP)
> +	WARN_ON(atomic_add_unless(v, 1, INT_MAX) == 0);
> +#else
>  	asm volatile(LOCK_PREFIX "incl %0"
>  		     : "+m" (v->counter));
> +#endif
>  }

also looks a bit ugly - this ugly #ifdef would spread into every 
architecture.

If we want to restrict atomic_t value ranges like that then the 
clean solution would be to add generic wrappers doing the debug 
(once, in generic code), and renaming the arch primitives to 
raw_atomic_inc() (etc), doing the lowlevel bits cleanly.

Do we really want this?

	Ingo
--
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