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
Kirill Smelkov
linux
Commits
05c1b290
Commit
05c1b290
authored
7 years ago
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mqueue: fold mq_attr_ok() into mqueue_get_inode()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
af4a5372
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
50 deletions
+21
-50
ipc/mqueue.c
ipc/mqueue.c
+21
-50
No files found.
ipc/mqueue.c
View file @
05c1b290
...
...
@@ -270,13 +270,30 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
* that means the min(mq_maxmsg, max_priorities) * struct
* posix_msg_tree_node.
*/
ret
=
-
EINVAL
;
if
(
info
->
attr
.
mq_maxmsg
<=
0
||
info
->
attr
.
mq_msgsize
<=
0
)
goto
out_inode
;
if
(
capable
(
CAP_SYS_RESOURCE
))
{
if
(
info
->
attr
.
mq_maxmsg
>
HARD_MSGMAX
||
info
->
attr
.
mq_msgsize
>
HARD_MSGSIZEMAX
)
goto
out_inode
;
}
else
{
if
(
info
->
attr
.
mq_maxmsg
>
ipc_ns
->
mq_msg_max
||
info
->
attr
.
mq_msgsize
>
ipc_ns
->
mq_msgsize_max
)
goto
out_inode
;
}
ret
=
-
EOVERFLOW
;
/* check for overflow */
if
(
info
->
attr
.
mq_msgsize
>
ULONG_MAX
/
info
->
attr
.
mq_maxmsg
)
goto
out_inode
;
mq_treesize
=
info
->
attr
.
mq_maxmsg
*
sizeof
(
struct
msg_msg
)
+
min_t
(
unsigned
int
,
info
->
attr
.
mq_maxmsg
,
MQ_PRIO_MAX
)
*
sizeof
(
struct
posix_msg_tree_node
);
mq_bytes
=
mq_treesize
+
(
info
->
attr
.
mq_maxmsg
*
info
->
attr
.
mq_msgsize
)
;
mq_bytes
=
info
->
attr
.
mq_maxmsg
*
info
->
attr
.
mq_msgsize
;
if
(
mq_bytes
+
mq_treesize
<
mq_bytes
)
goto
out_inode
;
mq_bytes
+=
mq_treesize
;
spin_lock
(
&
mq_lock
);
if
(
u
->
mq_bytes
+
mq_bytes
<
u
->
mq_bytes
||
u
->
mq_bytes
+
mq_bytes
>
rlimit
(
RLIMIT_MSGQUEUE
))
{
...
...
@@ -696,34 +713,6 @@ static void remove_notification(struct mqueue_inode_info *info)
info
->
notify_user_ns
=
NULL
;
}
static
int
mq_attr_ok
(
struct
ipc_namespace
*
ipc_ns
,
struct
mq_attr
*
attr
)
{
int
mq_treesize
;
unsigned
long
total_size
;
if
(
attr
->
mq_maxmsg
<=
0
||
attr
->
mq_msgsize
<=
0
)
return
-
EINVAL
;
if
(
capable
(
CAP_SYS_RESOURCE
))
{
if
(
attr
->
mq_maxmsg
>
HARD_MSGMAX
||
attr
->
mq_msgsize
>
HARD_MSGSIZEMAX
)
return
-
EINVAL
;
}
else
{
if
(
attr
->
mq_maxmsg
>
ipc_ns
->
mq_msg_max
||
attr
->
mq_msgsize
>
ipc_ns
->
mq_msgsize_max
)
return
-
EINVAL
;
}
/* check for overflow */
if
(
attr
->
mq_msgsize
>
ULONG_MAX
/
attr
->
mq_maxmsg
)
return
-
EOVERFLOW
;
mq_treesize
=
attr
->
mq_maxmsg
*
sizeof
(
struct
msg_msg
)
+
min_t
(
unsigned
int
,
attr
->
mq_maxmsg
,
MQ_PRIO_MAX
)
*
sizeof
(
struct
posix_msg_tree_node
);
total_size
=
attr
->
mq_maxmsg
*
attr
->
mq_msgsize
;
if
(
total_size
+
mq_treesize
<
total_size
)
return
-
EOVERFLOW
;
return
0
;
}
/*
* Invoked when creating a new queue via sys_mq_open
*/
...
...
@@ -731,24 +720,6 @@ static int do_create(struct ipc_namespace *ipc_ns, struct inode *dir,
struct
path
*
path
,
int
oflag
,
umode_t
mode
,
struct
mq_attr
*
attr
)
{
int
ret
;
if
(
attr
)
{
ret
=
mq_attr_ok
(
ipc_ns
,
attr
);
if
(
ret
)
return
ret
;
}
else
{
struct
mq_attr
def_attr
;
def_attr
.
mq_maxmsg
=
min
(
ipc_ns
->
mq_msg_max
,
ipc_ns
->
mq_msg_default
);
def_attr
.
mq_msgsize
=
min
(
ipc_ns
->
mq_msgsize_max
,
ipc_ns
->
mq_msgsize_default
);
ret
=
mq_attr_ok
(
ipc_ns
,
&
def_attr
);
if
(
ret
)
return
ret
;
}
return
vfs_mkobj
(
path
->
dentry
,
mode
&
~
current_umask
(),
mqueue_create_attr
,
attr
);
}
...
...
This diff is collapsed.
Click to expand it.
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