Re: [PATCH 3/5] ipc,msg: always respect MSG_NOERROR

From: Davidlohr Bueso
Date: Sun May 18 2014 - 14:01:54 EST


On Sun, 2014-05-18 at 07:53 +0200, Manfred Spraul wrote:
> On 05/13/2014 10:27 PM, Davidlohr Bueso wrote:
> > When specifying the MSG_NOERROR flag, receivers can avoid returning
> > error (E2BIG) and just truncate the message text, if it is too large.
> >
> > Currently, this logic is only respected when there are already pending
> > messages in the queue.
> Do you have a test case? The code should handle that
> (See below)
> > Fix this for the case when there are only
> > receivers waiting for a msg to be sent. In order for this to work, save
> > the flags in the msg_receiver struct as it must be used later when
> > doing the pipeline send.
> No, it is sufficient to set the message size to infinity.
>
> > Also do some pipeline_send() cleanups while at it.
> No - please don't mix cleanups with bugfixes.
>
> >
> > long do_msgsnd(int msqid, long mtype, void __user *mtext,
> > @@ -901,6 +907,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, int msgfl
> > list_add_tail(&msr_d.r_list, &msq->q_receivers);
> > msr_d.r_tsk = current;
> > msr_d.r_msgtype = msgtyp;
> > + msr_d.r_msgflg = msgflg;
> > msr_d.r_mode = mode;
> > if (msgflg & MSG_NOERROR)
> > msr_d.r_maxsize = INT_MAX;
> ^^^^^^
> This code should handle MSG_NOERROR:
> If MSG_NOERROR is set, then maxsize is set to INT_MAX, therefore -E2BIG
> should never be returned.

Yeah, I noticed that, but I'd still prefer keeping the check, even if
redundant. It's free and by keeping both scenarios where there are and
aren't msg waiting in the queue the code becomes easier to read.

Thanks,
Davidlohr

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/