[LTP] [PATCH 1/2] msgrcv07: Check negative msg type filters
xuyang2018.jy@fujitsu.com
xuyang2018.jy@fujitsu.com
Wed Oct 13 08:56:16 CEST 2021
Hi Richard
> It should leave higher message types on the queue if they are above
> the specified type's magnitude.
>
> Also check what happens when MSG_EXCEPT is passed with a negative msg
> type. This behavior is unspecified, but presently the kernel ignores
> the flag if the type is negative. The motivation to check this is long
> handling in 32bit compat mode. If the msg type is not sign extended
> then it will be treated as a large positive integer. In this case we
> should receive the remaining message.
>
> On the current kernel under x86 the test passes because the system
> call has an explicit compat variant which performs the sign
> extension. Otherwise it would fail.
>
> Signed-off-by: Richard Palethorpe<rpalethorpe@suse.com>
> ---
> testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
> index 2c687c5c8..8635ef7a4 100644
> --- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
> +++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
> @@ -232,6 +232,13 @@ static void test_negative_msgtyp(void)
> "-msgtyp didn't get the first message in the queue with the lowest type");
> }
>
> + TST_EXP_FAIL(msgrcv(queue_id,&rcv_buf, MSGSIZE, -MSGTYPE1, IPC_NOWAIT),
> + ENOMSG,
> + "-msgtype didn't recv next lowest msg");
> + TST_EXP_FAIL(msgrcv(queue_id,&rcv_buf, MSGSIZE, -MSGTYPE1, MSG_EXCEPT | IPC_NOWAIT),
> + ENOMSG,
> + "-msgtype (with except) didn't recv next lowest msg");
> +
It should use TST_EXP_FAIL2 macro. Other than this, look good to me
Reviewed-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Best Regards
Yang Xu
> exit:
> SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
> queue_id = -1;
More information about the ltp
mailing list