public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Behaviour of compat_msgsnd/compat_msgrcv calls
@ 2006-10-25 18:59 Suzuki K P
  2006-10-25 20:49 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Suzuki K P @ 2006-10-25 18:59 UTC (permalink / raw)
  To: lkml

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.

         if (!version) {
            [...]
                 if (copy_from_user (&ipck, uptr, sizeof(ipck)))
                         goto out;
                 uptr = compat_ptr(ipck.msgp);
                 msgtyp = ipck.msgtyp;

         }

         p = compat_alloc_user_space(second + sizeof(struct msgbuf));

Do we really need this allocation ?

         err = sys_msgrcv(first, p, second, msgtyp, third);

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);

Thanks,

-Suzuki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-11-11  1:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-25 18:59 Behaviour of compat_msgsnd/compat_msgrcv calls Suzuki K P
2006-10-25 20:49 ` David Miller
2006-11-08 17:36   ` Suzuki K P
2006-11-08 18:27     ` Suzuki K P
2006-11-11  1:24       ` [RFC] [PATCH] Fix compat space msg size limit for msgsnd/msgrcv ( Was Re: Behaviour of compat_msgsnd/compat_msgrcv calls ) suzuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox