Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
c3bb1361
Commit
c3bb1361
authored
Oct 27, 2002
by
James Morris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Backport netlink_set_nonroot changes by Andi Kleen.
parent
41e76c56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
include/linux/netlink.h
include/linux/netlink.h
+4
-0
net/core/rtnetlink.c
net/core/rtnetlink.c
+1
-0
net/netlink/af_netlink.c
net/netlink/af_netlink.c
+15
-3
net/netsyms.c
net/netsyms.c
+1
-0
No files found.
include/linux/netlink.h
View file @
c3bb1361
...
...
@@ -162,6 +162,10 @@ extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
int
(
*
done
)(
struct
netlink_callback
*
));
#define NL_NONROOT_RECV 0x1
#define NL_NONROOT_SEND 0x2
extern
void
netlink_set_nonroot
(
int
protocol
,
unsigned
flag
);
#endif
/* __KERNEL__ */
#endif
/* __LINUX_NETLINK_H */
net/core/rtnetlink.c
View file @
c3bb1361
...
...
@@ -523,6 +523,7 @@ void __init rtnetlink_init(void)
rtnl
=
netlink_kernel_create
(
NETLINK_ROUTE
,
rtnetlink_rcv
);
if
(
rtnl
==
NULL
)
panic
(
"rtnetlink_init: cannot initialize rtnetlink
\n
"
);
netlink_set_nonroot
(
NETLINK_ROUTE
,
NL_NONROOT_RECV
);
register_netdevice_notifier
(
&
rtnetlink_dev_notifier
);
rtnetlink_links
[
PF_UNSPEC
]
=
link_rtnetlink_table
;
rtnetlink_links
[
PF_PACKET
]
=
link_rtnetlink_table
;
...
...
net/netlink/af_netlink.c
View file @
c3bb1361
...
...
@@ -69,6 +69,7 @@ struct netlink_opt
static
struct
sock
*
nl_table
[
MAX_LINKS
];
static
DECLARE_WAIT_QUEUE_HEAD
(
nl_table_wait
);
static
unsigned
nl_nonroot
[
MAX_LINKS
];
#ifdef NL_EMULATE_DEV
static
struct
socket
*
netlink_kernel
[
MAX_LINKS
];
...
...
@@ -317,6 +318,11 @@ static int netlink_autobind(struct socket *sock)
return
0
;
}
static
inline
int
netlink_capable
(
struct
socket
*
sock
,
unsigned
flag
)
{
return
(
nl_nonroot
[
sock
->
sk
->
protocol
]
&
flag
)
||
capable
(
CAP_NET_ADMIN
);
}
static
int
netlink_bind
(
struct
socket
*
sock
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
struct
sock
*
sk
=
sock
->
sk
;
...
...
@@ -328,7 +334,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, int addr_len
return
-
EINVAL
;
/* Only superuser is allowed to listen multicasts */
if
(
nladdr
->
nl_groups
&&
!
capable
(
CAP_NET_ADMIN
))
if
(
nladdr
->
nl_groups
&&
!
netlink_capable
(
sock
,
NL_NONROOT_RECV
))
return
-
EPERM
;
if
(
nlk
->
pid
)
{
...
...
@@ -368,7 +374,7 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
return
-
EINVAL
;
/* Only superuser is allowed to send multicasts */
if
(
nladdr
->
nl_groups
&&
!
capable
(
CAP_NET_ADMIN
))
if
(
nladdr
->
nl_groups
&&
!
netlink_capable
(
sock
,
NL_NONROOT_SEND
))
return
-
EPERM
;
if
(
!
nlk
->
pid
)
...
...
@@ -590,7 +596,7 @@ static int netlink_sendmsg(struct kiocb *iocb, struct socket *sock,
return
-
EINVAL
;
dst_pid
=
addr
->
nl_pid
;
dst_groups
=
addr
->
nl_groups
;
if
(
dst_groups
&&
!
capable
(
CAP_NET_ADMIN
))
if
(
dst_groups
&&
!
netlink_capable
(
sock
,
NL_NONROOT_SEND
))
return
-
EPERM
;
}
else
{
dst_pid
=
nlk
->
dst_pid
;
...
...
@@ -743,6 +749,12 @@ netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len))
return
sk
;
}
void
netlink_set_nonroot
(
int
protocol
,
unsigned
flags
)
{
if
((
unsigned
)
protocol
<
MAX_LINKS
)
nl_nonroot
[
protocol
]
=
flags
;
}
static
void
netlink_destroy_callback
(
struct
netlink_callback
*
cb
)
{
if
(
cb
->
skb
)
...
...
net/netsyms.c
View file @
c3bb1361
...
...
@@ -408,6 +408,7 @@ EXPORT_SYMBOL(netlink_unicast);
EXPORT_SYMBOL
(
netlink_kernel_create
);
EXPORT_SYMBOL
(
netlink_dump_start
);
EXPORT_SYMBOL
(
netlink_ack
);
EXPORT_SYMBOL
(
netlink_set_nonroot
);
EXPORT_SYMBOL
(
netlink_register_notifier
);
EXPORT_SYMBOL
(
netlink_unregister_notifier
);
#if defined(CONFIG_NETLINK_DEV) || defined(CONFIG_NETLINK_DEV_MODULE)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment