[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <45521580.5000606@in.ibm.com>
Date: Wed, 08 Nov 2006 09:36:00 -0800
From: Suzuki K P <suzuki@...ibm.com>
To: David Miller <davem@...emloft.net>
CC: linux-kernel@...r.kernel.org, Andrew Morton <akpm@...l.org>
Subject: Re: Behaviour of compat_msgsnd/compat_msgrcv calls
-- Original Post ---
> Hi,
>
> I have a question regarding the behaviour of the comapt_msgsnd/ compat_msgrcv ()s. Don't know if this has been discussed already or if as I could not find any threads in the archives. Please bear with me if this is really a stupid question.
>
> The maximum length of the message that can be sent or received in any of those functions above is MAXBUF-(sizeof (struct msgbuf)), where MAXBUF is 64k.
>
> ipc/compat.c : compat_msgrcv()
> if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf)))
> ^^^^^^
> return -EINVAL;
>
> Is this limit due to the buffer allocation in user space as below ?
>
> And the way we are doing this is by allocating a buffer of msgsize on the userspace stack using compat_alloc_user_space() instead of using the buffer provided by the user and later copying the result back to the user buffer.
>>
>>Is there any specific reason behind this ? Can't we just use the user
>>buffer directly instead of doing an additional copy_in_user ?
>>ie,
>> err = sys_msgrcv(first, uptr, second, msgtyp, third);
>
>
-- Dave suggested --
> It's the cleanest way to deal with the difference in
> "struct msgbuf" layout between native and compat userspace.
>
> I guess we could make some common do_sys_msgrcv() function
> that passed in a pointer to the "msgbuf" and the buffer
> seperately.
Dave,
I have attached a patch which does the same here. It introduces
do_msgrcv()/ do_msgsnd() routines to service the sys_msgxxx variants.
The do_msgxxx variants accepts an additional "mtext" parameter along
with the sys_msgxxx paramters.
i.e,
asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp,
size_t msgsz, long msgtyp, int msgflg)
{
return do_msgrcv(msqid, msgp, msgp->mtext, msgsz, msgtyp,
msgflg);
}
Comments ?
Thanks,
-Suzuki
View attachment "fix-compat-ipc-msg-size-limit.diff" of type "text/x-patch" (4819 bytes)
Powered by blists - more mailing lists