]> granicus.if.org Git - spl/commit
vn_getf/vn_releasef should not accept negative file descriptors
authorRichard Yao <richard.yao@clusterhq.com>
Thu, 16 Apr 2015 14:29:41 +0000 (10:29 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 24 Apr 2015 20:02:00 +0000 (13:02 -0700)
commit313b1ea622275e24c3046c3b04a98a933b18f8de
treed4aa83fb61aca5eb359db6d254d7322ea20393ba
parentcd69f020e4b0f9c416dd07a264e48c9488a7633f
vn_getf/vn_releasef should not accept negative file descriptors

C type coercion rules require that negative numbers be converted into
positive numbers via wraparound such that a negative -1 becomes a
positive 1. This causes vn_getf to return a file handle when it should
return NULL whenever a positive file descriptor existed with the same
value. We should check for a negative file descriptor and return NULL
instead.

This was caught by ClusterHQ's unit testing.

Reference:
http://stackoverflow.com/questions/50605/signed-to-unsigned-conversion-in-c-is-it-always-safe

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Andriy Gapon <avg@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #450
module/spl/spl-vnode.c