A joint pain supplement taken by millions of Britons may be linked to an increased risk of dementia, a major new study suggests.