There are no restrictions on who can pass the ball. As long as the handoff was legal, this is a legal play. If the handoff was backward, this is always a legal play as anybody can hand the ball backward to anybody else at anytime. If the handoff was forward, the lineman must have turned to face his end line and be at least two yards behind the line of scrimmage when taking the handoff.