I think I've read somewhere that people managed to force JTAG/ISP programmer to use different model number (or they were using IAP Flash programming - I don't remember) and they were able to access the memory beyond what it should be based on the part number.
It seems that ST is binning these MCUs according to the usable flash amount (e.g. if they find corrupted bits), or maybe, there is one silicon design and memory limits are imposed more or less artificially for marketing reasons. These are not 14 nm Intel CPUs, is the yield that low that they have to resort to binning based on which parts are broken?
it is also possible that they want to have a part an a particular range to compete with others and as long as they aren't sold
it sufficient number they won't bother making a new part, they'll just sell a bigger part at a lower margin
I've worked at place that was bitten by that once, a product by accident used memory that weren't supposed to be there but it
was because it was really a bigger part. When the production got really big the manufacturer of the IC made a new part that
only had the memory it was supposed to and everything stopped working