* [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
@ 2026-06-15 17:21 Bernard Pidoux
2026-06-16 2:36 ` Greg KH
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-06-15 17:21 UTC (permalink / raw)
To: Jakub Kicinski, stable; +Cc: gregkh, linux-hams
Hello Jakub, Greg, and stable maintainers,
(Resending in plain text; the previous copy was rejected by the lists
because it carried an HTML part.)
I am Bernard Pidoux, F6BVP, an old-timer ham radio user of the Linux
ROSE implementation. ROSE and AX.25 no longer have an official kernel
maintainer; I am one of the people still running this code on real
nodes and fixing it when it breaks.
Over the past weeks a series of fifteen memory-safety fixes for
net/rose that I wrote was reviewed and merged by Jakub Kicinski into
linux-netdev/mod-orphan. They fix real, reproducible kernel bugs that
affect any node running AX.25 networking over the ROSE protocol:
- several use-after-free conditions in the ROSE teardown paths
(neighbour timers fired after free, socket freed under an open fd,
sockets reaped from the heartbeat while still owned by userspace);
- a rose_neigh refcount underflow in rose_kill_by_device();
- netdev reference double-holds in rose_make_new() and
rose_rx_call_request();
- dev_put()/neighbour reference leaks in the loopback timer path;
- a notifier unregistered too early in rose_exit().
These are crash bugs (use-after-free writes, refcount underflow) that a
remote peer or normal session teardown can trigger. They have been
soak-tested on production ROSE nodes and confirmed to remove the
crashes and the kmemleak reports.
The problem is the path to the stable trees. ROSE was removed from
mainline in 7.1 and is now unmaintained, so these fixes were merged
into the out-of-tree mod-orphan repository rather than into Linus'
tree, and therefore have no mainline commit ID. The normal
"cherry-pick from upstream SHA" stable procedure cannot apply.
However the affected code is still present and still buggy in every
stable series that predates the removal: 7.0.y first of all (the last
line that ships net/rose), and the older long-term branches that carry
essentially the same ROSE code. Distributions tracking those kernels
currently ship the crashes with no official way to receive the fix.
My request: would you accept these as stable-only patches applied to
7.0.y and to the earlier stable series that still contain net/rose, so
that distributions pick them up? If a stable-only submission is the
right vehicle, I will send the series rebased per target branch, each
patch with a proper changelog and the bug it fixes; if you would rather
route them another way, please tell me and I will prepare whatever form
you need.
I can attach the patches in git-format-patch form for any branch you
name.
Thank you for considering this. ROSE is a small and quiet corner of the
kernel, but the nodes that run it are real, and these fixes matter to
them.
73,
Bernard Pidoux, F6BVP
bernard.f6bvp@gmail.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-06-15 17:21 [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) Bernard Pidoux
@ 2026-06-16 2:36 ` Greg KH
[not found] ` <CAFAa3YBciYSJxDT-SH=4oppyBS3hWUSEwJP_86EgUriJfYkjLw@mail.gmail.com>
0 siblings, 1 reply; 23+ messages in thread
From: Greg KH @ 2026-06-16 2:36 UTC (permalink / raw)
To: Bernard Pidoux; +Cc: Jakub Kicinski, stable, linux-hams
On Mon, Jun 15, 2026 at 07:21:21PM +0200, Bernard Pidoux wrote:
> Hello Jakub, Greg, and stable maintainers,
>
> (Resending in plain text; the previous copy was rejected by the lists
> because it carried an HTML part.)
>
> I am Bernard Pidoux, F6BVP, an old-timer ham radio user of the Linux
> ROSE implementation. ROSE and AX.25 no longer have an official kernel
> maintainer; I am one of the people still running this code on real
> nodes and fixing it when it breaks.
>
> Over the past weeks a series of fifteen memory-safety fixes for
> net/rose that I wrote was reviewed and merged by Jakub Kicinski into
> linux-netdev/mod-orphan. They fix real, reproducible kernel bugs that
> affect any node running AX.25 networking over the ROSE protocol:
>
> - several use-after-free conditions in the ROSE teardown paths
> (neighbour timers fired after free, socket freed under an open fd,
> sockets reaped from the heartbeat while still owned by userspace);
> - a rose_neigh refcount underflow in rose_kill_by_device();
> - netdev reference double-holds in rose_make_new() and
> rose_rx_call_request();
> - dev_put()/neighbour reference leaks in the loopback timer path;
> - a notifier unregistered too early in rose_exit().
>
> These are crash bugs (use-after-free writes, refcount underflow) that a
> remote peer or normal session teardown can trigger. They have been
> soak-tested on production ROSE nodes and confirmed to remove the
> crashes and the kmemleak reports.
>
> The problem is the path to the stable trees. ROSE was removed from
> mainline in 7.1 and is now unmaintained, so these fixes were merged
> into the out-of-tree mod-orphan repository rather than into Linus'
> tree, and therefore have no mainline commit ID. The normal
> "cherry-pick from upstream SHA" stable procedure cannot apply.
>
> However the affected code is still present and still buggy in every
> stable series that predates the removal: 7.0.y first of all (the last
> line that ships net/rose), and the older long-term branches that carry
> essentially the same ROSE code. Distributions tracking those kernels
> currently ship the crashes with no official way to receive the fix.
>
> My request: would you accept these as stable-only patches applied to
> 7.0.y and to the earlier stable series that still contain net/rose, so
> that distributions pick them up? If a stable-only submission is the
> right vehicle, I will send the series rebased per target branch, each
> patch with a proper changelog and the bug it fixes; if you would rather
> route them another way, please tell me and I will prepare whatever form
> you need.
Great questions, I was waiting for something like this to eventually
happen :)
Ideally, we would just backport the "delete the code" changes, and then
distros can use your external module for their older systems, if they
care/want to, BUT that will increase the load on you to support older
kernel versions, which isn't very fair for you as in the end, you will
be getting bizarre requests from dead^Wenterprise distros asking you to
support 10+ year old kernels...
So let's try the other way, yes, I'll gladly take patches that you have
applied to your tree to fix issues in older kernels. One request,
please use the same git id that you use in your repo as the "backported
from" git id that is in the stable message, so that we can track them
properly across different stable releases (the ecosystem has lots of
tools that rely on this.)
As for the format, whatever works for you is fine for us. Ideally a
mbox full of patches, but we can take anything as long as we can
eventually turn it into a patch that we can apply. How about trying one
set of backports first so we can see how well the process works to
smooth out the details?
Oh, and of course, thanks for stepping up and offering to do this work,
it's much appreciated.
greg k-h
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
[not found] ` <2026062048-posted-scarf-dcf2@gregkh>
@ 2026-06-20 10:37 ` Bernard Pidoux
2026-06-20 10:51 ` Greg KH
2026-06-21 13:47 ` Sasha Levin
0 siblings, 2 replies; 23+ messages in thread
From: Bernard Pidoux @ 2026-06-20 10:37 UTC (permalink / raw)
To: kuba, stable; +Cc: gregkh, linux-hams
[-- Attachment #1: Type: text/plain, Size: 1666 bytes --]
Hi Greg, all,
Sorry about that -- my mail client dropped the list and Jakub from the
recipients on the previous message; I did not intend to take it off-list.
Resending the same note to everyone, with the mbox attached again.
I have prepared a first set, attached as an mbox: 15 ROSE fixes for the
7.0.y stable tree (7.0.y is the last stable line that still ships ROSE,
since it was removed in 7.1). They are the use-after-free, refcount and
teardown-race fixes I developed and merged in the linux-netdev/mod-orphan
tree, where ROSE now lives.
As Greg asked, every patch carries a
(cherry picked from commit <id>)
trailer pointing at the exact git id in mod-orphan it was taken from, so
they can be tracked across releases.
The whole series applies cleanly with "git am" on top of v7.0.13 (no
conflicts, no fuzz). The 15 fixes form one coherent set -- the three
core UAF fixes build on the earlier refactors in the same series, so they
cannot be cherry-picked in isolation; this is why I send the full set as
the first batch.
Please let me know if you would prefer a different format (individual
mails via git send-email, extra trailers, etc.) and I will adjust. I am
happy to follow up once this batch has gone through.
Thanks again,
Bernard, F6BVP
Le sam. 20 juin 2026 à 12:27, Greg KH <gregkh@linuxfoundation.org> a écrit :
>
> On Sat, Jun 20, 2026 at 12:24:55PM +0200, Bernard Pidoux wrote:
> > Hi Greg,
>
> <snip>
>
> For some reason you sent this only to me, which is a bit rude to
> everyone else on the mailing list. I'll be glad to respond if you
> resend it to everyone.
>
> thanks,
>
> greg k-h
[-- Attachment #2: rose-7.0.13-backport.mbox --]
[-- Type: application/mbox, Size: 36226 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-06-20 10:37 ` Bernard Pidoux
@ 2026-06-20 10:51 ` Greg KH
2026-06-20 12:42 ` Bernard Pidoux
2026-06-21 13:47 ` Sasha Levin
1 sibling, 1 reply; 23+ messages in thread
From: Greg KH @ 2026-06-20 10:51 UTC (permalink / raw)
To: Bernard Pidoux; +Cc: kuba, stable, linux-hams
On Sat, Jun 20, 2026 at 12:37:16PM +0200, Bernard Pidoux wrote:
> Hi Greg, all,
>
> Sorry about that -- my mail client dropped the list and Jakub from the
> recipients on the previous message; I did not intend to take it off-list.
> Resending the same note to everyone, with the mbox attached again.
>
> I have prepared a first set, attached as an mbox: 15 ROSE fixes for the
> 7.0.y stable tree (7.0.y is the last stable line that still ships ROSE,
> since it was removed in 7.1). They are the use-after-free, refcount and
> teardown-race fixes I developed and merged in the linux-netdev/mod-orphan
> tree, where ROSE now lives.
>
> As Greg asked, every patch carries a
>
> (cherry picked from commit <id>)
>
> trailer pointing at the exact git id in mod-orphan it was taken from, so
> they can be tracked across releases.
>
> The whole series applies cleanly with "git am" on top of v7.0.13 (no
> conflicts, no fuzz). The 15 fixes form one coherent set -- the three
> core UAF fixes build on the earlier refactors in the same series, so they
> cannot be cherry-picked in isolation; this is why I send the full set as
> the first batch.
>
> Please let me know if you would prefer a different format (individual
> mails via git send-email, extra trailers, etc.) and I will adjust. I am
> happy to follow up once this batch has gone through.
Great, does this series also apply to 6.18.y and/or any older trees? Or
should I just worry about this branch for now while we work out the
workflow?
And at first glance, this looks great. I'll try to apply these on
Monday and let you know how it goes.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-06-20 10:51 ` Greg KH
@ 2026-06-20 12:42 ` Bernard Pidoux
2026-06-25 11:04 ` Greg KH
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-06-20 12:42 UTC (permalink / raw)
To: gregkh; +Cc: kuba, stable, linux-hams
Hi Greg,
Thanks, much appreciated.
Short answer: yes, the same series applies to 6.18.y, and the same bugs
exist in the older trees too -- but only 7.0.y and 6.18.y take the series
as-is. ROSE was removed in 7.1, so every stable line up to and including
7.0.y still carries this code and is affected.
I just test-applied this exact mbox with "git am" against the current
ROSE files of each tree:
v7.0.13 : clean, 15/15 (what I sent you)
linux-6.18.y : clean, 15/15, no conflicts -- the teardown code is
identical to 7.0.13
linux-6.12.y : applies up to patch 3, then conflicts in
rose_loopback.c (the loopback/timer code predates one
of the refactors the series builds on)
linux-6.6.y / 6.1.y / 5.15.y : same, conflict at the same patch
So for 6.18.y I can send an identical batch right away. For 6.12.y and
the older LTS lines the fixes are still needed, but they need a rebased
backport rather than a straight cherry-pick; I'm happy to prepare those
per-tree once the format is settled.
My suggestion, matching what you said: let's land this 7.0.y batch first
to work out the workflow. As soon as it's in I'll send the (identical)
6.18.y batch, and then the rebased older-tree batches one line at a time.
Whatever order is easiest on your side works for me.
Thanks again,
Bernard, F6BVP
Le sam. 20 juin 2026 à 12:52, Greg KH <gregkh@linuxfoundation.org> a écrit :
>
> On Sat, Jun 20, 2026 at 12:37:16PM +0200, Bernard Pidoux wrote:
> > Hi Greg, all,
> >
> > Sorry about that -- my mail client dropped the list and Jakub from the
> > recipients on the previous message; I did not intend to take it off-list.
> > Resending the same note to everyone, with the mbox attached again.
> >
> > I have prepared a first set, attached as an mbox: 15 ROSE fixes for the
> > 7.0.y stable tree (7.0.y is the last stable line that still ships ROSE,
> > since it was removed in 7.1). They are the use-after-free, refcount and
> > teardown-race fixes I developed and merged in the linux-netdev/mod-orphan
> > tree, where ROSE now lives.
> >
> > As Greg asked, every patch carries a
> >
> > (cherry picked from commit <id>)
> >
> > trailer pointing at the exact git id in mod-orphan it was taken from, so
> > they can be tracked across releases.
> >
> > The whole series applies cleanly with "git am" on top of v7.0.13 (no
> > conflicts, no fuzz). The 15 fixes form one coherent set -- the three
> > core UAF fixes build on the earlier refactors in the same series, so they
> > cannot be cherry-picked in isolation; this is why I send the full set as
> > the first batch.
> >
> > Please let me know if you would prefer a different format (individual
> > mails via git send-email, extra trailers, etc.) and I will adjust. I am
> > happy to follow up once this batch has gone through.
>
> Great, does this series also apply to 6.18.y and/or any older trees? Or
> should I just worry about this branch for now while we work out the
> workflow?
>
> And at first glance, this looks great. I'll try to apply these on
> Monday and let you know how it goes.
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-06-20 10:37 ` Bernard Pidoux
2026-06-20 10:51 ` Greg KH
@ 2026-06-21 13:47 ` Sasha Levin
1 sibling, 0 replies; 23+ messages in thread
From: Sasha Levin @ 2026-06-21 13:47 UTC (permalink / raw)
To: kuba, stable; +Cc: Sasha Levin, gregkh, linux-hams, Bernard Pidoux
> I have prepared a first set, attached as an mbox: 15 ROSE fixes for the
> 7.0.y stable tree [...] The whole series applies cleanly with "git am"
> on top of v7.0.13 [...] The 15 fixes form one coherent set [...] this is
> why I send the full set as the first batch.
Thanks Bernard. No objection from me on the series. Since Greg has said
he'll apply the 7.0.y batch himself (and these come straight from the
mod-orphan tree rather than from a mainline SHA), I'll leave him to drive
landing 7.0.y first and then the identical 6.18.y batch, and I'll pick up
the rebased older-tree batches once you send them per-tree.
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-06-20 12:42 ` Bernard Pidoux
@ 2026-06-25 11:04 ` Greg KH
[not found] ` <CAFAa3YAkgv9t==Xeh4hqTVCq3+hN1igwqWXPOu3gHmD54Wd2Kw@mail.gmail.com>
0 siblings, 1 reply; 23+ messages in thread
From: Greg KH @ 2026-06-25 11:04 UTC (permalink / raw)
To: Bernard Pidoux; +Cc: kuba, stable, linux-hams
On Sat, Jun 20, 2026 at 02:42:17PM +0200, Bernard Pidoux wrote:
> Hi Greg,
>
> Thanks, much appreciated.
>
> Short answer: yes, the same series applies to 6.18.y, and the same bugs
> exist in the older trees too -- but only 7.0.y and 6.18.y take the series
> as-is. ROSE was removed in 7.1, so every stable line up to and including
> 7.0.y still carries this code and is affected.
>
> I just test-applied this exact mbox with "git am" against the current
> ROSE files of each tree:
>
> v7.0.13 : clean, 15/15 (what I sent you)
> linux-6.18.y : clean, 15/15, no conflicts -- the teardown code is
> identical to 7.0.13
Great, I've applied these to both now.
> linux-6.12.y : applies up to patch 3, then conflicts in
> rose_loopback.c (the loopback/timer code predates one
> of the refactors the series builds on)
> linux-6.6.y / 6.1.y / 5.15.y : same, conflict at the same patch
>
> So for 6.18.y I can send an identical batch right away. For 6.12.y and
> the older LTS lines the fixes are still needed, but they need a rebased
> backport rather than a straight cherry-pick; I'm happy to prepare those
> per-tree once the format is settled.
>
> My suggestion, matching what you said: let's land this 7.0.y batch first
> to work out the workflow. As soon as it's in I'll send the (identical)
> 6.18.y batch, and then the rebased older-tree batches one line at a time.
> Whatever order is easiest on your side works for me.
What you sent was fine, no problems, if that works for you, it's fine
for me.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
[not found] ` <2026093015-outmost-shrimp-45f8@gregkh>
@ 2026-10-15 18:49 ` Bernard Pidoux
2026-10-17 3:00 ` Sasha Levin
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-10-15 18:49 UTC (permalink / raw)
To: gregkh; +Cc: stable, sashal, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 3610 bytes --]
Hi Greg,
One more ROSE fix for 6.18.y, and this one matters: it fixes a
regression from one of my own earlier patches.
Commit df12be096302 ("rose: release netdev ref and destroy orphaned
incoming sockets"), which is in 6.18.y, lets the heartbeat free an
incoming socket whose call was cleared before accept(), while the call's
skb still sits on the listener's queue pointing at it. Closing the
listener, or a later accept(), then touches the freed socket. On a KASAN
kernel this shows as a slab-use-after-free in rose_destroy_socket()
followed by a kernel panic; on a stock 6.1 i686 kernel with the same
module code it is a plain NULL pointer Oops and panic.
The fix, "rose: hold a reference on incoming sockets queued for
accept()", is now merged in linux-netdev/mod-orphan as commit
6b0223a4795f5db52dee038a7a29e9906122b0f7, and that is the id in the
"(cherry picked from commit ...)" trailer of the attached mbox. It
applies cleanly with "git am" on top of v6.18.57 (no conflicts, no
fuzz). It has been running on six production nodes (x86_64, arm64 and
32-bit armv7) since late September with no further reports.
6.12.y does not need it: Sasha dropped df12be096302 from the 6.12 queue
after my report, and the 6.12.y heartbeat code (checked on v6.12.113)
does not reap these sockets, so the bug is not there.
Thanks again,
Bernard, F6BVP
Le mer. 30 sept. 2026 à 16:25, Greg KH <gregkh@linuxfoundation.org> a écrit :
>
> On Sat, Sep 12, 2026 at 01:16:56PM +0200, Bernard Pidoux wrote:
> > Hi Greg,
> >
> > While that 6.12.y batch is pending review, here are four more independent
> > ROSE fixes for 6.18.y, which already carries the earlier fifteen-patch
> > series. (I notice 7.0.y no longer appears on the stable releases page -- I
> > assume it is EOL now that 7.1 is out, so I am not including it here; let me
> > know if you would still like a copy for it.) Each is a single
> > self-contained commit, already reviewed and merged in
> > linux-netdev/mod-orphan (where AX.25/ROSE/NetRom now live since their
> > removal from mainline in 7.1):
> >
> > - Patch 1 closes a routing-loop amplification bug: rose_route_frame()
> > deleted the route for an incoming CALL REQUEST before checking whether it
> > was a routing loop, so two nodes whose routes pointed at each other would
> > relay the same call back and forth as fast as the CPU allowed. Observed in
> > production: 204 million frames over nine days on a link that normally
> > carries a few frames per minute.
> >
> > - Patch 2 fixes a NULL pointer dereference:
> > rose_kick()/rose_write_internal() could reach rose_transmit_link() with a
> > NULL neighbour once the state machines clear it. Reproduced on a live BBS
> > node.
> >
> > - Patch 3 closes a use-after-free that matches an open syzbot report (KASAN
> > slab-use-after-free in ax25_find_cb()) which had resisted bisection: the
> > self-rearming t0timer could fire again on freed memory even after
> > timer_delete_sync(), which only guarantees the callback is not running at
> > the moment it returns.
> >
> > - Patch 4 silences two harmless "unknown %02X in state 3" warnings (stray
> > CALL_ACCEPTED / CLEAR_CONFIRMATION) that are routinely dropped anyway and
> > alarm sysops watching the console for no reason.
> >
> > Attached is the mbox: all four apply cleanly with "git am" against the
> > current head of 6.18.y (no conflicts, no fuzz). Each patch carries a
> > "(cherry picked from commit <id>)" trailer pointing at the exact mod-orphan
> > git id.
>
> All now applied, thanks.
>
> greg k-h
[-- Attachment #2: rose-pr25-6.18.y.mbox --]
[-- Type: application/mbox, Size: 5563 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-15 18:49 ` Bernard Pidoux
@ 2026-10-17 3:00 ` Sasha Levin
2026-10-17 18:04 ` Bernard Pidoux
0 siblings, 1 reply; 23+ messages in thread
From: Sasha Levin @ 2026-10-17 3:00 UTC (permalink / raw)
To: gregkh; +Cc: Sasha Levin, stable, kuba, linux-hams, Bernard Pidoux
> One more ROSE fix for 6.18.y, and this one matters: it fixes a
> regression from one of my own earlier patches.
Queued for 6.18, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-17 3:00 ` Sasha Levin
@ 2026-10-17 18:04 ` Bernard Pidoux
2026-10-19 11:11 ` Bernard Pidoux
2026-10-19 20:55 ` [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) Sasha Levin
0 siblings, 2 replies; 23+ messages in thread
From: Bernard Pidoux @ 2026-10-17 18:04 UTC (permalink / raw)
To: gregkh; +Cc: sashal, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 2663 bytes --]
Hi Greg, Sasha,
Thanks for queuing the regression fix for 6.18.
Now that the fix is merged in mod-orphan, here is the matching batch
for 6.12.y, as announced on October 1st when Sasha dropped five ROSE
patches from the 6.12 queue.
On October 15th I wrote that 6.12.y did not need the fix.
That is true of 6.12.y as it is today, since it does not carry df12be096302.
This batch brings df12be096302 back together with its fix.
The attached mbox has ten patches.
Each one carries a "(cherry picked from commit <id>)" trailer with the
mod-orphan git id.
1. Patches 1-5 are the five patches dropped from the 6.12 queue on
October 1st, in their original order and unchanged from the copy you
had queued:
rose: set SOCK_DESTROY in rose_kill_by_device() for prompt cleanup
rose: disconnect orphaned STATE_2 sockets when device is gone
rose: release netdev ref and destroy orphaned incoming sockets
rose: clear neighbour pointer in rose_kill_by_device()
rose: don't free fd-owned sockets when reaping in the heartbeat
2. Patches 6-9 are the four fixes you applied to 6.18.y on September
30th, now in 6.18.55:
rose: keep the route needed for routing loop detection
rose: guard rose_transmit_link() against a NULL neighbour
rose: use timer_shutdown_sync() for t0timer teardown
rose: don't warn on stray CALL_ACCEPTED/CLEAR_CONFIRMATION in state 3
3. Patch 10 is the regression fix queued for 6.18 today:
rose: hold a reference on incoming sockets queued for accept()
It must come after patch 3.
One backport adjustment: patch 8 differs from mod-orphan by context
only, because 6.12 still calls del_timer_sync() in
rose_remove_neigh().
The fix itself is unchanged, and timer_shutdown_sync() is available in 6.12.
This is noted in the commit message.
Testing:
- the mbox applies with "git am" on top of v6.12.113, with no
conflicts and no fuzz;
- each patch builds on its own (net/rose, W=1, KASAN enabled), with no warnings;
- after the series, net/rose in 6.12.y matches 6.18.57 plus the queued
fix, apart from the expected API differences (from_timer(),
del_timer(), the bind() prototype and sk_filter_trim_cap()).
The same fixes have been running in the out-of-tree modules on our
production nodes (6.18 and 7.0 kernels) since late September.
None of our nodes runs 6.12, so on 6.12 the series is build-tested only.
Thanks again,
Bernard, F6BVP
Le sam. 17 oct. 2026 à 05:00, Sasha Levin <sashal@kernel.org> a écrit :
>
> > One more ROSE fix for 6.18.y, and this one matters: it fixes a
> > regression from one of my own earlier patches.
>
> Queued for 6.18, thanks.
>
> --
> Thanks,
> Sasha
[-- Attachment #2: rose-6.12.113-stable.mbox --]
[-- Type: application/mbox, Size: 34873 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-17 18:04 ` Bernard Pidoux
@ 2026-10-19 11:11 ` Bernard Pidoux
2026-10-19 20:55 ` Sasha Levin
2026-10-19 20:55 ` [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) Sasha Levin
1 sibling, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-10-19 11:11 UTC (permalink / raw)
To: gregkh; +Cc: sashal, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 4723 bytes --]
Hi Greg, Sasha,
Here are two more fixes for 6.12.y and 6.18.y.
They were merged in mod-orphan in September, but I left them out of my
earlier batches by mistake.
1. ax25: bound REJ-driven fast retransmits with the existing N2 counter
(mod-orphan commit a3aa611e37d4)
A REJ received in state 3 triggers an immediate retransmit and never
counts towards N2.
A link that keeps receiving REJs therefore retransmits at wire speed for ever.
We measured about 5900 frames per second on one of our links, and
Chris Maness, KQ6UP, reported the same storm on a plain AX.25 link.
After N2 REJ-driven retransmits without progress, the link now falls
back to the paced state 4 enquiry, like every other recovery path in
this state machine.
2. rose: purge rose_neigh->queue on final teardown
(mod-orphan commit e59e4523182e)
rose_neigh_put() frees the neighbour without emptying its frame queue,
so frames still queued there are leaked.
The queue is now purged when the last reference is dropped.
The two attached mboxes hold two patches each, one mbox per branch.
Each patch carries a "(cherry picked from commit <id>)" trailer with
the mod-orphan git id.
- 6.18.y: the mbox applies with "git am" on top of v6.18.57.
- 6.12.y: the mbox applies on top of the ten-patch 6.12.y series I
sent on October 17th.
Patch 2 depends on patch 8 of that series ("rose: use
timer_shutdown_sync() for t0timer teardown"), which changes the same
lines of rose_neigh_put().
Patch 1 also applies on v6.12.113 alone.
Testing:
- each patch builds (net/ax25 and net/rose, W=1, KASAN enabled), with
no warnings;
- checkpatch reports nothing;
- both fixes have been running on our production nodes since mid-September.
The mod-orphan commits carry my callsign as author name; the backports
use my real name.
Thanks,
Bernard, F6BVP
Le sam. 17 oct. 2026 à 20:04, Bernard Pidoux <bernard.f6bvp@gmail.com> a écrit :
>
> Hi Greg, Sasha,
>
> Thanks for queuing the regression fix for 6.18.
>
> Now that the fix is merged in mod-orphan, here is the matching batch
> for 6.12.y, as announced on October 1st when Sasha dropped five ROSE
> patches from the 6.12 queue.
> On October 15th I wrote that 6.12.y did not need the fix.
> That is true of 6.12.y as it is today, since it does not carry df12be096302.
> This batch brings df12be096302 back together with its fix.
>
> The attached mbox has ten patches.
> Each one carries a "(cherry picked from commit <id>)" trailer with the
> mod-orphan git id.
>
> 1. Patches 1-5 are the five patches dropped from the 6.12 queue on
> October 1st, in their original order and unchanged from the copy you
> had queued:
> rose: set SOCK_DESTROY in rose_kill_by_device() for prompt cleanup
> rose: disconnect orphaned STATE_2 sockets when device is gone
> rose: release netdev ref and destroy orphaned incoming sockets
> rose: clear neighbour pointer in rose_kill_by_device()
> rose: don't free fd-owned sockets when reaping in the heartbeat
>
> 2. Patches 6-9 are the four fixes you applied to 6.18.y on September
> 30th, now in 6.18.55:
> rose: keep the route needed for routing loop detection
> rose: guard rose_transmit_link() against a NULL neighbour
> rose: use timer_shutdown_sync() for t0timer teardown
> rose: don't warn on stray CALL_ACCEPTED/CLEAR_CONFIRMATION in state 3
>
> 3. Patch 10 is the regression fix queued for 6.18 today:
> rose: hold a reference on incoming sockets queued for accept()
> It must come after patch 3.
>
> One backport adjustment: patch 8 differs from mod-orphan by context
> only, because 6.12 still calls del_timer_sync() in
> rose_remove_neigh().
> The fix itself is unchanged, and timer_shutdown_sync() is available in 6.12.
> This is noted in the commit message.
>
> Testing:
> - the mbox applies with "git am" on top of v6.12.113, with no
> conflicts and no fuzz;
> - each patch builds on its own (net/rose, W=1, KASAN enabled), with no warnings;
> - after the series, net/rose in 6.12.y matches 6.18.57 plus the queued
> fix, apart from the expected API differences (from_timer(),
> del_timer(), the bind() prototype and sk_filter_trim_cap()).
>
> The same fixes have been running in the out-of-tree modules on our
> production nodes (6.18 and 7.0 kernels) since late September.
> None of our nodes runs 6.12, so on 6.12 the series is build-tested only.
>
> Thanks again,
> Bernard, F6BVP
>
>
> Le sam. 17 oct. 2026 à 05:00, Sasha Levin <sashal@kernel.org> a écrit :
> >
> > > One more ROSE fix for 6.18.y, and this one matters: it fixes a
> > > regression from one of my own earlier patches.
> >
> > Queued for 6.18, thanks.
> >
> > --
> > Thanks,
> > Sasha
[-- Attachment #2: rose-ax25-6.12.y-oublies.mbox --]
[-- Type: application/mbox, Size: 7884 bytes --]
[-- Attachment #3: rose-ax25-6.18.y-oublies.mbox --]
[-- Type: application/mbox, Size: 7884 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-17 18:04 ` Bernard Pidoux
2026-10-19 11:11 ` Bernard Pidoux
@ 2026-10-19 20:55 ` Sasha Levin
1 sibling, 0 replies; 23+ messages in thread
From: Sasha Levin @ 2026-10-19 20:55 UTC (permalink / raw)
To: gregkh; +Cc: Sasha Levin, stable, kuba, linux-hams, Bernard Pidoux
> Now that the fix is merged in mod-orphan, here is the matching batch
> for 6.12.y, as announced on October 1st when Sasha dropped five ROSE
> patches from the 6.12 queue.
Queued the series for 6.12, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-19 11:11 ` Bernard Pidoux
@ 2026-10-19 20:55 ` Sasha Levin
2026-10-21 17:25 ` Bernard Pidoux
0 siblings, 1 reply; 23+ messages in thread
From: Sasha Levin @ 2026-10-19 20:55 UTC (permalink / raw)
To: gregkh; +Cc: Sasha Levin, stable, kuba, linux-hams, Bernard Pidoux
> Here are two more fixes for 6.12.y and 6.18.y.
> They were merged in mod-orphan in September, but I left them out of my
> earlier batches by mistake.
Queued for 6.18 and 6.12, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-19 20:55 ` Sasha Levin
@ 2026-10-21 17:25 ` Bernard Pidoux
2026-10-23 20:02 ` Sasha Levin
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-10-21 17:25 UTC (permalink / raw)
To: gregkh; +Cc: sashal, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 4253 bytes --]
Hi Greg, Sasha,
Thanks for queuing the 6.12.y series and the two fixes from October
19th, and for 6.18.58.
Here is the rest of what has been merged in mod-orphan for AX.25,
NET/ROM and ROSE, for 6.12.y and 6.18.y.
None of these 26 patches has been sent to stable before.
Most are memory-safety and locking fixes, a few are protocol fixes
that stop links from hanging.
NET/ROM:
1. netrom: linearize and validate lengths in nr_rx_frame() (Stanislav Fort)
2. netrom: require full NET/ROM headers in nr_route_frame() (Greg Kroah-Hartman)
3. net: netrom: validate source address in nr_find_socket() (Mashiro Chen)
4. netrom: bound fragment reassembly in nr_queue_rx_frame()
5. netrom: use a single lock for the node and neighbour lists
6. netrom: look up and update routes in one critical section
7. netrom: fix reference count leak in nr_rt_device_down (Junjie Cao)
8. netrom: clear nr_neigh->ax25 under the routing lock in nr_link_failed()
9. netrom: fix nr_node leak when nr_del_node() removes the last route
AX.25:
10. ax25: fix OOB read after address header strip in ax25_rcv() (Ashutosh Desai)
11. ax25: check frame length in ax25_decode() and ax25_rx_iframe()
12. net: ax25: fix integer overflow in ax25_rx_fragment() (Mashiro Chen)
13. ax25: serialise the transmission of I frames on a connection
14. ax25: don't create two connections for the same link in ax25_send_frame()
15. ax25: read the connection's ax25_dev only once when walking ax25_list
16. ax25: wait for ax25_send_frame() before detaching the connections
of a device
17. ax25: don't accept frames on a device that is going down
18. ax25: send a private copy of each I frame
19. ax25: send unacknowledged I frames again when a link is re-established
20. ax25: don't free an incoming SABM skb left on the listener's queue
ROSE:
21. rose: clear stale N(R)/N(S) before (re)transmitting a data frame
22. rose: clear through routes when a neighbour is removed from the tables
23. rose: restart the link of a neighbour created over a live AX.25 connection
24. rose: process received frames and send with the socket locked
25. rose: clear the circuits of a neighbour that restarts the link
26. rose: bring up the link of the preferred route passed over by a
connect request
The list above is grouped by protocol.
In the mboxes, the patches follow the mod-orphan merge order, which
must be kept, since several of them touch the same functions.
The two attached mboxes hold the 26 patches, one mbox per branch.
Each patch carries a "(cherry picked from commit <id>)" trailer with
the mod-orphan git id.
- 6.18.y: the mbox applies with "git am" on top of v6.18.58 plus the
two patches queued on October 19th.
- 6.12.y: the mbox applies with "git am" on top of v6.12.114 plus the
twelve patches now in queue-6.12.
The backports are the mod-orphan commits with one change: patch 20
used kmalloc_obj(), which these branches do not have, and now uses
kmalloc(sizeof(ax25_digi), GFP_ATOMIC) as the surrounding code does.
I left out one mod-orphan commit, "rose: fix sk_filter_trim_cap()
compatibility across kernel versions", which only concerns building
the out-of-tree modules against several kernel versions.
As on my earlier batches, the mod-orphan commits carrying my callsign
as author name use my real name here.
Seven patches had a "Co-Authored-By:" line for the AI assistant I
used; in the backports it is an "Assisted-by:" line, as
Documentation/process asks.
Testing:
- each patch builds on both branches (net/ax25, net/netrom and
net/rose, W=1, KASAN enabled), with no warnings and no errors;
- checkpatch reports nothing beyond style remarks in the original commits;
- all 26 fixes are part of the module set running on our production
AX.25 / NET/ROM / ROSE nodes; the complete set has been in service
since October 17th, and the older patches since September.
Thanks,
Bernard, F6BVP
Le lun. 19 oct. 2026 à 22:55, Sasha Levin <sashal@kernel.org> a écrit :
>
> > Here are two more fixes for 6.12.y and 6.18.y.
> > They were merged in mod-orphan in September, but I left them out of my
> > earlier batches by mistake.
>
> Queued for 6.18 and 6.12, thanks.
>
> --
> Thanks,
> Sasha
[-- Attachment #2: rose-ax25-netrom-6.18.y-suite.mbox --]
[-- Type: application/mbox, Size: 126347 bytes --]
[-- Attachment #3: rose-ax25-netrom-6.12.y-suite.mbox --]
[-- Type: application/mbox, Size: 126347 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-21 17:25 ` Bernard Pidoux
@ 2026-10-23 20:02 ` Sasha Levin
2026-10-24 9:53 ` Bernard Pidoux
0 siblings, 1 reply; 23+ messages in thread
From: Sasha Levin @ 2026-10-23 20:02 UTC (permalink / raw)
To: gregkh; +Cc: Sasha Levin, stable, kuba, linux-hams, Bernard Pidoux
> [PATCH 6.12.y 02/26] netrom: linearize and validate lengths in nr_rx_frame()
>
> + /* nr_state1_machine() reads the window size at byte 20 */
> + if (frametype == NR_CONNACK &&
> + skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1) {
> + sock_put(sk);
> + return 0;
> + }
This check ignores the flag nibble, so it also drops CONNACK|CHOKE (0x82)
refusals. __nr_transmit_reply() builds those as 20-byte frames
(skb_put(NR_NETWORK_LEN + NR_TRANSPORT_LEN)), so a refused connect() no
longer gets ECONNREFUSED and times out after the T1/N2 retries, and CHOKE
resets of state 2 and 3 circuits are lost. nr_state1_machine() only reads
the window byte for a plain CONNACK.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-23 20:02 ` Sasha Levin
@ 2026-10-24 9:53 ` Bernard Pidoux
2026-10-24 20:11 ` Sasha Levin
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-10-24 9:53 UTC (permalink / raw)
To: sashal; +Cc: gregkh, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 2024 bytes --]
Hi Sasha,
You are right, thanks for catching it.
nr_rx_frame() masks the flag nibble off the frame type, so the length
check also hits CONNACK|CHOKE, and __nr_transmit_reply() sends those
as 20-byte frames.
Only the plain CONNACK case of nr_state1_machine() reads byte 20.
I reproduced it on a two-VM QEMU bench (6.12.y with this series,
KASAN, mkiss link), node A calling node B where nobody listens:
- with v1 of 02/26, the refusal is dropped and connect() is still
blocked after 15 seconds;
- with v2, connect() fails with ECONNREFUSED in 40 ms.
A plain CONNACK is still accepted: once B listens, the same call
connects and data flows.
No KASAN report in either run.
v2 of 02/26 is attached for 6.12.y and 6.18.y.
It applies the length check to a plain CONNACK only:
if (frametype == NR_CONNACK && !flags &&
skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1) {
Patches 03 to 26 apply unchanged on top of it, and net/netrom builds
with W=1 and KASAN on both branches, with no warning.
The same fix goes to mod-orphan as a follow-up to db51201afd46.
Thanks,
Bernard
Le ven. 23 oct. 2026 à 22:03, Sasha Levin <sashal@kernel.org> a écrit :
>
> > [PATCH 6.12.y 02/26] netrom: linearize and validate lengths in nr_rx_frame()
> >
> > + /* nr_state1_machine() reads the window size at byte 20 */
> > + if (frametype == NR_CONNACK &&
> > + skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1) {
> > + sock_put(sk);
> > + return 0;
> > + }
>
> This check ignores the flag nibble, so it also drops CONNACK|CHOKE (0x82)
> refusals. __nr_transmit_reply() builds those as 20-byte frames
> (skb_put(NR_NETWORK_LEN + NR_TRANSPORT_LEN)), so a refused connect() no
> longer gets ECONNREFUSED and times out after the T1/N2 retries, and CHOKE
> resets of state 2 and 3 circuits are lost. nr_state1_machine() only reads
> the window byte for a plain CONNACK.
>
> --
> Thanks,
> Sasha
[-- Attachment #2: 6.18.y-v2-02-26-netrom-nr_rx_frame.patch --]
[-- Type: text/x-patch, Size: 3736 bytes --]
From 9fc8ec7512274e47d40451ee42bf388e244d5e81 Mon Sep 17 00:00:00 2001
From: Stanislav Fort <disclosure@aisle.com>
Date: Fri, 25 Sep 2026 12:23:50 +0200
Subject: [PATCH 6.18.y v2 02/26] netrom: linearize and validate lengths in
nr_rx_frame()
Linearize skb and add targeted length checks in nr_rx_frame() to
prevent out-of-bounds reads when processing malformed NET/ROM frames.
- Require skb to be linear and at least NR_NETWORK_LEN +
NR_TRANSPORT_LEN (20 bytes) before reading network/transport fields.
- For the existing sockets path, ensure NR_CONNACK includes the window
byte (>= 21 bytes), which nr_state1_machine() reads.
- For CONNREQ handling, ensure window (byte 20) and user address
(bytes 21-27) are present (>= 28 bytes), and do so before
nr_find_listener() so no listener reference can leak.
- Preserve existing BPQ extension handling:
- NR_CONNACK len == 22 -> 1 extra byte (TTL)
- NR_CONNREQ len == 37 -> 2 extra bytes (timeout)
nr_route_frame() only guarantees 15 bytes before handing a frame
addressed to a local node to nr_rx_frame(), so a short frame received
from any AX.25 neighbour is enough to trigger the over-read.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Stanislav Fort <disclosure@aisle.com>
[F6BVP: v4 never reached mainline (whitespace-damaged posting, subsystem
removed in 7.1); rebased onto mod-orphan, added comments. Tested on a
two-VM QEMU bench (6.12.94, mkiss link): an AX.25 peer sends CONNREQ
frames truncated to 20 and 27 bytes; without this patch both are
accepted as connections, the user callsign being read past the end of
the frame; with it only the complete 35-byte CONNREQ is accepted.
v2: apply the CONNACK length check to a plain CONNACK only, so that
20-byte CONNACK|CHOKE refusals and resets are no longer dropped
(reported by Sasha Levin). Same fix submitted to mod-orphan.]
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
(cherry picked from commit db51201afd46992c9206fa79878badb2236bb7d3)
---
net/netrom/af_netrom.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 33468124d5..0e70d149ab 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -885,6 +885,11 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
* skb->data points to the netrom frame start
*/
+ if (skb_linearize(skb))
+ return 0;
+ if (skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN)
+ return 0;
+
src = (ax25_address *)(skb->data + 0);
dest = (ax25_address *)(skb->data + 7);
@@ -927,6 +932,17 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
}
if (sk != NULL) {
+ /*
+ * nr_state1_machine() reads the window size at byte 20, but
+ * only for a plain CONNACK. A CONNACK with the choke flag set
+ * is a refusal or a reset, sent as a 20-byte frame by
+ * __nr_transmit_reply(), and must not be dropped here.
+ */
+ if (frametype == NR_CONNACK && !flags &&
+ skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1) {
+ sock_put(sk);
+ return 0;
+ }
bh_lock_sock(sk);
skb_reset_transport_header(skb);
@@ -961,10 +977,14 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
return 0;
}
- sk = nr_find_listener(dest);
+ /* Need window (byte 20) and user address (bytes 21-27) */
+ if (skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1 + AX25_ADDR_LEN)
+ return 0;
user = (ax25_address *)(skb->data + 21);
+ sk = nr_find_listener(dest);
+
if (sk == NULL || sk_acceptq_is_full(sk) ||
(make = nr_make_new(sk)) == NULL) {
nr_transmit_refusal(skb, 0);
--
2.53.0
[-- Attachment #3: 6.12.y-v2-02-26-netrom-nr_rx_frame.patch --]
[-- Type: text/x-patch, Size: 3736 bytes --]
From 8624b05447631592d38258a46f082afc29e124f2 Mon Sep 17 00:00:00 2001
From: Stanislav Fort <disclosure@aisle.com>
Date: Fri, 25 Sep 2026 12:23:50 +0200
Subject: [PATCH 6.12.y v2 02/26] netrom: linearize and validate lengths in
nr_rx_frame()
Linearize skb and add targeted length checks in nr_rx_frame() to
prevent out-of-bounds reads when processing malformed NET/ROM frames.
- Require skb to be linear and at least NR_NETWORK_LEN +
NR_TRANSPORT_LEN (20 bytes) before reading network/transport fields.
- For the existing sockets path, ensure NR_CONNACK includes the window
byte (>= 21 bytes), which nr_state1_machine() reads.
- For CONNREQ handling, ensure window (byte 20) and user address
(bytes 21-27) are present (>= 28 bytes), and do so before
nr_find_listener() so no listener reference can leak.
- Preserve existing BPQ extension handling:
- NR_CONNACK len == 22 -> 1 extra byte (TTL)
- NR_CONNREQ len == 37 -> 2 extra bytes (timeout)
nr_route_frame() only guarantees 15 bytes before handing a frame
addressed to a local node to nr_rx_frame(), so a short frame received
from any AX.25 neighbour is enough to trigger the over-read.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Stanislav Fort <disclosure@aisle.com>
[F6BVP: v4 never reached mainline (whitespace-damaged posting, subsystem
removed in 7.1); rebased onto mod-orphan, added comments. Tested on a
two-VM QEMU bench (6.12.94, mkiss link): an AX.25 peer sends CONNREQ
frames truncated to 20 and 27 bytes; without this patch both are
accepted as connections, the user callsign being read past the end of
the frame; with it only the complete 35-byte CONNREQ is accepted.
v2: apply the CONNACK length check to a plain CONNACK only, so that
20-byte CONNACK|CHOKE refusals and resets are no longer dropped
(reported by Sasha Levin). Same fix submitted to mod-orphan.]
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
(cherry picked from commit db51201afd46992c9206fa79878badb2236bb7d3)
---
net/netrom/af_netrom.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 6ee148f0e6..4dac5ee58a 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -885,6 +885,11 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
* skb->data points to the netrom frame start
*/
+ if (skb_linearize(skb))
+ return 0;
+ if (skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN)
+ return 0;
+
src = (ax25_address *)(skb->data + 0);
dest = (ax25_address *)(skb->data + 7);
@@ -927,6 +932,17 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
}
if (sk != NULL) {
+ /*
+ * nr_state1_machine() reads the window size at byte 20, but
+ * only for a plain CONNACK. A CONNACK with the choke flag set
+ * is a refusal or a reset, sent as a 20-byte frame by
+ * __nr_transmit_reply(), and must not be dropped here.
+ */
+ if (frametype == NR_CONNACK && !flags &&
+ skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1) {
+ sock_put(sk);
+ return 0;
+ }
bh_lock_sock(sk);
skb_reset_transport_header(skb);
@@ -961,10 +977,14 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
return 0;
}
- sk = nr_find_listener(dest);
+ /* Need window (byte 20) and user address (bytes 21-27) */
+ if (skb->len < NR_NETWORK_LEN + NR_TRANSPORT_LEN + 1 + AX25_ADDR_LEN)
+ return 0;
user = (ax25_address *)(skb->data + 21);
+ sk = nr_find_listener(dest);
+
if (sk == NULL || sk_acceptq_is_full(sk) ||
(make = nr_make_new(sk)) == NULL) {
nr_transmit_refusal(skb, 0);
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-24 9:53 ` Bernard Pidoux
@ 2026-10-24 20:11 ` Sasha Levin
2026-10-25 9:41 ` Bernard Pidoux
0 siblings, 1 reply; 23+ messages in thread
From: Sasha Levin @ 2026-10-24 20:11 UTC (permalink / raw)
To: Bernard Pidoux; +Cc: Sasha Levin, gregkh, stable, kuba, linux-hams
> v2 of 02/26 is attached for 6.12.y and 6.18.y.
>
> Patches 03 to 26 apply unchanged on top of it, and net/netrom builds
> with W=1 and KASAN on both branches, with no warning.
>
> [PATCH 6.18.y 16/26] ax25: serialise the transmission of I frames on a connection
>
> + spin_lock_bh(&ax25->lock);
> if (ax25->va != nr) {
> while (skb_peek(&ax25->ack_queue) != NULL && ax25->va != nr) {
> skb = skb_dequeue(&ax25->ack_queue);
> - kfree_skb(skb);
> + __skb_queue_tail(&acked, skb);
Thanks for the v2 of 02/26. The series still can't go in as is, because
16/26 adds a NULL dereference in ax25_frames_acked(). ax25_clear_queues()
purges ack_queue without taking ax25->lock, so the skb_peek() check above
can be stale by the time skb_dequeue() runs, and skb_dequeue() can then
return NULL. The old kfree_skb(NULL) tolerated that, but
__skb_queue_tail(&acked, NULL) dereferences it in softirq context.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-24 20:11 ` Sasha Levin
@ 2026-10-25 9:41 ` Bernard Pidoux
2026-10-25 23:29 ` Sasha Levin
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-10-25 9:41 UTC (permalink / raw)
To: sashal; +Cc: gregkh, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
On Sat, Oct 24, 2026 10:11 PM, Sasha Levin <sashal@kernel.org> wrote:
> Thanks for the v2 of 02/26. The series still can't go in as is, because
> 16/26 adds a NULL dereference in ax25_frames_acked(). ax25_clear_queues()
> purges ack_queue without taking ax25->lock, so the skb_peek() check above
> can be stale by the time skb_dequeue() runs, and skb_dequeue() can then
> return NULL. The old kfree_skb(NULL) tolerated that, but
> __skb_queue_tail(&acked, NULL) dereferences it in softirq context.
Hi Sasha,
You are right again, thanks.
ax25_clear_queues() purges the ack queue without ax25->lock, so the
skb_peek() test in ax25_frames_acked() can be stale and skb_dequeue()
can return NULL, which __skb_queue_tail() then dereferences.
I reproduced it in QEMU (6.12.94, two 4-CPU nodes with lockdep and
KASAN over a KISS link, four ROSE circuits sending 400 messages each),
simulating ax25_clear_queues() once between the check and the
dequeue: KASAN null-ptr-deref and a panic in ax25_frames_acked()
from the receive path. With the fix, no report under the same
simulation, and 1600/1600 messages in order on three normal runs.
v2 of 16/26 is attached for 6.12.y and 6.18.y. The loop now tests
what skb_dequeue() returns:
while (ax25->va != nr && (skb = skb_dequeue(&ax25->ack_queue)) != NULL) {
Nothing else changes. Patches 17 to 26 apply unchanged on top of it,
and net/ax25 builds with W=1 and KASAN on both branches, with no
warning. The same fix is submitted to mod-orphan (pull request #42).
Out of curiosity, how did you spot these two? Is it part of an
automated review? I would like to run the same checks on the rest of
the AX.25, NET/ROM and ROSE code.
Thanks,
Bernard
[-- Attachment #2: 6.18.y-v2-16-26-ax25-serialise-I-frames.patch --]
[-- Type: text/x-patch, Size: 9268 bytes --]
From dec6e3b94da83a558396fe2e6b17e907471c5f06 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Thu, 1 Oct 2026 14:07:43 +0200
Subject: [PATCH 6.18.y v2 16/26] ax25: serialise the transmission of I frames
on a connection
ax25_kick() takes frames off the write queue, numbers them from V(S)
and moves them to the ack queue, with no lock. It is called from
process context by the senders (ax25_output()) and from softirq context
by the receive path and the timers. A connection used by ROSE or NET/ROM
carries several circuits, so ax25_output() can run for the same
connection on two CPUs at once, and against the receive path. Both then
read the same V(S) and two different I frames are sent under the same
N(S). The peer keeps the first and rejects the second; the go-back-N
that follows resends whatever the ack queue holds for that number, and
one of the two frames is never sent again while the AX.25 counters look
consistent on both sides. The layer above sees a hole: a ROSE circuit
receives its frames out of sequence, ignores them, and stays frozen
with its window full.
Seen on a live ROSE node relaying several circuits over one AX.25 link:
fm F6BVP-9 to F6BVP-13 ctl I55^ pid=1(X.25) len 254 LCI 030 DATA S2
fm F6BVP-9 to F6BVP-13 ctl I55^ pid=1(X.25) len 254 LCI 02E DATA S2
fm F6BVP-13 to F6BVP-9 ctl REJ6v
Add a lock to the ax25_cb covering V(S), V(A) and the write and ack
queues, taken in ax25_kick(), ax25_frames_acked() and
ax25_requeue_frames(). The frames are not sent with the lock held,
since ax25_transmit_buffer() may end up in ax25_disconnect(): ax25_kick()
puts the numbered frames on a transmit queue which is emptied, in
order, by one context at a time once the lock is dropped.
Tested in QEMU, two 4-CPU nodes with lockdep and KASAN over a KISS
serial link, four ROSE circuits each sending 400 numbered messages at
the same time: before, every circuit freezes and 300 to 600 of the 1600
messages get through; after, no sender is blocked and more than 1500
get through (the ROSE side needs "rose: process received frames and
send with the socket locked" for the rest: 1600/1600 in order on six
runs out of six with both). No lockdep, KASAN or refcount report.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
[F6BVP: v2: in ax25_frames_acked(), loop on what skb_dequeue() returns
instead of on skb_peek(): ax25_clear_queues() purges the ack queue
without ax25->lock, so skb_dequeue() could return NULL and
__skb_queue_tail() dereference it in softirq context (reported by
Sasha Levin). Same fix submitted to mod-orphan.]
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
(cherry picked from commit 3f42b974059565c9e60229a9ff1ca21d10334671)
---
include/net/ax25.h | 5 ++++
net/ax25/af_ax25.c | 2 ++
net/ax25/ax25_out.c | 56 ++++++++++++++++++++++++++++++++++++++++----
net/ax25/ax25_subr.c | 37 ++++++++++++++++++++++-------
4 files changed, 88 insertions(+), 12 deletions(-)
diff --git a/include/net/ax25.h b/include/net/ax25.h
index a7bba42dde..0fe92fa6ef 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -252,6 +252,11 @@ typedef struct ax25_cb {
struct sk_buff_head reseq_queue;
struct sk_buff_head ack_queue;
struct sk_buff_head frag_queue;
+ /* I frames numbered by ax25_kick(), waiting to go to the device */
+ struct sk_buff_head xmit_queue;
+ /* serialises V(S)/V(A) and the write, ack and xmit queues */
+ spinlock_t lock;
+ unsigned char xmit_running;
unsigned char window;
struct timer_list timer, dtimer;
struct sock *sk; /* Backlink to socket */
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 23c558ff96..d76fe0cbc5 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -537,6 +537,8 @@ ax25_cb *ax25_create_cb(void)
skb_queue_head_init(&ax25->frag_queue);
skb_queue_head_init(&ax25->ack_queue);
skb_queue_head_init(&ax25->reseq_queue);
+ skb_queue_head_init(&ax25->xmit_queue);
+ spin_lock_init(&ax25->lock);
ax25_setup_timers(ax25);
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index 8bca2ace98..1b9a91b9c9 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -218,6 +218,11 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
* This procedure is passed a buffer descriptor for an iframe. It builds
* the rest of the control part of the frame and then writes it out.
*/
+/*
+ * Number an I frame and queue it for the device. Called by ax25_kick()
+ * with ax25->lock held: the frame is sent by ax25_run_xmit_queue() once
+ * the lock is dropped.
+ */
static void ax25_send_iframe(ax25_cb *ax25, struct sk_buff *skb, int poll_bit)
{
unsigned char *frame;
@@ -245,7 +250,34 @@ static void ax25_send_iframe(ax25_cb *ax25, struct sk_buff *skb, int poll_bit)
ax25_start_idletimer(ax25);
- ax25_transmit_buffer(ax25, skb, AX25_COMMAND);
+ skb_queue_tail(&ax25->xmit_queue, skb);
+}
+
+/*
+ * Hand the frames numbered by ax25_kick() to the device, in order. Only
+ * one context does it at a time, so that frames queued by two senders
+ * cannot overtake each other; the one already running picks up whatever
+ * the others have queued. The lock is not held while transmitting.
+ */
+static void ax25_run_xmit_queue(ax25_cb *ax25)
+{
+ struct sk_buff *skb;
+
+ spin_lock_bh(&ax25->lock);
+ if (ax25->xmit_running) {
+ spin_unlock_bh(&ax25->lock);
+ return;
+ }
+ ax25->xmit_running = 1;
+
+ while ((skb = skb_dequeue(&ax25->xmit_queue)) != NULL) {
+ spin_unlock_bh(&ax25->lock);
+ ax25_transmit_buffer(ax25, skb, AX25_COMMAND);
+ spin_lock_bh(&ax25->lock);
+ }
+
+ ax25->xmit_running = 0;
+ spin_unlock_bh(&ax25->lock);
}
void ax25_kick(ax25_cb *ax25)
@@ -260,14 +292,25 @@ void ax25_kick(ax25_cb *ax25)
if (ax25->condition & AX25_COND_PEER_RX_BUSY)
return;
+ /*
+ * ax25_kick() is called from process context by the senders and
+ * from softirq context by the receive path and the timers, possibly
+ * for several ROSE or NET/ROM circuits sharing this connection. Two
+ * of them running here at the same time would read the same V(S) and
+ * send two different frames under the same N(S); the peer keeps one
+ * and the other is never sent again. Take the frames off the write
+ * queue and number them under the lock.
+ */
+ spin_lock_bh(&ax25->lock);
+
if (skb_peek(&ax25->write_queue) == NULL)
- return;
+ goto out;
start = (skb_peek(&ax25->ack_queue) == NULL) ? ax25->va : ax25->vs;
end = (ax25->va + ax25->window) % ax25->modulus;
if (start == end)
- return;
+ goto out;
/*
* Transmit data until either we're out of data to send or
@@ -281,7 +324,7 @@ void ax25_kick(ax25_cb *ax25)
*/
skb = skb_dequeue(&ax25->write_queue);
if (!skb)
- return;
+ goto out;
ax25->vs = start;
@@ -331,6 +374,11 @@ void ax25_kick(ax25_cb *ax25)
ax25_calculate_t1(ax25);
ax25_start_t1timer(ax25);
}
+
+out:
+ spin_unlock_bh(&ax25->lock);
+
+ ax25_run_xmit_queue(ax25);
}
void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type)
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 12c027bead..a1e33092e6 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -34,6 +34,7 @@ void ax25_clear_queues(ax25_cb *ax25)
{
skb_queue_purge(&ax25->write_queue);
skb_queue_purge(&ax25->ack_queue);
+ skb_queue_purge(&ax25->xmit_queue);
skb_queue_purge(&ax25->reseq_queue);
skb_queue_purge(&ax25->frag_queue);
}
@@ -45,31 +46,51 @@ void ax25_clear_queues(ax25_cb *ax25)
*/
void ax25_frames_acked(ax25_cb *ax25, unsigned short nr)
{
+ struct sk_buff_head acked;
struct sk_buff *skb;
+ __skb_queue_head_init(&acked);
+
/*
- * Remove all the ack-ed frames from the ack queue.
+ * Remove all the ack-ed frames from the ack queue. ax25_kick() may be
+ * filling it from another CPU: move V(A) and the queue together, and
+ * free the frames once the lock is dropped.
*/
- if (ax25->va != nr) {
- while (skb_peek(&ax25->ack_queue) != NULL && ax25->va != nr) {
- skb = skb_dequeue(&ax25->ack_queue);
- kfree_skb(skb);
- ax25->va = (ax25->va + 1) % ax25->modulus;
- }
+ spin_lock_bh(&ax25->lock);
+ /*
+ * ax25_clear_queues() purges the ack queue without ax25->lock: test
+ * what skb_dequeue() returns, not what skb_peek() saw before it.
+ */
+ while (ax25->va != nr && (skb = skb_dequeue(&ax25->ack_queue)) != NULL) {
+ __skb_queue_tail(&acked, skb);
+ ax25->va = (ax25->va + 1) % ax25->modulus;
}
+ spin_unlock_bh(&ax25->lock);
+
+ __skb_queue_purge(&acked);
}
void ax25_requeue_frames(ax25_cb *ax25)
{
+ struct sk_buff_head stale;
struct sk_buff *skb;
+ __skb_queue_head_init(&stale);
+
/*
* Requeue all the un-ack-ed frames on the output queue to be picked
* up by ax25_kick called from the timer. This arrangement handles the
- * possibility of an empty output queue.
+ * possibility of an empty output queue. Copies that ax25_kick() has
+ * numbered but not sent yet are stale: they will be sent again.
*/
+ spin_lock_bh(&ax25->lock);
+ while ((skb = skb_dequeue(&ax25->xmit_queue)) != NULL)
+ __skb_queue_tail(&stale, skb);
while ((skb = skb_dequeue_tail(&ax25->ack_queue)) != NULL)
skb_queue_head(&ax25->write_queue, skb);
+ spin_unlock_bh(&ax25->lock);
+
+ __skb_queue_purge(&stale);
}
/*
--
2.53.0
[-- Attachment #3: 6.12.y-v2-16-26-ax25-serialise-I-frames.patch --]
[-- Type: text/x-patch, Size: 9268 bytes --]
From 1e865a5da1521173333dcb7a0637cb0c5510483e Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Thu, 1 Oct 2026 14:07:43 +0200
Subject: [PATCH 6.12.y v2 16/26] ax25: serialise the transmission of I frames
on a connection
ax25_kick() takes frames off the write queue, numbers them from V(S)
and moves them to the ack queue, with no lock. It is called from
process context by the senders (ax25_output()) and from softirq context
by the receive path and the timers. A connection used by ROSE or NET/ROM
carries several circuits, so ax25_output() can run for the same
connection on two CPUs at once, and against the receive path. Both then
read the same V(S) and two different I frames are sent under the same
N(S). The peer keeps the first and rejects the second; the go-back-N
that follows resends whatever the ack queue holds for that number, and
one of the two frames is never sent again while the AX.25 counters look
consistent on both sides. The layer above sees a hole: a ROSE circuit
receives its frames out of sequence, ignores them, and stays frozen
with its window full.
Seen on a live ROSE node relaying several circuits over one AX.25 link:
fm F6BVP-9 to F6BVP-13 ctl I55^ pid=1(X.25) len 254 LCI 030 DATA S2
fm F6BVP-9 to F6BVP-13 ctl I55^ pid=1(X.25) len 254 LCI 02E DATA S2
fm F6BVP-13 to F6BVP-9 ctl REJ6v
Add a lock to the ax25_cb covering V(S), V(A) and the write and ack
queues, taken in ax25_kick(), ax25_frames_acked() and
ax25_requeue_frames(). The frames are not sent with the lock held,
since ax25_transmit_buffer() may end up in ax25_disconnect(): ax25_kick()
puts the numbered frames on a transmit queue which is emptied, in
order, by one context at a time once the lock is dropped.
Tested in QEMU, two 4-CPU nodes with lockdep and KASAN over a KISS
serial link, four ROSE circuits each sending 400 numbered messages at
the same time: before, every circuit freezes and 300 to 600 of the 1600
messages get through; after, no sender is blocked and more than 1500
get through (the ROSE side needs "rose: process received frames and
send with the socket locked" for the rest: 1600/1600 in order on six
runs out of six with both). No lockdep, KASAN or refcount report.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
[F6BVP: v2: in ax25_frames_acked(), loop on what skb_dequeue() returns
instead of on skb_peek(): ax25_clear_queues() purges the ack queue
without ax25->lock, so skb_dequeue() could return NULL and
__skb_queue_tail() dereference it in softirq context (reported by
Sasha Levin). Same fix submitted to mod-orphan.]
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
(cherry picked from commit 3f42b974059565c9e60229a9ff1ca21d10334671)
---
include/net/ax25.h | 5 ++++
net/ax25/af_ax25.c | 2 ++
net/ax25/ax25_out.c | 56 ++++++++++++++++++++++++++++++++++++++++----
net/ax25/ax25_subr.c | 37 ++++++++++++++++++++++-------
4 files changed, 88 insertions(+), 12 deletions(-)
diff --git a/include/net/ax25.h b/include/net/ax25.h
index a7bba42dde..0fe92fa6ef 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -252,6 +252,11 @@ typedef struct ax25_cb {
struct sk_buff_head reseq_queue;
struct sk_buff_head ack_queue;
struct sk_buff_head frag_queue;
+ /* I frames numbered by ax25_kick(), waiting to go to the device */
+ struct sk_buff_head xmit_queue;
+ /* serialises V(S)/V(A) and the write, ack and xmit queues */
+ spinlock_t lock;
+ unsigned char xmit_running;
unsigned char window;
struct timer_list timer, dtimer;
struct sock *sk; /* Backlink to socket */
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 3ee7dba343..164e9f46f0 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -537,6 +537,8 @@ ax25_cb *ax25_create_cb(void)
skb_queue_head_init(&ax25->frag_queue);
skb_queue_head_init(&ax25->ack_queue);
skb_queue_head_init(&ax25->reseq_queue);
+ skb_queue_head_init(&ax25->xmit_queue);
+ spin_lock_init(&ax25->lock);
ax25_setup_timers(ax25);
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index 8bca2ace98..1b9a91b9c9 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -218,6 +218,11 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
* This procedure is passed a buffer descriptor for an iframe. It builds
* the rest of the control part of the frame and then writes it out.
*/
+/*
+ * Number an I frame and queue it for the device. Called by ax25_kick()
+ * with ax25->lock held: the frame is sent by ax25_run_xmit_queue() once
+ * the lock is dropped.
+ */
static void ax25_send_iframe(ax25_cb *ax25, struct sk_buff *skb, int poll_bit)
{
unsigned char *frame;
@@ -245,7 +250,34 @@ static void ax25_send_iframe(ax25_cb *ax25, struct sk_buff *skb, int poll_bit)
ax25_start_idletimer(ax25);
- ax25_transmit_buffer(ax25, skb, AX25_COMMAND);
+ skb_queue_tail(&ax25->xmit_queue, skb);
+}
+
+/*
+ * Hand the frames numbered by ax25_kick() to the device, in order. Only
+ * one context does it at a time, so that frames queued by two senders
+ * cannot overtake each other; the one already running picks up whatever
+ * the others have queued. The lock is not held while transmitting.
+ */
+static void ax25_run_xmit_queue(ax25_cb *ax25)
+{
+ struct sk_buff *skb;
+
+ spin_lock_bh(&ax25->lock);
+ if (ax25->xmit_running) {
+ spin_unlock_bh(&ax25->lock);
+ return;
+ }
+ ax25->xmit_running = 1;
+
+ while ((skb = skb_dequeue(&ax25->xmit_queue)) != NULL) {
+ spin_unlock_bh(&ax25->lock);
+ ax25_transmit_buffer(ax25, skb, AX25_COMMAND);
+ spin_lock_bh(&ax25->lock);
+ }
+
+ ax25->xmit_running = 0;
+ spin_unlock_bh(&ax25->lock);
}
void ax25_kick(ax25_cb *ax25)
@@ -260,14 +292,25 @@ void ax25_kick(ax25_cb *ax25)
if (ax25->condition & AX25_COND_PEER_RX_BUSY)
return;
+ /*
+ * ax25_kick() is called from process context by the senders and
+ * from softirq context by the receive path and the timers, possibly
+ * for several ROSE or NET/ROM circuits sharing this connection. Two
+ * of them running here at the same time would read the same V(S) and
+ * send two different frames under the same N(S); the peer keeps one
+ * and the other is never sent again. Take the frames off the write
+ * queue and number them under the lock.
+ */
+ spin_lock_bh(&ax25->lock);
+
if (skb_peek(&ax25->write_queue) == NULL)
- return;
+ goto out;
start = (skb_peek(&ax25->ack_queue) == NULL) ? ax25->va : ax25->vs;
end = (ax25->va + ax25->window) % ax25->modulus;
if (start == end)
- return;
+ goto out;
/*
* Transmit data until either we're out of data to send or
@@ -281,7 +324,7 @@ void ax25_kick(ax25_cb *ax25)
*/
skb = skb_dequeue(&ax25->write_queue);
if (!skb)
- return;
+ goto out;
ax25->vs = start;
@@ -331,6 +374,11 @@ void ax25_kick(ax25_cb *ax25)
ax25_calculate_t1(ax25);
ax25_start_t1timer(ax25);
}
+
+out:
+ spin_unlock_bh(&ax25->lock);
+
+ ax25_run_xmit_queue(ax25);
}
void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type)
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index d0719267e5..fbfeb09784 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -34,6 +34,7 @@ void ax25_clear_queues(ax25_cb *ax25)
{
skb_queue_purge(&ax25->write_queue);
skb_queue_purge(&ax25->ack_queue);
+ skb_queue_purge(&ax25->xmit_queue);
skb_queue_purge(&ax25->reseq_queue);
skb_queue_purge(&ax25->frag_queue);
}
@@ -45,31 +46,51 @@ void ax25_clear_queues(ax25_cb *ax25)
*/
void ax25_frames_acked(ax25_cb *ax25, unsigned short nr)
{
+ struct sk_buff_head acked;
struct sk_buff *skb;
+ __skb_queue_head_init(&acked);
+
/*
- * Remove all the ack-ed frames from the ack queue.
+ * Remove all the ack-ed frames from the ack queue. ax25_kick() may be
+ * filling it from another CPU: move V(A) and the queue together, and
+ * free the frames once the lock is dropped.
*/
- if (ax25->va != nr) {
- while (skb_peek(&ax25->ack_queue) != NULL && ax25->va != nr) {
- skb = skb_dequeue(&ax25->ack_queue);
- kfree_skb(skb);
- ax25->va = (ax25->va + 1) % ax25->modulus;
- }
+ spin_lock_bh(&ax25->lock);
+ /*
+ * ax25_clear_queues() purges the ack queue without ax25->lock: test
+ * what skb_dequeue() returns, not what skb_peek() saw before it.
+ */
+ while (ax25->va != nr && (skb = skb_dequeue(&ax25->ack_queue)) != NULL) {
+ __skb_queue_tail(&acked, skb);
+ ax25->va = (ax25->va + 1) % ax25->modulus;
}
+ spin_unlock_bh(&ax25->lock);
+
+ __skb_queue_purge(&acked);
}
void ax25_requeue_frames(ax25_cb *ax25)
{
+ struct sk_buff_head stale;
struct sk_buff *skb;
+ __skb_queue_head_init(&stale);
+
/*
* Requeue all the un-ack-ed frames on the output queue to be picked
* up by ax25_kick called from the timer. This arrangement handles the
- * possibility of an empty output queue.
+ * possibility of an empty output queue. Copies that ax25_kick() has
+ * numbered but not sent yet are stale: they will be sent again.
*/
+ spin_lock_bh(&ax25->lock);
+ while ((skb = skb_dequeue(&ax25->xmit_queue)) != NULL)
+ __skb_queue_tail(&stale, skb);
while ((skb = skb_dequeue_tail(&ax25->ack_queue)) != NULL)
skb_queue_head(&ax25->write_queue, skb);
+ spin_unlock_bh(&ax25->lock);
+
+ __skb_queue_purge(&stale);
}
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-25 9:41 ` Bernard Pidoux
@ 2026-10-25 23:29 ` Sasha Levin
2026-11-09 10:30 ` Bernard Pidoux
0 siblings, 1 reply; 23+ messages in thread
From: Sasha Levin @ 2026-10-25 23:29 UTC (permalink / raw)
To: Bernard Pidoux; +Cc: Sasha Levin, gregkh, stable, kuba, linux-hams
> v2 of 16/26 is attached for 6.12.y and 6.18.y. The loop now tests
> what skb_dequeue() returns:
>
> while (ax25->va != nr && (skb = skb_dequeue(&ax25->ack_queue)) != NULL) {
Queued the series for 6.18 and 6.12, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-10-25 23:29 ` Sasha Levin
@ 2026-11-09 10:30 ` Bernard Pidoux
2026-11-09 15:53 ` Sasha Levin
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-11-09 10:30 UTC (permalink / raw)
To: gregkh; +Cc: sashal, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 5202 bytes --]
Hi Greg, Sasha,
Thanks for queuing the October 21st series, and to Sasha for the two
catches in it.
All 26 patches are in 6.12.115 and 6.18.60.
Here is what has been merged in mod-orphan since then, for 6.12.y and 6.18.y.
None of these 41 patches has been sent to stable before.
They fix memory-safety, locking and reference counting bugs, a few
protocol bugs that make links or calls hang, and three drivers (mkiss,
6pack, bpqether).
Drivers:
1. mkiss: size the frame buffers for worst-case KISS escaping
2. mkiss: don't use a tty write error as a byte count
3. bpqether: leave the Ethernet device's queue and counters alone
4. bpqether: fix truncated /proc/net/bpqether on partial reads
10. mkiss: restart the transmit queue when the interface is opened
11. 6pack: restart the transmit queue when the interface is opened
AX.25:
8. ax25: don't create a second connection for a link on an incoming SABM
9. ax25: free a closed socket when its device goes down
12. ax25: don't build a frame header from an uninitialised digipeater list
13. ax25: don't take a reference on a gone device in ax25_accept()
14. ax25: don't copy an uninitialised address to recvmsg()'s caller
15. ax25: free the old digipeater path of a listed socket under ax25_list_lock
16. ax25: put an incoming connection on the listener's queue once it is set up
17. ax25: don't test the socket flags of a connection that has no socket
18. ax25: free the copy of an IP packet that ax25_send_frame() turned down
19. ax25: don't leave half a message on a connection when fragmenting fails
20. ax25: make 16 the smallest maximum_packet_length of a port
21. ax25: keep the window below 8 when a socket goes back to modulo 8
22. ax25: let a socket connect again after a failed or ended connection
23. ax25: don't let connect() find its own socket when calling the same station
NET/ROM:
6. netrom: ignore a BPQ transport timeout below the sysctl minimum
24. netrom: don't convert the maximum number of tries to jiffies
25. netrom: don't leak frames in nr_route_frame()
26. netrom: use the more flag of each frame taken from the resequencing queue
27. netrom: give a frame back intact when it cannot be delivered
28. netrom: don't give the same circuit ID to two sockets
29. netrom: return the peer node in the address given by recvmsg()
30. netrom: keep the selected route when a route of a node is removed
31. netrom: drop a frame received with a TTL of 0
32. netrom: check the window size given by the peer
33. netrom: don't send part of a message that cannot be fragmented whole
34. netrom: disconnect sockets under their lock when a device goes down
35. netrom: only update the BPQ extension flag on circuit set-up frames
ROSE:
5. rose: arm the neighbour timers with mod_timer()
7. rose: don't give the same LCI to two calls placed at the same time
36. rose: hold the listener while a Call Request is queued on it
37. rose: hold the socket a received frame is delivered to
38. rose: report a timed out call to connect()
39. rose: drop the neighbour reference once when a cleared socket is closed
40. rose: swap the AX.25 connection of a neighbour under a lock
41. rose: give the sysctl timer limits in milliseconds
The numbers are the positions in the mboxes, which follow the
mod-orphan merge order.
That order must be kept, since several patches touch the same functions.
The two attached mboxes hold the 41 patches, one mbox per branch.
Each patch carries a "(cherry picked from commit <id>)" trailer with
the mod-orphan git id.
- 6.18.y: the mbox applies with "git am" on top of v6.18.62.
- 6.12.y: the mbox applies with "git am" on top of v6.12.116.
The backports are the mod-orphan commits with one change: in patch 5,
6.12 still has del_timer() instead of timer_delete(), so the context
of two functions is adjusted; a note in the patch says so.
Patches 1 to 4 had a "Co-Authored-By:" line for the AI assistant I
used; in the backports it is an "Assisted-by:" line, as
Documentation/process asks.
Patches 3 and 4 also get the Fixes tags that were missing in mod-orphan.
Testing:
- each patch builds on both branches (net/ax25, net/netrom, net/rose
and drivers/net/hamradio, W=1, KASAN enabled, mkiss, 6pack and
bpqether as modules), with no warnings and no errors;
- checkpatch reports nothing beyond style remarks inherited from the
original code;
- each fix was tested on a QEMU bench (KASAN and lockdep), as
described in its commit message;
- the AX.25, NET/ROM and ROSE fixes are part of the module set running
on two of our production nodes; patches 1 to 23 have been in service
since November 1st, 24 to 35 since November 4th, and 36 to 41 since
November 5th;
- no node uses bpqether or 6pack, so patches 3, 4 and 11 were only
tested on the bench.
Thanks,
Bernard
Le lun. 26 oct. 2026 à 00:30, Sasha Levin <sashal@kernel.org> a écrit :
>
> > v2 of 16/26 is attached for 6.12.y and 6.18.y. The loop now tests
> > what skb_dequeue() returns:
> >
> > while (ax25->va != nr && (skb = skb_dequeue(&ax25->ack_queue)) != NULL) {
>
> Queued the series for 6.18 and 6.12, thanks.
>
> --
> Thanks,
> Sasha
[-- Attachment #2: rose-ax25-netrom-6.12.y-0911.mbox --]
[-- Type: application/mbox, Size: 134683 bytes --]
[-- Attachment #3: rose-ax25-netrom-6.18.y-0911.mbox --]
[-- Type: application/mbox, Size: 134550 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-11-09 10:30 ` Bernard Pidoux
@ 2026-11-09 15:53 ` Sasha Levin
2026-11-16 11:17 ` Bernard Pidoux
0 siblings, 1 reply; 23+ messages in thread
From: Sasha Levin @ 2026-11-09 15:53 UTC (permalink / raw)
To: gregkh; +Cc: Sasha Levin, stable, kuba, linux-hams, Bernard Pidoux
> [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
Queued all 41 for 6.18 and 6.12, in mbox order. Thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
2026-11-09 15:53 ` Sasha Levin
@ 2026-11-16 11:17 ` Bernard Pidoux
2026-11-16 16:06 ` [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) - 10 more patches for 6.12.y/6.18.y Sasha Levin
0 siblings, 1 reply; 23+ messages in thread
From: Bernard Pidoux @ 2026-11-16 11:17 UTC (permalink / raw)
To: gregkh; +Cc: sashal, stable, kuba, linux-hams
[-- Attachment #1: Type: text/plain, Size: 2931 bytes --]
Hi Greg, Sasha,
Thanks for queuing the 41 patches of November 9th; they are all in
6.12.118-rc1 and 6.18.64-rc1.
Here are the ten fixes merged in mod-orphan since then, for 6.12.y and
6.18.y. None of them has been sent to stable before. Nine are ROSE
fixes found by the same audit as the last ROSE patches of the previous
series (locking, a read past the end of a short frame, calls that are
never answered or leave a dead circuit); the tenth is an hdlcdrv fix.
ROSE:
1. rose: walk the neighbour list under its lock when a device goes down
2. rose: hold RTNL while a route is added or deleted
3. rose: change the loopback nodes under the neighbour list lock too
4. rose: check the length of Restart Request and Diagnostic frames
5. rose: keep a socket unbound when connect() fails to autobind it
6. rose: refuse an empty message when the Q bit is included
7. rose: give loopback answers LCIs that calls cannot be given
8. rose: clear the other half of a through route a new call takes over
9. rose: disconnect sockets under their lock when a neighbour goes away
Drivers:
10. hdlcdrv: close the hardware driver once, and only if it was opened
The numbers are the positions in the mboxes, which follow the
mod-orphan merge order.
The two attached mboxes hold the 10 patches, one mbox per branch. Each
patch carries a "(cherry picked from commit <id>)" trailer with the
mod-orphan git id.
- 6.18.y: the mbox applies with "git am" on top of 6.18.64-rc1.
- 6.12.y: the mbox applies with "git am" on top of 6.12.118-rc1.
They need the 41 patches already queued: the files they touch are the
same in 6.12.118-rc1 and 6.18.64-rc1 as after applying the November 9th
mboxes on 6.12.117 and 6.18.63.
The backports are the mod-orphan commits unchanged, except patch 10,
which gets the Fixes tag that was missing in mod-orphan (the code it
fixes dates back to the first git import).
Testing:
- each patch builds on both branches (net/ax25, net/netrom, net/rose
and drivers/net/hamradio, W=1, KASAN enabled, mkiss, 6pack, bpqether
and the baycom drivers as modules), with no warnings and no errors;
- checkpatch reports nothing beyond one style remark inherited from
the original code (a comparison to NULL, patch 8);
- each fix was tested on a QEMU bench (KASAN and lockdep), as
described in its commit message;
- the ROSE fixes are part of the module set running on our production
nodes: on two of them since November 6th and 7th, and on five more
since November 10th to 12th, with clean nights so far;
- no node uses hdlcdrv, so patch 10 was only tested on the bench.
Thanks,
Bernard
Le lun. 9 nov. 2026 à 16:53, Sasha Levin <sashal@kernel.org> a écrit :
>
> > [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan)
>
> Queued all 41 for 6.18 and 6.12, in mbox order. Thanks.
>
> --
> Thanks,
> Sasha
[-- Attachment #2: rose-hdlcdrv-6.18.y-1611.mbox --]
[-- Type: application/octet-stream, Size: 25804 bytes --]
From cffc5c1de012925bd5b4b277987eff3602660bbe Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:22:55 +0100
Subject: [PATCH 6.18.y 01/10] rose: walk the neighbour list under its lock
when a device goes down
rose_link_device_down() walks rose_neigh_list without
rose_neigh_list_lock. The list can change under it: rose_add_node() and
rose_del_node() from the SIOCADDRT/SIOCDELRT ioctls, and
rose_rt_device_down(), which the same NETDEV_DOWN event calls right
after, all add or free neighbours under that lock. The walk can then
follow a neighbour that has just been freed.
Take the lock around the walk, as rose_link_failed() does around the
very same calls to rose_del_route_by_neigh() and rose_kill_by_neigh().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit bf7007048732cd8eac6e3c7c68d131692b480f75)
---
net/rose/rose_route.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 00fbe47fffe0..70ed72f4a11c 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -958,12 +958,14 @@ void rose_link_device_down(struct net_device *dev)
{
struct rose_neigh *rose_neigh;
+ spin_lock_bh(&rose_neigh_list_lock);
for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next) {
if (rose_neigh->dev == dev) {
rose_del_route_by_neigh(rose_neigh);
rose_kill_by_neigh(rose_neigh);
}
}
+ spin_unlock_bh(&rose_neigh_list_lock);
}
/*
--
2.53.0
From 22354f9509a8f9dabf6053ccca75f9d2b7efd102 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:23:42 +0100
Subject: [PATCH 6.18.y 02/10] rose: hold RTNL while a route is added or
deleted
rose_ax25_dev_find() says it is called with RTNL, but rose_rt_ioctl()
does not take it for SIOCADDRT and SIOCDELRT. __dev_get_by_name() is
then used without RTNL or RCU, and the device can go down between the
IFF_UP check and rose_add_node(): the NETDEV_DOWN notifier runs
rose_rt_device_down(), finds no neighbour on the device yet, and the
neighbour added right after keeps a pointer to a device that may be
unregistered and freed, since rose_neigh->dev holds no reference.
Commit b4ec82402149 ("rose: device refcount leak") stopped taking a
reference on the device because RTNL would be held, which the ioctl
never did.
Take RTNL around the lookup of the device and the change of the
tables. The notifier runs under RTNL too, so a neighbour is either on
the list before the device goes down, where rose_rt_device_down()
removes it, or not added at all.
Fixes: b4ec82402149 ("rose: device refcount leak")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 1b9d3d721a9d334e7cd8ab21a2885fe1fa271a80)
---
net/rose/rose_route.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 70ed72f4a11c..7044496bb214 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -17,6 +17,7 @@
#include <net/ax25.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
#include <net/arp.h>
#include <linux/if_arp.h>
#include <linux/skbuff.h>
@@ -829,23 +830,29 @@ int rose_rt_ioctl(unsigned int cmd, void __user *arg)
case SIOCADDRT:
if (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))
return -EFAULT;
- if ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)
- return -EINVAL;
if (rose_dev_exists(&rose_route.address)) /* Can't add routes to ourself */
return -EINVAL;
if (rose_route.mask > 10) /* Mask can't be more than 10 digits */
return -EINVAL;
if (rose_route.ndigis > AX25_MAX_DIGIS)
return -EINVAL;
- err = rose_add_node(&rose_route, dev);
+ /*
+ * RTNL keeps the device up until the neighbour that uses it
+ * is on the list, where rose_rt_device_down() finds it.
+ */
+ rtnl_lock();
+ dev = rose_ax25_dev_find(rose_route.device);
+ err = dev ? rose_add_node(&rose_route, dev) : -EINVAL;
+ rtnl_unlock();
return err;
case SIOCDELRT:
if (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))
return -EFAULT;
- if ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)
- return -EINVAL;
- err = rose_del_node(&rose_route, dev);
+ rtnl_lock();
+ dev = rose_ax25_dev_find(rose_route.device);
+ err = dev ? rose_del_node(&rose_route, dev) : -EINVAL;
+ rtnl_unlock();
return err;
case SIOCRSCLRRT:
--
2.53.0
From 7cbf3f069d7936b3c0f9a7093163fc6160e3509d Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:24:22 +0100
Subject: [PATCH 6.18.y 03/10] rose: change the loopback nodes under the
neighbour list lock too
Since commit fe2c802ab62a ("rose: improving AX25 routing frames via ROSE
network"), rose_route_frame() looks up the node list through
rose_get_neigh() with route_frame set, under rose_neigh_list_lock only:
it cannot take rose_node_list_lock there. Every other writer of
rose_node_list holds both locks for that reason, but
rose_add_loopback_node() and rose_del_loopback_node(), run when a rose
device is opened, closed or given a new address, take
rose_node_list_lock alone. A frame routed at that moment can walk a node
that is being freed.
Take rose_neigh_list_lock inside rose_node_list_lock in both, in the
same order as rose_add_node() and rose_del_node().
Fixes: fe2c802ab62a ("rose: improving AX25 routing frames via ROSE network")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 0ab5a3287997c348ca74443999abb9e6004beece)
---
net/rose/rose_route.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 7044496bb214..30dfbe1f1431 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -463,6 +463,7 @@ int rose_add_loopback_node(const rose_address *address)
int err = 0;
spin_lock_bh(&rose_node_list_lock);
+ spin_lock_bh(&rose_neigh_list_lock);
rose_node = rose_node_list;
while (rose_node != NULL) {
@@ -495,6 +496,7 @@ int rose_add_loopback_node(const rose_address *address)
rose_neigh_hold(rose_loopback_neigh);
out:
+ spin_unlock_bh(&rose_neigh_list_lock);
spin_unlock_bh(&rose_node_list_lock);
return err;
@@ -508,6 +510,7 @@ void rose_del_loopback_node(const rose_address *address)
struct rose_node *rose_node;
spin_lock_bh(&rose_node_list_lock);
+ spin_lock_bh(&rose_neigh_list_lock);
rose_node = rose_node_list;
while (rose_node != NULL) {
@@ -527,6 +530,7 @@ void rose_del_loopback_node(const rose_address *address)
rose_neigh_put(rose_loopback_neigh);
out:
+ spin_unlock_bh(&rose_neigh_list_lock);
spin_unlock_bh(&rose_node_list_lock);
}
--
2.53.0
From a89859f9362083f1c5364fe5383a43f75180c036 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:24:44 +0100
Subject: [PATCH 6.18.y 04/10] rose: check the length of Restart Request and
Diagnostic frames
rose_route_frame() only makes sure that a frame holds the three bytes
of the ROSE header before it hands the frames with LCI 0 to
rose_link_rx_restart(). There, a Restart Request has its cause read
from byte 3 to set dce_mode, and a Diagnostic has bytes 3 to 6 printed.
A peer that sends them shorter makes the kernel read past the end of
the frame, and set dce_mode, which decides from which end LCIs are
given out, from whatever lies there.
Only read the restarting cause when the frame has one, and leave
dce_mode as it was otherwise. Ignore a Diagnostic too short to hold
its diagnostic code and the three bytes it reports, as x25 does with
pskb_may_pull().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 13db36d85e64fa98f579d5ee38e416baf9fc0dec)
---
net/rose/rose_link.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/rose/rose_link.c b/net/rose/rose_link.c
index 912d26f1fe35..7fbdf9c97cc6 100644
--- a/net/rose/rose_link.c
+++ b/net/rose/rose_link.c
@@ -185,7 +185,9 @@ void rose_link_rx_restart(struct sk_buff *skb, struct rose_neigh *neigh, unsigne
rose_link_restarted(neigh);
rose_stop_t0timer(neigh);
neigh->restarted = 1;
- neigh->dce_mode = (skb->data[3] == ROSE_DTE_ORIGINATED);
+ /* The restarting cause, when present, tells if the peer is a DTE */
+ if (skb->len > ROSE_MIN_LEN)
+ neigh->dce_mode = (skb->data[3] == ROSE_DTE_ORIGINATED);
rose_transmit_restart_confirmation(neigh);
break;
@@ -195,6 +197,9 @@ void rose_link_rx_restart(struct sk_buff *skb, struct rose_neigh *neigh, unsigne
break;
case ROSE_DIAGNOSTIC:
+ /* Diagnostic code and the first three bytes of the bad packet */
+ if (skb->len < ROSE_MIN_LEN + 4)
+ break;
pr_warn("ROSE: received diagnostic #%d - %3ph\n", skb->data[3],
skb->data + 4);
break;
--
2.53.0
From 0f5288fc3cfd0eb8614a872e83b5aa6d94c86693 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:25:10 +0100
Subject: [PATCH 6.18.y 05/10] rose: keep a socket unbound when connect() fails
to autobind it
When connect() is called on a socket that was never bound, it clears
SOCK_ZAPPED first and then looks for a rose device and for the
callsign of the user. If there is no rose device, or no callsign for
the user, connect() fails, but the socket is left marked as bound
although it has no device, no source address and is not on rose_list.
A second connect() on that socket then skips the autobind and places
the call with an all-zero source address and callsign. The socket is
not on rose_list, so rose_new_lci() does not see the LCI it holds and
rose_find_socket() never finds it: the Call Accepted is not delivered
to it and the call can only time out.
Clear SOCK_ZAPPED only once the autobind has succeeded, right before
the socket goes on rose_list, as rose_bind() does.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit f079e74f7889731570e7f53e9a7372e7776e3f9e)
---
net/rose/af_rose.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index fbf0e27ce898..52f279aa189e 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -894,8 +894,6 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */
struct net_device *dev;
- sock_reset_flag(sk, SOCK_ZAPPED);
-
dev = rose_dev_first();
if (!dev) {
err = -ENETUNREACH;
@@ -916,6 +914,8 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
GFP_KERNEL);
ax25_uid_put(user);
+ /* Only now is the socket bound: a failed autobind leaves it as it was */
+ sock_reset_flag(sk, SOCK_ZAPPED);
rose_insert_socket(sk); /* Finish the bind */
}
--
2.53.0
From 78aa20d3e9313f9ee2afc8ff21e7acd5f1e6ee0a Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:25:44 +0100
Subject: [PATCH 6.18.y 06/10] rose: refuse an empty message when the Q bit is
included
With the ROSE_QBITINCL socket option set, rose_sendmsg() takes the Q
bit from the first byte of the message and pulls that byte off.
Nothing checks that there is a first byte: a send() of zero bytes
reads the Q bit from beyond the data copied from the user, skb_pull()
fails without a word, and an empty data frame goes out with a Q bit
taken from uninitialised memory.
Refuse such a message with EINVAL before anything is allocated.
x25_sendmsg() checks for that byte too, with pskb_may_pull().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit fd8a23b811b7c46d0b9aefc2a45955ea8f685a8e)
---
net/rose/af_rose.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 52f279aa189e..5a8585627feb 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1286,6 +1286,10 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
if (len > 65535)
return -EMSGSIZE;
+ /* With the Q bit included, the first byte of the data holds it */
+ if (rose->qbitincl && len < 1)
+ return -EINVAL;
+
size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN;
if ((skb = sock_alloc_send_skb(sk, size, msg->msg_flags & MSG_DONTWAIT, &err)) == NULL)
--
2.53.0
From bc8a4a4a841ac8ac04937cdc3a545714e6d06a0f Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:26:08 +0100
Subject: [PATCH 6.18.y 07/10] rose: give loopback answers LCIs that calls
cannot be given
A call to an address of the node itself goes through the loopback
neighbour, and both ends of it use that neighbour. rose_loopback_timer()
gives the answering end LCI 51 - i for a call on LCI i, so that each
end finds the other. The 51 comes from ROSE_DEFAULT_MAXVC, but the
number of circuits is the maximum_virtual_circuits sysctl, which goes
up to 254, and rose_new_lci() hands out LCIs from 1 up to that value
on the loopback neighbour as on any other.
With more than 50 circuits allowed, the call on LCI 51 is answered on
LCI 0 and the next ones on LCIs that wrap around to huge values: the
answer is never matched to its call. Below that, LCI 51 - i is never
checked to be free, and only the way rose_new_lci() walks the LCIs
keeps it from being one that a call already uses.
Answer on LCI 4096 - i instead, at the top of the 12-bit LCI range, as
was nearly done before commit 1f731b63752d ("rose_loopback_timer sets
VC number <= ROSE_DEFAULT_MAXVC"): 0xFFF - i. That commit moved the
answers below 51 so that /proc/net/rose would not show an LCI above
the number of circuits; it prints the LCI on three hex digits, which
any LCI up to 0xFFF fits. 4096 - i is still its own inverse, so each
end finds the other as before, and rose_new_lci() never gives out an
LCI above 254.
Fixes: 1f731b63752d ("rose_loopback_timer sets VC number <= ROSE_DEFAULT_MAXVC")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit aeddd6cb7ca6e8019ac73c8c0d40e5d9dcbc5c6f)
---
net/rose/rose_loopback.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/rose/rose_loopback.c b/net/rose/rose_loopback.c
index 6c5c35030e67..efd4a719ab2c 100644
--- a/net/rose/rose_loopback.c
+++ b/net/rose/rose_loopback.c
@@ -101,7 +101,12 @@ static void rose_loopback_timer(struct timer_list *unused)
continue;
}
dest = (rose_address *)(skb->data + ROSE_CALL_REQ_DEST_ADDR_OFF);
- lci_o = ROSE_DEFAULT_MAXVC + 1 - lci_i;
+ /*
+ * The call and its answer use the same neighbour: give the
+ * answer the LCI at the other end of the 12-bit range, which
+ * rose_new_lci() never hands out, and get back from it.
+ */
+ lci_o = 0xFFF + 1 - lci_i;
skb_reset_transport_header(skb);
--
2.53.0
From 9f6b6f92e7403df80cca485c76b5fc6ed3d2a599 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:27:08 +0100
Subject: [PATCH 6.18.y 08/10] rose: clear the other half of a through route a
new call takes over
When a Call Request comes in on the LCI of an existing through route,
for a call other than the one the route was built for, the neighbour
has evidently lost that call: it gives the LCI out again.
rose_route_frame() then removes the route and goes on with the new
call, but says nothing to the neighbour on the other half. That end
keeps its virtual circuit up with nothing behind it, and its LCI on
our side is freed while it may still send on it.
Do as rose_clear_routes_by_neigh() does when a neighbour goes away:
detach the half that the new call takes over and send a Clear Request
on the other half. The route stays for that half until its Clear
Confirmation, which removes it, and its LCI is not given to another
call meanwhile. The cause is the one given to a socket in the same
case, network congestion. A route that has no other half left is
removed as before.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 9b1a1d3395bdcf1eca96d3db517eae195d02a632)
---
net/rose/rose_route.c | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 30dfbe1f1431..d23f8d30067b 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -1145,8 +1145,24 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
120);
goto out;
}
- /* Remove an existing unused route */
- rose_remove_route(rose_route);
+ /*
+ * Another call on the LCI of a through
+ * route: the neighbour no longer has the
+ * call it was built for. Clear the other
+ * half, which keeps the route until its
+ * Clear Confirmation, and leave the LCI
+ * to the new call.
+ */
+ if (rose_route->neigh2 != NULL) {
+ rose_neigh_put(rose_route->neigh1);
+ rose_route->neigh1 = NULL;
+ rose_transmit_clear_request(rose_route->neigh2,
+ rose_route->lci2,
+ ROSE_NETWORK_CONGESTION,
+ 0);
+ } else {
+ rose_remove_route(rose_route);
+ }
break;
} else if (rose_route->neigh2 != NULL) {
skb->data[0] &= 0xF0;
@@ -1180,8 +1196,24 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
120);
goto out;
}
- /* Remove an existing unused route */
- rose_remove_route(rose_route);
+ /*
+ * Another call on the LCI of a through
+ * route: the neighbour no longer has the
+ * call it was built for. Clear the other
+ * half, which keeps the route until its
+ * Clear Confirmation, and leave the LCI
+ * to the new call.
+ */
+ if (rose_route->neigh1 != NULL) {
+ rose_neigh_put(rose_route->neigh2);
+ rose_route->neigh2 = NULL;
+ rose_transmit_clear_request(rose_route->neigh1,
+ rose_route->lci1,
+ ROSE_NETWORK_CONGESTION,
+ 0);
+ } else {
+ rose_remove_route(rose_route);
+ }
break;
} else if (rose_route->neigh1 != NULL) {
skb->data[0] &= 0xF0;
--
2.53.0
From 7c574ba6a31510ba8d7001e9bc0db95b7ac1defa Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:27:56 +0100
Subject: [PATCH 6.18.y 09/10] rose: disconnect sockets under their lock when a
neighbour goes away
rose_kill_by_neigh() disconnects every socket that uses a neighbour
whose link has failed, restarted or gone down, holding only
rose_list_lock. rose_disconnect() stops the timers, purges the queues
and changes the state of the socket, but its timers and the frames
received for it work on the same socket under bh_lock_sock() only, on
other CPUs, and are not kept out by rose_list_lock.
Disconnect each socket under its lock. rose_rx_call_request() and
rose_kill_by_device() take the socket lock before rose_list_lock, so
do as rose_kill_by_device() does: take a reference on the sockets that
use the neighbour under rose_list_lock, drop it, and lock each socket
in turn, checking that it still uses the neighbour. The neighbour is
still taken under rose_list_lock as well: rose_release() takes it under
that lock while it owns the socket, which bh_lock_sock() does not keep
out.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 250c2ad2174f0a1aeb6c306e7bcc259a7fe2178d)
---
net/rose/af_rose.c | 48 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 5a8585627feb..916b8aad03d4 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -162,19 +162,52 @@ static void rose_remove_socket(struct sock *sk)
*/
void rose_kill_by_neigh(struct rose_neigh *neigh)
{
- struct sock *s;
+ struct sock *s, *array[16];
+ bool rescan;
+ int i, cnt;
+ /*
+ * Each socket is disconnected under its lock, which its timers and
+ * the frames received for it hold while they work on it. That lock
+ * is taken before rose_list_lock elsewhere, so collect the sockets
+ * first, as rose_kill_by_device() does. rose_list_lock is still
+ * held around the change of the neighbour, which rose_release()
+ * takes under it while it owns the socket. A socket done with has
+ * no neighbour left and is not collected again.
+ */
+again:
+ rescan = false;
+ cnt = 0;
spin_lock_bh(&rose_list_lock);
sk_for_each(s, &rose_list) {
- struct rose_sock *rose = rose_sk(s);
+ if (rose_sk(s)->neighbour != neigh)
+ continue;
+ if (cnt == ARRAY_SIZE(array)) {
+ rescan = true;
+ break;
+ }
+ sock_hold(s);
+ array[cnt++] = s;
+ }
+ spin_unlock_bh(&rose_list_lock);
+
+ for (i = 0; i < cnt; i++) {
+ struct rose_sock *rose = rose_sk(array[i]);
+ bh_lock_sock(array[i]);
+ /* rose_release() takes the neighbour under rose_list_lock */
+ spin_lock_bh(&rose_list_lock);
if (rose->neighbour == neigh) {
- rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
+ rose_disconnect(array[i], ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
rose_neigh_put(rose->neighbour);
rose->neighbour = NULL;
}
+ spin_unlock_bh(&rose_list_lock);
+ bh_unlock_sock(array[i]);
+ sock_put(array[i]);
}
- spin_unlock_bh(&rose_list_lock);
+ if (rescan)
+ goto again;
}
/*
@@ -721,9 +754,10 @@ static int rose_release(struct socket *sock)
* Disconnect before the socket lock is dropped: frames put on
* the backlog meanwhile, a Clear Confirmation for one, then
* find it in state 0 instead of dropping the neighbour
- * reference a second time. rose_kill_by_neigh() does not take
- * the socket lock: take the neighbour under rose_list_lock, as
- * it does, so that only one of them drops the reference.
+ * reference a second time. rose_kill_by_neigh() can run while
+ * the socket is owned here: take the neighbour under
+ * rose_list_lock, as it does, so that only one of them drops
+ * the reference.
*/
rose_disconnect(sk, 0, -1, -1);
spin_lock_bh(&rose_list_lock);
--
2.53.0
From 096e8605b526be69935b47b63d68171e4c154f55 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Mon, 5 Oct 2026 20:30:45 +0200
Subject: [PATCH 6.18.y 10/10] hdlcdrv: close the hardware driver once, and
only if it was opened
hdlcdrv_unregister() calls the hardware driver's close() when s->opened
is set and then calls unregister_netdev(). Two things go wrong:
- if the interface is still up, unregister_netdev() closes it through
ndo_stop, so hdlcdrv_close() calls the hardware driver's close() a
second time;
- hdlcdrv_open() sets s->opened before it calls the hardware driver's
open() and leaves it set when that fails, so close() is also called
for a port that was never opened.
The close() methods of the baycom drivers are not written for either
case. baycom_ser_fdx and baycom_ser_hdx call free_irq() and
release_region() for resources they do not hold. baycom_par
dereferences bc->pdev, which is NULL if the port was never opened and
points to an unregistered parport device after a first close.
Set s->opened only once the hardware driver's open() has succeeded,
and let unregister_netdev() do the closing.
Tested in a QEMU guest (6.12.94, KASAN and lockdep) with
baycom_ser_fdx and two ports: bcsf0 at an address without a UART, whose
open fails, and bcsf1 on a UART, left up. Unloading baycom_ser_fdx gave
before the change:
Trying to free already-free IRQ 5
ser12_close+0xa1/0x190 [baycom_ser_fdx]
cleanup_baycomserfdx+0x38/0x50 [baycom_ser_fdx]
resource: Trying to free nonexistent resource <0x300-0x307>
baycom_ser_fdx: close ser_fdx at iobase 0x250 irq 9
Trying to free already-free IRQ 9
resource: Trying to free nonexistent resource <0x250-0x257>
and after the change a single close of bcsf1 and no warning. The
baycom_par case was not reproduced, the test kernel has no parport
support.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 056d9c67e92622d5ec8cc6ce4a49179a16c53ef1)
---
drivers/net/hamradio/hdlcdrv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 2263029d1a20..dc4e2c45e2d1 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -441,7 +441,6 @@ static int hdlcdrv_open(struct net_device *dev)
/*
* initialise some variables
*/
- s->opened = 1;
s->hdlcrx.hbuf.rd = s->hdlcrx.hbuf.wr = 0;
s->hdlcrx.in_hdlc_rx = 0;
s->hdlcrx.rx_state = 0;
@@ -458,6 +457,7 @@ static int hdlcdrv_open(struct net_device *dev)
i = s->ops->open(dev);
if (i)
return i;
+ s->opened = 1;
netif_start_queue(dev);
return 0;
}
@@ -725,8 +725,7 @@ void hdlcdrv_unregister(struct net_device *dev)
BUG_ON(s->magic != HDLCDRV_MAGIC);
- if (s->opened && s->ops->close)
- s->ops->close(dev);
+ /* unregister_netdev() closes the device if it is still up */
unregister_netdev(dev);
free_netdev(dev);
--
2.53.0
[-- Attachment #3: rose-hdlcdrv-6.12.y-1611.mbox --]
[-- Type: application/octet-stream, Size: 25804 bytes --]
From 5801b6ebfaf9052b014334fb03bc019f53caca17 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:22:55 +0100
Subject: [PATCH 6.12.y 01/10] rose: walk the neighbour list under its lock
when a device goes down
rose_link_device_down() walks rose_neigh_list without
rose_neigh_list_lock. The list can change under it: rose_add_node() and
rose_del_node() from the SIOCADDRT/SIOCDELRT ioctls, and
rose_rt_device_down(), which the same NETDEV_DOWN event calls right
after, all add or free neighbours under that lock. The walk can then
follow a neighbour that has just been freed.
Take the lock around the walk, as rose_link_failed() does around the
very same calls to rose_del_route_by_neigh() and rose_kill_by_neigh().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit bf7007048732cd8eac6e3c7c68d131692b480f75)
---
net/rose/rose_route.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 00fbe47fffe0..70ed72f4a11c 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -958,12 +958,14 @@ void rose_link_device_down(struct net_device *dev)
{
struct rose_neigh *rose_neigh;
+ spin_lock_bh(&rose_neigh_list_lock);
for (rose_neigh = rose_neigh_list; rose_neigh != NULL; rose_neigh = rose_neigh->next) {
if (rose_neigh->dev == dev) {
rose_del_route_by_neigh(rose_neigh);
rose_kill_by_neigh(rose_neigh);
}
}
+ spin_unlock_bh(&rose_neigh_list_lock);
}
/*
--
2.53.0
From 927b3976e7d2c0aefcced63b3c4c73de96b6564c Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:23:42 +0100
Subject: [PATCH 6.12.y 02/10] rose: hold RTNL while a route is added or
deleted
rose_ax25_dev_find() says it is called with RTNL, but rose_rt_ioctl()
does not take it for SIOCADDRT and SIOCDELRT. __dev_get_by_name() is
then used without RTNL or RCU, and the device can go down between the
IFF_UP check and rose_add_node(): the NETDEV_DOWN notifier runs
rose_rt_device_down(), finds no neighbour on the device yet, and the
neighbour added right after keeps a pointer to a device that may be
unregistered and freed, since rose_neigh->dev holds no reference.
Commit b4ec82402149 ("rose: device refcount leak") stopped taking a
reference on the device because RTNL would be held, which the ioctl
never did.
Take RTNL around the lookup of the device and the change of the
tables. The notifier runs under RTNL too, so a neighbour is either on
the list before the device goes down, where rose_rt_device_down()
removes it, or not added at all.
Fixes: b4ec82402149 ("rose: device refcount leak")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 1b9d3d721a9d334e7cd8ab21a2885fe1fa271a80)
---
net/rose/rose_route.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 70ed72f4a11c..7044496bb214 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -17,6 +17,7 @@
#include <net/ax25.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
+#include <linux/rtnetlink.h>
#include <net/arp.h>
#include <linux/if_arp.h>
#include <linux/skbuff.h>
@@ -829,23 +830,29 @@ int rose_rt_ioctl(unsigned int cmd, void __user *arg)
case SIOCADDRT:
if (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))
return -EFAULT;
- if ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)
- return -EINVAL;
if (rose_dev_exists(&rose_route.address)) /* Can't add routes to ourself */
return -EINVAL;
if (rose_route.mask > 10) /* Mask can't be more than 10 digits */
return -EINVAL;
if (rose_route.ndigis > AX25_MAX_DIGIS)
return -EINVAL;
- err = rose_add_node(&rose_route, dev);
+ /*
+ * RTNL keeps the device up until the neighbour that uses it
+ * is on the list, where rose_rt_device_down() finds it.
+ */
+ rtnl_lock();
+ dev = rose_ax25_dev_find(rose_route.device);
+ err = dev ? rose_add_node(&rose_route, dev) : -EINVAL;
+ rtnl_unlock();
return err;
case SIOCDELRT:
if (copy_from_user(&rose_route, arg, sizeof(struct rose_route_struct)))
return -EFAULT;
- if ((dev = rose_ax25_dev_find(rose_route.device)) == NULL)
- return -EINVAL;
- err = rose_del_node(&rose_route, dev);
+ rtnl_lock();
+ dev = rose_ax25_dev_find(rose_route.device);
+ err = dev ? rose_del_node(&rose_route, dev) : -EINVAL;
+ rtnl_unlock();
return err;
case SIOCRSCLRRT:
--
2.53.0
From 07c0ca4629d92e2680eb43faf781271c8c475e35 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:24:22 +0100
Subject: [PATCH 6.12.y 03/10] rose: change the loopback nodes under the
neighbour list lock too
Since commit fe2c802ab62a ("rose: improving AX25 routing frames via ROSE
network"), rose_route_frame() looks up the node list through
rose_get_neigh() with route_frame set, under rose_neigh_list_lock only:
it cannot take rose_node_list_lock there. Every other writer of
rose_node_list holds both locks for that reason, but
rose_add_loopback_node() and rose_del_loopback_node(), run when a rose
device is opened, closed or given a new address, take
rose_node_list_lock alone. A frame routed at that moment can walk a node
that is being freed.
Take rose_neigh_list_lock inside rose_node_list_lock in both, in the
same order as rose_add_node() and rose_del_node().
Fixes: fe2c802ab62a ("rose: improving AX25 routing frames via ROSE network")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 0ab5a3287997c348ca74443999abb9e6004beece)
---
net/rose/rose_route.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 7044496bb214..30dfbe1f1431 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -463,6 +463,7 @@ int rose_add_loopback_node(const rose_address *address)
int err = 0;
spin_lock_bh(&rose_node_list_lock);
+ spin_lock_bh(&rose_neigh_list_lock);
rose_node = rose_node_list;
while (rose_node != NULL) {
@@ -495,6 +496,7 @@ int rose_add_loopback_node(const rose_address *address)
rose_neigh_hold(rose_loopback_neigh);
out:
+ spin_unlock_bh(&rose_neigh_list_lock);
spin_unlock_bh(&rose_node_list_lock);
return err;
@@ -508,6 +510,7 @@ void rose_del_loopback_node(const rose_address *address)
struct rose_node *rose_node;
spin_lock_bh(&rose_node_list_lock);
+ spin_lock_bh(&rose_neigh_list_lock);
rose_node = rose_node_list;
while (rose_node != NULL) {
@@ -527,6 +530,7 @@ void rose_del_loopback_node(const rose_address *address)
rose_neigh_put(rose_loopback_neigh);
out:
+ spin_unlock_bh(&rose_neigh_list_lock);
spin_unlock_bh(&rose_node_list_lock);
}
--
2.53.0
From 5c0a31787eb172a03a760498f3e49f381510c842 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:24:44 +0100
Subject: [PATCH 6.12.y 04/10] rose: check the length of Restart Request and
Diagnostic frames
rose_route_frame() only makes sure that a frame holds the three bytes
of the ROSE header before it hands the frames with LCI 0 to
rose_link_rx_restart(). There, a Restart Request has its cause read
from byte 3 to set dce_mode, and a Diagnostic has bytes 3 to 6 printed.
A peer that sends them shorter makes the kernel read past the end of
the frame, and set dce_mode, which decides from which end LCIs are
given out, from whatever lies there.
Only read the restarting cause when the frame has one, and leave
dce_mode as it was otherwise. Ignore a Diagnostic too short to hold
its diagnostic code and the three bytes it reports, as x25 does with
pskb_may_pull().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 13db36d85e64fa98f579d5ee38e416baf9fc0dec)
---
net/rose/rose_link.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/rose/rose_link.c b/net/rose/rose_link.c
index 2e2837e63242..c544157944f5 100644
--- a/net/rose/rose_link.c
+++ b/net/rose/rose_link.c
@@ -185,7 +185,9 @@ void rose_link_rx_restart(struct sk_buff *skb, struct rose_neigh *neigh, unsigne
rose_link_restarted(neigh);
rose_stop_t0timer(neigh);
neigh->restarted = 1;
- neigh->dce_mode = (skb->data[3] == ROSE_DTE_ORIGINATED);
+ /* The restarting cause, when present, tells if the peer is a DTE */
+ if (skb->len > ROSE_MIN_LEN)
+ neigh->dce_mode = (skb->data[3] == ROSE_DTE_ORIGINATED);
rose_transmit_restart_confirmation(neigh);
break;
@@ -195,6 +197,9 @@ void rose_link_rx_restart(struct sk_buff *skb, struct rose_neigh *neigh, unsigne
break;
case ROSE_DIAGNOSTIC:
+ /* Diagnostic code and the first three bytes of the bad packet */
+ if (skb->len < ROSE_MIN_LEN + 4)
+ break;
pr_warn("ROSE: received diagnostic #%d - %3ph\n", skb->data[3],
skb->data + 4);
break;
--
2.53.0
From a2b2c78efca546598dccdc0ec1434391dd7a5d59 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:25:10 +0100
Subject: [PATCH 6.12.y 05/10] rose: keep a socket unbound when connect() fails
to autobind it
When connect() is called on a socket that was never bound, it clears
SOCK_ZAPPED first and then looks for a rose device and for the
callsign of the user. If there is no rose device, or no callsign for
the user, connect() fails, but the socket is left marked as bound
although it has no device, no source address and is not on rose_list.
A second connect() on that socket then skips the autobind and places
the call with an all-zero source address and callsign. The socket is
not on rose_list, so rose_new_lci() does not see the LCI it holds and
rose_find_socket() never finds it: the Call Accepted is not delivered
to it and the call can only time out.
Clear SOCK_ZAPPED only once the autobind has succeeded, right before
the socket goes on rose_list, as rose_bind() does.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit f079e74f7889731570e7f53e9a7372e7776e3f9e)
---
net/rose/af_rose.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 332d26771681..1b5230ed4a45 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -894,8 +894,6 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */
struct net_device *dev;
- sock_reset_flag(sk, SOCK_ZAPPED);
-
dev = rose_dev_first();
if (!dev) {
err = -ENETUNREACH;
@@ -916,6 +914,8 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
GFP_KERNEL);
ax25_uid_put(user);
+ /* Only now is the socket bound: a failed autobind leaves it as it was */
+ sock_reset_flag(sk, SOCK_ZAPPED);
rose_insert_socket(sk); /* Finish the bind */
}
--
2.53.0
From a895cb66f0abe814cf1fca7168c638f7661fc99b Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:25:44 +0100
Subject: [PATCH 6.12.y 06/10] rose: refuse an empty message when the Q bit is
included
With the ROSE_QBITINCL socket option set, rose_sendmsg() takes the Q
bit from the first byte of the message and pulls that byte off.
Nothing checks that there is a first byte: a send() of zero bytes
reads the Q bit from beyond the data copied from the user, skb_pull()
fails without a word, and an empty data frame goes out with a Q bit
taken from uninitialised memory.
Refuse such a message with EINVAL before anything is allocated.
x25_sendmsg() checks for that byte too, with pskb_may_pull().
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit fd8a23b811b7c46d0b9aefc2a45955ea8f685a8e)
---
net/rose/af_rose.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 1b5230ed4a45..2cb096068e5e 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1286,6 +1286,10 @@ static int rose_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
if (len > 65535)
return -EMSGSIZE;
+ /* With the Q bit included, the first byte of the data holds it */
+ if (rose->qbitincl && len < 1)
+ return -EINVAL;
+
size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN;
if ((skb = sock_alloc_send_skb(sk, size, msg->msg_flags & MSG_DONTWAIT, &err)) == NULL)
--
2.53.0
From a63c692bd658f17ac09b7f6c47a2037fc3f6fa2c Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:26:08 +0100
Subject: [PATCH 6.12.y 07/10] rose: give loopback answers LCIs that calls
cannot be given
A call to an address of the node itself goes through the loopback
neighbour, and both ends of it use that neighbour. rose_loopback_timer()
gives the answering end LCI 51 - i for a call on LCI i, so that each
end finds the other. The 51 comes from ROSE_DEFAULT_MAXVC, but the
number of circuits is the maximum_virtual_circuits sysctl, which goes
up to 254, and rose_new_lci() hands out LCIs from 1 up to that value
on the loopback neighbour as on any other.
With more than 50 circuits allowed, the call on LCI 51 is answered on
LCI 0 and the next ones on LCIs that wrap around to huge values: the
answer is never matched to its call. Below that, LCI 51 - i is never
checked to be free, and only the way rose_new_lci() walks the LCIs
keeps it from being one that a call already uses.
Answer on LCI 4096 - i instead, at the top of the 12-bit LCI range, as
was nearly done before commit 1f731b63752d ("rose_loopback_timer sets
VC number <= ROSE_DEFAULT_MAXVC"): 0xFFF - i. That commit moved the
answers below 51 so that /proc/net/rose would not show an LCI above
the number of circuits; it prints the LCI on three hex digits, which
any LCI up to 0xFFF fits. 4096 - i is still its own inverse, so each
end finds the other as before, and rose_new_lci() never gives out an
LCI above 254.
Fixes: 1f731b63752d ("rose_loopback_timer sets VC number <= ROSE_DEFAULT_MAXVC")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit aeddd6cb7ca6e8019ac73c8c0d40e5d9dcbc5c6f)
---
net/rose/rose_loopback.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/rose/rose_loopback.c b/net/rose/rose_loopback.c
index 6c5c35030e67..efd4a719ab2c 100644
--- a/net/rose/rose_loopback.c
+++ b/net/rose/rose_loopback.c
@@ -101,7 +101,12 @@ static void rose_loopback_timer(struct timer_list *unused)
continue;
}
dest = (rose_address *)(skb->data + ROSE_CALL_REQ_DEST_ADDR_OFF);
- lci_o = ROSE_DEFAULT_MAXVC + 1 - lci_i;
+ /*
+ * The call and its answer use the same neighbour: give the
+ * answer the LCI at the other end of the 12-bit range, which
+ * rose_new_lci() never hands out, and get back from it.
+ */
+ lci_o = 0xFFF + 1 - lci_i;
skb_reset_transport_header(skb);
--
2.53.0
From 37c321ffa9d1fd31a50a06e5c4e70ac2ecc70fe8 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:27:08 +0100
Subject: [PATCH 6.12.y 08/10] rose: clear the other half of a through route a
new call takes over
When a Call Request comes in on the LCI of an existing through route,
for a call other than the one the route was built for, the neighbour
has evidently lost that call: it gives the LCI out again.
rose_route_frame() then removes the route and goes on with the new
call, but says nothing to the neighbour on the other half. That end
keeps its virtual circuit up with nothing behind it, and its LCI on
our side is freed while it may still send on it.
Do as rose_clear_routes_by_neigh() does when a neighbour goes away:
detach the half that the new call takes over and send a Clear Request
on the other half. The route stays for that half until its Clear
Confirmation, which removes it, and its LCI is not given to another
call meanwhile. The cause is the one given to a socket in the same
case, network congestion. A route that has no other half left is
removed as before.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 9b1a1d3395bdcf1eca96d3db517eae195d02a632)
---
net/rose/rose_route.c | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index 30dfbe1f1431..d23f8d30067b 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -1145,8 +1145,24 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
120);
goto out;
}
- /* Remove an existing unused route */
- rose_remove_route(rose_route);
+ /*
+ * Another call on the LCI of a through
+ * route: the neighbour no longer has the
+ * call it was built for. Clear the other
+ * half, which keeps the route until its
+ * Clear Confirmation, and leave the LCI
+ * to the new call.
+ */
+ if (rose_route->neigh2 != NULL) {
+ rose_neigh_put(rose_route->neigh1);
+ rose_route->neigh1 = NULL;
+ rose_transmit_clear_request(rose_route->neigh2,
+ rose_route->lci2,
+ ROSE_NETWORK_CONGESTION,
+ 0);
+ } else {
+ rose_remove_route(rose_route);
+ }
break;
} else if (rose_route->neigh2 != NULL) {
skb->data[0] &= 0xF0;
@@ -1180,8 +1196,24 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
120);
goto out;
}
- /* Remove an existing unused route */
- rose_remove_route(rose_route);
+ /*
+ * Another call on the LCI of a through
+ * route: the neighbour no longer has the
+ * call it was built for. Clear the other
+ * half, which keeps the route until its
+ * Clear Confirmation, and leave the LCI
+ * to the new call.
+ */
+ if (rose_route->neigh1 != NULL) {
+ rose_neigh_put(rose_route->neigh2);
+ rose_route->neigh2 = NULL;
+ rose_transmit_clear_request(rose_route->neigh1,
+ rose_route->lci1,
+ ROSE_NETWORK_CONGESTION,
+ 0);
+ } else {
+ rose_remove_route(rose_route);
+ }
break;
} else if (rose_route->neigh1 != NULL) {
skb->data[0] &= 0xF0;
--
2.53.0
From df53712ad979a3859f3c5cc5c8b573a0acd3713a Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Fri, 6 Nov 2026 13:27:56 +0100
Subject: [PATCH 6.12.y 09/10] rose: disconnect sockets under their lock when a
neighbour goes away
rose_kill_by_neigh() disconnects every socket that uses a neighbour
whose link has failed, restarted or gone down, holding only
rose_list_lock. rose_disconnect() stops the timers, purges the queues
and changes the state of the socket, but its timers and the frames
received for it work on the same socket under bh_lock_sock() only, on
other CPUs, and are not kept out by rose_list_lock.
Disconnect each socket under its lock. rose_rx_call_request() and
rose_kill_by_device() take the socket lock before rose_list_lock, so
do as rose_kill_by_device() does: take a reference on the sockets that
use the neighbour under rose_list_lock, drop it, and lock each socket
in turn, checking that it still uses the neighbour. The neighbour is
still taken under rose_list_lock as well: rose_release() takes it under
that lock while it owns the socket, which bh_lock_sock() does not keep
out.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 250c2ad2174f0a1aeb6c306e7bcc259a7fe2178d)
---
net/rose/af_rose.c | 48 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 2cb096068e5e..2a610cf8425a 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -162,19 +162,52 @@ static void rose_remove_socket(struct sock *sk)
*/
void rose_kill_by_neigh(struct rose_neigh *neigh)
{
- struct sock *s;
+ struct sock *s, *array[16];
+ bool rescan;
+ int i, cnt;
+ /*
+ * Each socket is disconnected under its lock, which its timers and
+ * the frames received for it hold while they work on it. That lock
+ * is taken before rose_list_lock elsewhere, so collect the sockets
+ * first, as rose_kill_by_device() does. rose_list_lock is still
+ * held around the change of the neighbour, which rose_release()
+ * takes under it while it owns the socket. A socket done with has
+ * no neighbour left and is not collected again.
+ */
+again:
+ rescan = false;
+ cnt = 0;
spin_lock_bh(&rose_list_lock);
sk_for_each(s, &rose_list) {
- struct rose_sock *rose = rose_sk(s);
+ if (rose_sk(s)->neighbour != neigh)
+ continue;
+ if (cnt == ARRAY_SIZE(array)) {
+ rescan = true;
+ break;
+ }
+ sock_hold(s);
+ array[cnt++] = s;
+ }
+ spin_unlock_bh(&rose_list_lock);
+
+ for (i = 0; i < cnt; i++) {
+ struct rose_sock *rose = rose_sk(array[i]);
+ bh_lock_sock(array[i]);
+ /* rose_release() takes the neighbour under rose_list_lock */
+ spin_lock_bh(&rose_list_lock);
if (rose->neighbour == neigh) {
- rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
+ rose_disconnect(array[i], ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
rose_neigh_put(rose->neighbour);
rose->neighbour = NULL;
}
+ spin_unlock_bh(&rose_list_lock);
+ bh_unlock_sock(array[i]);
+ sock_put(array[i]);
}
- spin_unlock_bh(&rose_list_lock);
+ if (rescan)
+ goto again;
}
/*
@@ -721,9 +754,10 @@ static int rose_release(struct socket *sock)
* Disconnect before the socket lock is dropped: frames put on
* the backlog meanwhile, a Clear Confirmation for one, then
* find it in state 0 instead of dropping the neighbour
- * reference a second time. rose_kill_by_neigh() does not take
- * the socket lock: take the neighbour under rose_list_lock, as
- * it does, so that only one of them drops the reference.
+ * reference a second time. rose_kill_by_neigh() can run while
+ * the socket is owned here: take the neighbour under
+ * rose_list_lock, as it does, so that only one of them drops
+ * the reference.
*/
rose_disconnect(sk, 0, -1, -1);
spin_lock_bh(&rose_list_lock);
--
2.53.0
From da763688431b2a631ff310185e482346fb5e0ec8 Mon Sep 17 00:00:00 2001
From: Bernard Pidoux <bernard.f6bvp@gmail.com>
Date: Mon, 5 Oct 2026 20:30:45 +0200
Subject: [PATCH 6.12.y 10/10] hdlcdrv: close the hardware driver once, and
only if it was opened
hdlcdrv_unregister() calls the hardware driver's close() when s->opened
is set and then calls unregister_netdev(). Two things go wrong:
- if the interface is still up, unregister_netdev() closes it through
ndo_stop, so hdlcdrv_close() calls the hardware driver's close() a
second time;
- hdlcdrv_open() sets s->opened before it calls the hardware driver's
open() and leaves it set when that fails, so close() is also called
for a port that was never opened.
The close() methods of the baycom drivers are not written for either
case. baycom_ser_fdx and baycom_ser_hdx call free_irq() and
release_region() for resources they do not hold. baycom_par
dereferences bc->pdev, which is NULL if the port was never opened and
points to an unregistered parport device after a first close.
Set s->opened only once the hardware driver's open() has succeeded,
and let unregister_netdev() do the closing.
Tested in a QEMU guest (6.12.94, KASAN and lockdep) with
baycom_ser_fdx and two ports: bcsf0 at an address without a UART, whose
open fails, and bcsf1 on a UART, left up. Unloading baycom_ser_fdx gave
before the change:
Trying to free already-free IRQ 5
ser12_close+0xa1/0x190 [baycom_ser_fdx]
cleanup_baycomserfdx+0x38/0x50 [baycom_ser_fdx]
resource: Trying to free nonexistent resource <0x300-0x307>
baycom_ser_fdx: close ser_fdx at iobase 0x250 irq 9
Trying to free already-free IRQ 9
resource: Trying to free nonexistent resource <0x250-0x257>
and after the change a single close of bcsf1 and no warning. The
baycom_par case was not reproduced, the test kernel has no parport
support.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 056d9c67e92622d5ec8cc6ce4a49179a16c53ef1)
---
drivers/net/hamradio/hdlcdrv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 2263029d1a20..dc4e2c45e2d1 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -441,7 +441,6 @@ static int hdlcdrv_open(struct net_device *dev)
/*
* initialise some variables
*/
- s->opened = 1;
s->hdlcrx.hbuf.rd = s->hdlcrx.hbuf.wr = 0;
s->hdlcrx.in_hdlc_rx = 0;
s->hdlcrx.rx_state = 0;
@@ -458,6 +457,7 @@ static int hdlcdrv_open(struct net_device *dev)
i = s->ops->open(dev);
if (i)
return i;
+ s->opened = 1;
netif_start_queue(dev);
return 0;
}
@@ -725,8 +725,7 @@ void hdlcdrv_unregister(struct net_device *dev)
BUG_ON(s->magic != HDLCDRV_MAGIC);
- if (s->opened && s->ops->close)
- s->ops->close(dev);
+ /* unregister_netdev() closes the device if it is still up */
unregister_netdev(dev);
free_netdev(dev);
--
2.53.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) - 10 more patches for 6.12.y/6.18.y
2026-11-16 11:17 ` Bernard Pidoux
@ 2026-11-16 16:06 ` Sasha Levin
0 siblings, 0 replies; 23+ messages in thread
From: Sasha Levin @ 2026-11-16 16:06 UTC (permalink / raw)
To: gregkh; +Cc: Sasha Levin, kuba, linux-hams, Bernard Pidoux, stable
> Here are the ten fixes merged in mod-orphan since then, for 6.12.y and
> 6.18.y.
Queued the series for 6.18 and 6.12, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2026-11-16 16:06 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 17:21 [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) Bernard Pidoux
2026-06-16 2:36 ` Greg KH
[not found] ` <CAFAa3YBciYSJxDT-SH=4oppyBS3hWUSEwJP_86EgUriJfYkjLw@mail.gmail.com>
[not found] ` <2026062048-posted-scarf-dcf2@gregkh>
2026-06-20 10:37 ` Bernard Pidoux
2026-06-20 10:51 ` Greg KH
2026-06-20 12:42 ` Bernard Pidoux
2026-06-25 11:04 ` Greg KH
[not found] ` <CAFAa3YAkgv9t==Xeh4hqTVCq3+hN1igwqWXPOu3gHmD54Wd2Kw@mail.gmail.com>
[not found] ` <CAFAa3YBDK8_va32Zi3myUsEhwNs20xnejO49m_06xOo3z3cK2Q@mail.gmail.com>
[not found] ` <2026093015-outmost-shrimp-45f8@gregkh>
2026-10-15 18:49 ` Bernard Pidoux
2026-10-17 3:00 ` Sasha Levin
2026-10-17 18:04 ` Bernard Pidoux
2026-10-19 11:11 ` Bernard Pidoux
2026-10-19 20:55 ` Sasha Levin
2026-10-21 17:25 ` Bernard Pidoux
2026-10-23 20:02 ` Sasha Levin
2026-10-24 9:53 ` Bernard Pidoux
2026-10-24 20:11 ` Sasha Levin
2026-10-25 9:41 ` Bernard Pidoux
2026-10-25 23:29 ` Sasha Levin
2026-11-09 10:30 ` Bernard Pidoux
2026-11-09 15:53 ` Sasha Levin
2026-11-16 11:17 ` Bernard Pidoux
2026-11-16 16:06 ` [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) - 10 more patches for 6.12.y/6.18.y Sasha Levin
2026-10-19 20:55 ` [stable request] ROSE memory-safety fixes for 7.0.y and earlier (merged out-of-tree in linux-netdev/mod-orphan) Sasha Levin
2026-06-21 13:47 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox