Re: [PATCH v2] Fix: ext4: guard against EA inode refcount underflow in xattr update

From: Albin Babu Varghese

Date: Wed Sep 24 2025 - 18:54:10 EST


Hi Darrick, Ted,

Thanks a lot for taking the time to review this patch and for the helpful
suggestions.

> /me wonders if you could use check_add_overflow for this, but otherwise
> everthing looks fine to me...
We looked at check_add_overflow() and check_sub_overflow(), but our
understanding is that they are mainly useful if ref_change can vary beyond the
current ±1. Since the call site appear to only pass increments or decrements
of one, would you prefer we still use the helpers for defensive hardening, or
is it acceptable to rely on explicit 0 / U64_MAX boundary checks in this case?

> ...though while you're modifying the precondition checking here, I think
> these i_nlink preconditions should also be hoisted to the top and cause
> an EFSCORRUPTED return on bad inputs.
Thanks for pointing this out. We will include this in V3.

Cheers,
Albin