В ядре Linux устранена следующая уязвимость: net: rds: fix uninitialized trans dereference В обработчике событий CM rds_rdma_cm_event_handler_cmn() назначает trans только в том случае, когда устройство RDMA является InfiniBand CA (RDMA_NODE_IB_CA). На любом другом типе устройства, например, iWARP RNIC, например, siw, транс остается неинициализированным, но переключатель событий лишает его: безусловно в случае RDMA_CM_EVENT_CONNECT_REQUEST через trans->cm_handle_connect(), и (с контекстом подключения) в случаях ROUTE_RESOLVED и ESTABLISHED. Таким образом, слушатель RDS на устройстве iWARP вылетает из ядра, как только поступает запрос на подключение: с CONFIG_INIT_STACK_ALL_ZERO дикая нагрузка становится NULL при смещении 0xa0 (&trans->cm_handle_connect) в iw_cm_wq workqueue.
GCC маскирует ошибку в сборках по умолчанию, складывая неинициализированную нагрузку в &rds_ib_transport; ядра Clang-built принимают реальный неинициализированный путь и oops. Активная сторона может приземлиться и на не-IB устройстве: идентификатор, который создает rds_ib_conn_path_connect(), не ограничен типом узла, поэтому rdma_resolve_addr() связывает его с тем устройством, которое обслуживает локальный адрес, и iWARP RNIC на том же netdev квалифицируется. Сбой там другой: решение маршрута на iWARP id никогда не заполняет cm_id->route.path_rec, и случай ROUTE_RESOLVED пишет path_rec[0].sl, прежде чем он вызывает в транспорт.
Транспорт iWARP был отброшен давно, и IB является единственным оставшимся транспортом, поэтому сделайте это явным: инициализируйте trans в &rds_ib_transport при объявлении, откажитесь от условного назначения, отклоните запрос на подключение, который поступает на устройство, не являющееся IB, и откажитесь от соединения, адрес которого разрешен, вместо того, чтобы решать маршрут на нем. Отказ ограничивается RDMA_CM_EVENT_CONNECT_REQUEST по назначению: ненулевой возврат от обработчика заставляет rdma_cm уничтожить идентификатор, на котором было доставлено событие, что подходит для недавно созданного идентификатора запроса, но освободит идентификатор соединения, который RDS все еще имеет для любого другого события. На активной стороне идентификатор остается ic->i_cm_id, и завершение соединения разрушает его, так что этот случай возвращает 0. [achender: отклонить только на RDMA_CM_EVENT_CONNECT_REQUEST вместо спасения для каждого события на устройстве, не являющемся IB, чтобы rdma_cm не уничтожал идентификаторы соединения RDS; отбросить соединение, чей адрес разрешен на устройстве, не являющемся IB, до того, как маршрут будет разрешен на нем; changelog custoded]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: net: rds: fix uninitialized trans dereference in CM event handler rds_rdma_cm_event_handler_cmn() assigns trans only when the RDMA device is an InfiniBand CA (RDMA_NODE_IB_CA). On any other device type, e.g. an iWARP RNIC such as siw, trans stays uninitialized, but the event switch dereferences it: unconditionally in the RDMA_CM_EVENT_CONNECT_REQUEST case via trans->cm_handle_connect(), and (with a connection context) in the ROUTE_RESOLVED and ESTABLISHED cases. An RDS listener on an iWARP device therefore crashes the kernel as soon as a connect request arrives: with CONFIG_INIT_STACK_ALL_ZERO the wild load becomes a NULL dereference at offset 0xa0 (&trans->cm_handle_connect) in the iw_cm_wq workqueue. GCC masks the bug in default builds by folding the uninitialized load into &rds_ib_transport; Clang-built kernels take the real uninitialized path and oops. The active side can land on a non-IB device too: the id that rds_ib_conn_path_connect() creates is not restricted to a node type, so rdma_resolve_addr() binds it to whichever device serves the local address, and an iWARP RNIC on the same netdev qualifies. The crash there is different: resolving a route on an iWARP id never fills in cm_id->route.path_rec, and the ROUTE_RESOLVED case writes path_rec[0].sl before it calls into the transport. The iWARP transport was dropped long ago and IB is the only transport left, so make that explicit: initialize trans to &rds_ib_transport at declaration, drop the conditional assignment, reject a connect request that arrives on a non-IB device, and drop a connection whose address resolved to one instead of resolving a route on it. The rejection is limited to RDMA_CM_EVENT_CONNECT_REQUEST on purpose: a non-zero return from the handler makes rdma_cm destroy the id the event was delivered on, which is right for the request's freshly created id but would free a connection id that RDS still owns for any other event. On the active side the id stays ic->i_cm_id and the connection's shutdown destroys it, so that case returns 0. [achender: reject only on RDMA_CM_EVENT_CONNECT_REQUEST instead of bailing out for every event on a non-IB device, so that rdma_cm does not destroy connection ids RDS still tracks; drop a connection whose address resolved to a non-IB device before a route is resolved on it; changelog adjusted]