Software doesn't know the total number of _physical_ sectors on a modern HDD, but not for the reason you state. Sure, software doesn't know anything about the disk geometry, including which cylinders may or may not have more or fewer sectors in each track, but that's fine: it's not the software's job to know that, it's the firmware's. That makes for an excellent abstraction, because every model of disk is different, and we can hide those details in the firmware that goes with that model.
The reason software doesn't know the total number of _physical_ sectors is that the firmware only reports the number of _logical_ sectors. The number of physical sectors is higher, because the firmware keeps some sectors in reserve for autoreplacement following errors. Another good abstraction so that the software doesn't have to care about that.