There is no definitave answer. So long as no money changes hands for the purpose of the flight it is not illegal.
It is only sensible that the instructor should consider it appropriate for a passenger to be carried and that the student does not object.