From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAD8330C34A for ; Sun, 26 Apr 2026 14:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777214590; cv=none; b=jp5bw3BOTzS0mglJL/5M9eNthoW0sZhoy7z/dmZlv2xJPXV3YbOAgx7q/sg+Cr+SEsBd0Nu7UhuIXR10JGcHJYxjsmg6Aw7k9U9Ahc6BtnE4w6G4Ya+IzQDzTynDgrPi+yqgw18ZCa8oOZopVJiCi8qts8/Zh7ptaZJe8TEU30g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777214590; c=relaxed/simple; bh=BkKTDP/QdqV60QGLaKXzoX1Zq58loiHiNgpiGqts+0s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KHmhn3AfFaKp4n0EupWypPBOZb/l8P52HgaTc73CxFYXFrQYg1dXxLKMU8jXYLkTDv7ah0v9kGlhYzKeFQRaa2H31LzeJfCKpu0tEusOhyut45MHSQM0idls2uwHLIzFxnUOwN4I7jLzmC7psMGUaUO10VIqePdCTTEPs4Mihq0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jkcWGcvL; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jkcWGcvL" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4891e86fabeso98669785e9.1 for ; Sun, 26 Apr 2026 07:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777214587; x=1777819387; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=N+fDrQ0imKcqjUd0pDltukSNKPmoj5xTHANz+kyGdM0=; b=jkcWGcvLacvY1y6WGFllv6v7k7ED4TRa3i14ALbEC7TghNb9zGdC71BMTJRy9//uvO llYPnBZrm0G7mQbNm/Hv9kF0XDnBEra8D+rHbanRqd68LyB13ee37r2bKC14XdLJX/51 EcgKC2RQvE1H8p6pSbepiP4f288z5BWzpJxNKwb+VbrqFys4xF94nK1F7u9D93FpIPaG M1LeienPJrW+cKp2OTPDoVEmQ2fWM7vvkI9jXgxGg9a+SY+AohMYNW/Pui+fWbJcxGXZ 5Yq8ovY9UKJHEwdsL9Kbznz1imtVkYkGqvycEuP3jAjoKNTTodjd0GaNQzAxR8ZhBVlr QBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777214587; x=1777819387; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=N+fDrQ0imKcqjUd0pDltukSNKPmoj5xTHANz+kyGdM0=; b=nRoRZK1J+ifAx112hjEFuPO9FWWTJi3cVscp0M+FBasDusk5MlVOf1ZY6R5IfWi4di NHGv4nPDtC+K1S4t0FaWDMR7pWvJlhu2tUaeHIWeAi4029cF0r4um3NBOUQAUUBnfM30 rs8Z09qbGrMHxtBz+UA/V1+a3bTkqcgBYRGUIUMY8UStXN/iW041g6ntc8C+JCFp9VSg wpFpHoT+94tkCZX7yQ+4I0y6CTliysw4v5vWdLKlVFhL3S4+llkSKcwlfDPA2LLr/Yoh u2378mPtdSfVDsW7Ie4iaZA1eG4/E+QdDdoOCCIv8nsxQVbLYYbTsXHoDuYyWEbN4alP reOg== X-Forwarded-Encrypted: i=1; AFNElJ8egoAm+YRRXqmw5fWXdiEb89V/n5Qq1g4Ie4K/iAPnzDsBzA8HKhnfSiay3Trv09opYYHLE1X2Vom03WY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9IcYLFwV6mqClaA0DVINAvNyeeqgAVovbsMU/od1oGwf1/zOQ uy92lnAqU5kactUAuL3kW7xavhkbKplSQe4Q2ZIh/Sg+IcAXai+vnPVK X-Gm-Gg: AeBDievUPwPs274TWuVCvQe2JufLXYlFb7nUUYCBd50r8qO88UWfsghIAh9WtVv0c5y e3Ev/qe79DP0U9SvDZZO3V/T/7SUtP8o3tRCkd99hDUU4bZp5rXhP49LSSoeMwU1Q5H4VYSJ0RT lCM/F6riVdzruZrMd9eib60akseD+gtX8gdFjI+kTgfOE9GY6ozaKYqRwhfM7I486FrNa+INYOu /pDrSj7INale0xh/yPG+JvQEYvWVai76Kv3jfHHp0rA9VIn3q3A30Ihx48DUQLQIFMocg6XhU2i yz1lGLbcSPOddtq9YuU7u3ZoQi20VMV39CuUzdQ4mE/kS4gqmHVq/WNLzrmOAvbahIuqmbzxlw4 uhhyHPbWDgK9nHBgjKE3WRwVFg506MIEDZxd+S18c6+ZcXHBNuiIyB83J4Kgy6BVQZ1fGSGgmNA bLEWA8av5HTptqCw+cKhLrdKwZzK/x7XIu4EQn69JBrRjJApxhUXOrTe0THpmUVrv52lrEGZbRC Li7X/G6feRgSkPI0VBUUBjDfg== X-Received: by 2002:a05:600c:308a:b0:489:6c22:e081 with SMTP id 5b1f17b1804b1-4896c22e217mr277337225e9.0.1777214586995; Sun, 26 Apr 2026 07:43:06 -0700 (PDT) Received: from ubuntu-f6bvp (lfbn-idf1-1-366-193.w86-195.abo.wanadoo.fr. [86.195.82.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc18bccfsm658230335e9.8.2026.04.26.07.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 07:43:06 -0700 (PDT) From: Bernard Pidoux To: netdev@vger.kernel.org Cc: linux-hams@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, Bernard Pidoux Subject: [PATCH net 0/5] rose: fix use-after-free and reference counting bugs Date: Sun, 26 Apr 2026 16:43:00 +0200 Message-ID: <20260426144305.984349-1-bernard.f6bvp@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series fixes several bugs in the ROSE protocol loopback path and state machines, all confirmed by KASAN on a live system. A long-standing practical consequence of these bugs is that once the rose module has been used to establish at least one connection, it can no longer be unloaded cleanly: rmmod(8) hangs or causes a kernel crash because outstanding references and running timers prevent the module from completing its exit path. Patches 2 and 3 together fix this by ensuring the loopback timer stops cleanly and all neighbour references are released on module exit. Patch 1 fixes a device reference leak in rose_loopback_timer(): dev_put() was only called on the failure path of rose_rx_call_request(), leaking a reference on every successful loopback CALL_REQUEST. It also removes a dead check that can never be true for the loopback neighbour. Patch 2 adds hold/put protection around the loopback timer body so that rose_loopback_neigh cannot be freed while the callback is running. Patch 3 fixes a race between the loopback timer and module removal by switching rose_loopback_clear() to timer_delete_sync() and adding an atomic loopback_stopping flag that prevents the timer from re-arming itself after module exit has started. Patch 4 clears rose->neighbour to NULL after every rose_neigh_put() call in the ROSE state machines (rose_in.c), preventing use of a potentially freed pointer by later code paths. Patch 5 guards the rose_neigh_put() call in rose_timer_expiry() STATE_2 against a NULL pointer that can appear when a concurrent teardown path (e.g. rose_kill_by_device()) has already cleared the neighbour pointer between a timer re-arm and the next firing. Bernard Pidoux (5): rose: fix dev_put() leak in rose_loopback_timer() rose: hold loopback neighbour reference across timer callback rose: fix race between loopback timer and module removal rose: clear neighbour pointer after rose_neigh_put() in state machines rose: guard rose_neigh_put() against NULL in timer expiry net/rose/rose_in.c | 6 +++++ net/rose/rose_loopback.c | 53 +++++++++++++++++++++++++++------------- net/rose/rose_timer.c | 5 +++- 3 files changed, 46 insertions(+), 18 deletions(-) -- 2.51.0