* [PATCH] af_unix: mark MSG_SPLICE_PAGES frags shared
@ 2026-06-30 7:05 Yiming Qian
2026-06-30 15:51 ` Kuniyuki Iwashima
0 siblings, 1 reply; 4+ messages in thread
From: Yiming Qian @ 2026-06-30 7:05 UTC (permalink / raw)
To: security
Cc: Kuniyuki Iwashima, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, netdev, linux-kernel,
lingchen5202005, yimingqian591
unix_stream_sendmsg() splices external pages directly into skb frags when
MSG_SPLICE_PAGES is set, but it does not propagate SKBFL_SHARED_FRAG
afterward.
That leaves later writers without the shared-frag marker even though the
skb still references externally owned pages.
Set the marker after a successful skb_splice_from_iter() call.
Fixes: a0dbf5f818f90 ("af_unix: Support MSG_SPLICE_PAGES")
Reported-by: Yiming Qian <yimingqian591@gmail.com>
Reported-by: Can Liu <lingchen5202005@gmail.com>
Signed-off-by: Yiming Qian <yimingqian591@gmail.com>
Signed-off-by: Can Liu <lingchen5202005@gmail.com>
---
net/unix/af_unix.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index f7a9d55eee8a1..f2cd0f8ec0914 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2458,6 +2458,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
goto out_free;
size = err;
+ skb_shinfo(skb)->flags |= SKBFL_SHARED_FRAG;
refcount_add(size, &sk->sk_wmem_alloc);
} else {
skb_put(skb, size - data_len);
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] af_unix: mark MSG_SPLICE_PAGES frags shared
2026-06-30 7:05 [PATCH] af_unix: mark MSG_SPLICE_PAGES frags shared Yiming Qian
@ 2026-06-30 15:51 ` Kuniyuki Iwashima
2026-07-02 2:05 ` 钱一铭
0 siblings, 1 reply; 4+ messages in thread
From: Kuniyuki Iwashima @ 2026-06-30 15:51 UTC (permalink / raw)
To: Yiming Qian
Cc: security, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel, lingchen5202005
On Tue, Jun 30, 2026 at 12:06 AM Yiming Qian <yimingqian591@gmail.com> wrote:
>
> unix_stream_sendmsg() splices external pages directly into skb frags when
> MSG_SPLICE_PAGES is set, but it does not propagate SKBFL_SHARED_FRAG
> afterward.
I think it doesn't matter with the plain AF_UNIX.
Please elaborate on the scenario where this could be a problem.
e.g. sockmap ?
>
> That leaves later writers without the shared-frag marker even though the
> skb still references externally owned pages.
>
> Set the marker after a successful skb_splice_from_iter() call.
>
> Fixes: a0dbf5f818f90 ("af_unix: Support MSG_SPLICE_PAGES")
> Reported-by: Yiming Qian <yimingqian591@gmail.com>
> Reported-by: Can Liu <lingchen5202005@gmail.com>
Reported-by is not needed when it's identical to SOB tag.
> Signed-off-by: Yiming Qian <yimingqian591@gmail.com>
> Signed-off-by: Can Liu <lingchen5202005@gmail.com>
> ---
> net/unix/af_unix.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index f7a9d55eee8a1..f2cd0f8ec0914 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -2458,6 +2458,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
> goto out_free;
>
> size = err;
> + skb_shinfo(skb)->flags |= SKBFL_SHARED_FRAG;
> refcount_add(size, &sk->sk_wmem_alloc);
> } else {
> skb_put(skb, size - data_len);
> --
> 2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] af_unix: mark MSG_SPLICE_PAGES frags shared
2026-06-30 15:51 ` Kuniyuki Iwashima
@ 2026-07-02 2:05 ` 钱一铭
2026-07-02 2:18 ` Kuniyuki Iwashima
0 siblings, 1 reply; 4+ messages in thread
From: 钱一铭 @ 2026-07-02 2:05 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: security, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel, lingchen5202005
Thanks, I agree plain AF_UNIX does not by itself provide the writer side.
The concern was that MSG_SPLICE_PAGES imports externally owned pages into
skb frags, while unlike TCP/UDP/KCM this path does not mark them with
SKBFL_SHARED_FRAG. I checked the AF_UNIX sockmap path as well, but I do
not currently have a concrete in-tree chain where those frags reach a
writer that skips COW based on skb_has_shared_frag().
So this should be treated as a defensive consistency cleanup rather than
a security fix. I will drop the Fixes tag and the duplicate Reported-by
tags in v2.
Kuniyuki Iwashima <kuniyu@google.com> 于2026年6月30日周二 23:51写道:
>
> On Tue, Jun 30, 2026 at 12:06 AM Yiming Qian <yimingqian591@gmail.com> wrote:
> >
> > unix_stream_sendmsg() splices external pages directly into skb frags when
> > MSG_SPLICE_PAGES is set, but it does not propagate SKBFL_SHARED_FRAG
> > afterward.
>
> I think it doesn't matter with the plain AF_UNIX.
>
> Please elaborate on the scenario where this could be a problem.
> e.g. sockmap ?
>
>
> >
> > That leaves later writers without the shared-frag marker even though the
> > skb still references externally owned pages.
> >
> > Set the marker after a successful skb_splice_from_iter() call.
> >
> > Fixes: a0dbf5f818f90 ("af_unix: Support MSG_SPLICE_PAGES")
> > Reported-by: Yiming Qian <yimingqian591@gmail.com>
> > Reported-by: Can Liu <lingchen5202005@gmail.com>
>
> Reported-by is not needed when it's identical to SOB tag.
>
>
> > Signed-off-by: Yiming Qian <yimingqian591@gmail.com>
> > Signed-off-by: Can Liu <lingchen5202005@gmail.com>
> > ---
> > net/unix/af_unix.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> > index f7a9d55eee8a1..f2cd0f8ec0914 100644
> > --- a/net/unix/af_unix.c
> > +++ b/net/unix/af_unix.c
> > @@ -2458,6 +2458,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
> > goto out_free;
> >
> > size = err;
> > + skb_shinfo(skb)->flags |= SKBFL_SHARED_FRAG;
> > refcount_add(size, &sk->sk_wmem_alloc);
> > } else {
> > skb_put(skb, size - data_len);
> > --
> > 2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] af_unix: mark MSG_SPLICE_PAGES frags shared
2026-07-02 2:05 ` 钱一铭
@ 2026-07-02 2:18 ` Kuniyuki Iwashima
0 siblings, 0 replies; 4+ messages in thread
From: Kuniyuki Iwashima @ 2026-07-02 2:18 UTC (permalink / raw)
To: 钱一铭
Cc: security, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel, lingchen5202005
On Wed, Jul 1, 2026 at 7:05 PM 钱一铭 <yimingqian591@gmail.com> wrote:
>
> Thanks, I agree plain AF_UNIX does not by itself provide the writer side.
>
> The concern was that MSG_SPLICE_PAGES imports externally owned pages into
> skb frags, while unlike TCP/UDP/KCM this path does not mark them with
> SKBFL_SHARED_FRAG. I checked the AF_UNIX sockmap path as well, but I do
> not currently have a concrete in-tree chain where those frags reach a
> writer that skips COW based on skb_has_shared_frag().
>
> So this should be treated as a defensive consistency cleanup rather than
> a security fix.
Hmm, if it's not exploitable, let's not add that. It's rather confusing
to future readers.
> I will drop the Fixes tag and the duplicate Reported-by
> tags in v2.
>
> Kuniyuki Iwashima <kuniyu@google.com> 于2026年6月30日周二 23:51写道:
> >
> > On Tue, Jun 30, 2026 at 12:06 AM Yiming Qian <yimingqian591@gmail.com> wrote:
> > >
> > > unix_stream_sendmsg() splices external pages directly into skb frags when
> > > MSG_SPLICE_PAGES is set, but it does not propagate SKBFL_SHARED_FRAG
> > > afterward.
> >
> > I think it doesn't matter with the plain AF_UNIX.
> >
> > Please elaborate on the scenario where this could be a problem.
> > e.g. sockmap ?
> >
> >
> > >
> > > That leaves later writers without the shared-frag marker even though the
> > > skb still references externally owned pages.
> > >
> > > Set the marker after a successful skb_splice_from_iter() call.
> > >
> > > Fixes: a0dbf5f818f90 ("af_unix: Support MSG_SPLICE_PAGES")
> > > Reported-by: Yiming Qian <yimingqian591@gmail.com>
> > > Reported-by: Can Liu <lingchen5202005@gmail.com>
> >
> > Reported-by is not needed when it's identical to SOB tag.
> >
> >
> > > Signed-off-by: Yiming Qian <yimingqian591@gmail.com>
> > > Signed-off-by: Can Liu <lingchen5202005@gmail.com>
> > > ---
> > > net/unix/af_unix.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> > > index f7a9d55eee8a1..f2cd0f8ec0914 100644
> > > --- a/net/unix/af_unix.c
> > > +++ b/net/unix/af_unix.c
> > > @@ -2458,6 +2458,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
> > > goto out_free;
> > >
> > > size = err;
> > > + skb_shinfo(skb)->flags |= SKBFL_SHARED_FRAG;
> > > refcount_add(size, &sk->sk_wmem_alloc);
> > > } else {
> > > skb_put(skb, size - data_len);
> > > --
> > > 2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-02 2:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-30 7:05 [PATCH] af_unix: mark MSG_SPLICE_PAGES frags shared Yiming Qian
2026-06-30 15:51 ` Kuniyuki Iwashima
2026-07-02 2:05 ` 钱一铭
2026-07-02 2:18 ` Kuniyuki Iwashima
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®