The reconfigurable intelligent surface (RIS) is a promising technology for terahertz (THz) massive multiple-input multiple-output (MIMO) communication systems. However, acquiring high-dimensional channel state information (CSI) and realizing efficient active/passive beamforming for RIS are challenging owing to its cascaded channel structure and lack of signal processing units. To overcome these challenges, this study proposes a deep learning (DL)-based physical signal processing scheme for RIS-aided THz massive MIMO systems over hybrid far-near field channels wherein channel estimation with low pilot overhead and robust beamforming are implemented. Specifically, first, an end-to-end DL-based channel estimation framework that consists of pilot design, CSI feedback, subchannel estimation, and channel extrapolation is introduced. In this framework, only some RIS elements are first activated, a subsampling RIS channel is then estimated, and a DL-based extrapolation network is finally used to reconstruct the full-dimensional CSI. Next, to maximize the sum rate under imperfect CSI, a DL-based scheme is developed to simultaneously design hybrid active beamforming at the base station and passive beamforming at the RIS. Simulation results show that the proposed channel extrapolation scheme achieves better CSI reconstruction performance than conventional schemes while greatly reducing pilot overhead. Moreover, the proposed beamforming scheme outperforms conventional schemes in terms of robustness to imperfect CSI.