Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a9357f4 authored by Jim Rees's avatar Jim Rees Committed by J. Bruce Fields
Browse files

nfsd: avoid undefined signed overflow



In C, signed integer overflow results in undefined behavior, but unsigned
overflow wraps around. So do the subtraction first, then cast to signed.

Reported-by: default avatarJoakim Tjernlund <joakim.tjernlund@transmode.se>
Signed-off-by: default avatarJim Rees <rees@umich.edu>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent b6040f97
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3427,7 +3427,7 @@ grace_disallows_io(struct net *net, struct inode *inode)
/* Returns true iff a is later than b: */
/* Returns true iff a is later than b: */
static bool stateid_generation_after(stateid_t *a, stateid_t *b)
static bool stateid_generation_after(stateid_t *a, stateid_t *b)
{
{
	return (s32)a->si_generation - (s32)b->si_generation > 0;
	return (s32)(a->si_generation - b->si_generation) > 0;
}
}


static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session)
static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session)