af_unix: mark MSG_SPLICE_PAGES frags shared
Subsystems (3)
PATCH 1/1 af_unix: mark MSG_SPLICE_PAGES frags shared
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.
--- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)
net/unix/af_unix.c +1 -0
@@ -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);
Signature · 1 line
2.34.1
Kuniyuki Iwashima
maintainerQuoted 4 lines · Yiming Qian
unix_stream_sendmsg()splices external pages directly into skb frags whenMSG_SPLICE_PAGESis set, but it does not propagateSKBFL_SHARED_FRAGafterward.
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 ?
Quoted 9 lines
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 <[email protected]>Reported-by Can Liu <[email protected]>
Reported-by is not needed when it's identical to SOB tag.
Quoted 20 lines
Signed-off-by Yiming Qian <[email protected]>Signed-off-by Can Liu <[email protected]>--- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)net/unix/af_unix.c +1
-1@@ -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
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.
Quoted 46 lines · Kuniyuki Iwashima <[email protected]> 于2026年6月30日周二 23:51写道:
Quoted 4 lines · Yiming Qian
unix_stream_sendmsg()splices external pages directly into skb frags whenMSG_SPLICE_PAGESis set, but it does not propagateSKBFL_SHARED_FRAGafterward.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 ?
Quoted 9 lines
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 <[email protected]>Reported-by Can Liu <[email protected]>Reported-by is not needed when it's identical to SOB tag.
Quoted 20 lines
Signed-off-by Yiming Qian <[email protected]>Signed-off-by Can Liu <[email protected]>--- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)net/unix/af_unix.c +1
-1@@ -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
Kuniyuki Iwashima
maintainerQuoted 11 lines · 钱一铭
Thanks, I agree plain
AF_UNIXdoes not by itself provide the writer side.The concern was that
MSG_SPLICE_PAGESimports externally owned pages into skb frags, while unlike TCP/UDP/KCM this path does not mark them withSKBFL_SHARED_FRAG. I checked theAF_UNIXsockmap path as well, but I do not currently have a concrete in-tree chain where those frags reach a writer that skips COW based onskb_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.
Quoted 50 lines
I will drop the Fixes tag and the duplicate Reported-by
tags in v2.Quoted 46 lines · Kuniyuki Iwashima <[email protected]> 于2026年6月30日周二 23:51写道:
Quoted 4 lines · Yiming Qian
unix_stream_sendmsg()splices external pages directly into skb frags whenMSG_SPLICE_PAGESis set, but it does not propagateSKBFL_SHARED_FRAGafterward.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 ?
Quoted 9 lines
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 <[email protected]>Reported-by Can Liu <[email protected]>Reported-by is not needed when it's identical to SOB tag.
Quoted 20 lines
Signed-off-by Yiming Qian <[email protected]>Signed-off-by Can Liu <[email protected]>--- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+)net/unix/af_unix.c +1
-1@@ -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