Say the ball goes in halfway past the rim, and an opponent knocks the ball back upwards and out. Does this count for points? How far does the ball have to pass the rim to count as a successful score?
That would be illegal and considered interference.
From NBA rule 11, section I
A player should not : b. Touch any ball from within the playing area when it is above the basket ring and within the imaginary cylinder.
g. Touch the ball at any time with a hand which is through the basket ring.
i. Touch the rim, net or ball while the ball is in the net, preventing it from clearing the basket.
PENALTY: If the violation is at the opponent’s basket, the offended team is awarded two points, if the attempt is from the two point zone and three points if it is from the three point zone. The crediting of the score and subsequent procedure is the same as if the awarded score has resulted from the ball having gone through the basket, except that the official shall hand the ball to a player of the team entitled to the throw-in. If the violation is at a team’s own basket, no points can be scored and the ball is awarded to the offended team at the free throw line extended on either sideline. If there is a violation by both teams, no points can be scored, play shall be resumed by a jump ball between any two opponents in the game at the center circle.