From patchwork Mon Apr 28 16:04:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?T25kxZllaiBCw61sa2E=?= X-Patchwork-Id: 343485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B34BA140088 for ; Tue, 29 Apr 2014 02:04:32 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; q=dns; s=default; b=UFzqJ0vriQXLyN7vIQg8MENzN/wajH V7XP8+pZ6y2zBZt9/2y7Edm3GZ13K2A2P51rDyiGCFB/vmbicjmgHPlKXS+7nK8U oRAAapUWzdq/60iAqKB/NPLhI9W4slokpNhKpjuF/HYrNhG7s9OpXf+XU0rkaXAS 43R3dPbhBwOoc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; s=default; bh=DQhnHxdCMCZu5K1JVr3U59y3M9I=; b=FKxY 7EKO20+mD5HXc8aOwFdGYE+9eRZKfQpUqCO3psfcY9s2BMBRxcAEfLZ0gVS9NIiZ AaFPzV6H52B610hqgUATB5SqDekwwHc/III6/Z95o1UsF3ZKAggAImH0ERH/I3/e OM90wpSozXlxIvMk2aCJdy113USXGFMn5Q0aYjE= Received: (qmail 15789 invoked by alias); 28 Apr 2014 16:04:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15778 invoked by uid 89); 28 Apr 2014 16:04:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Mon, 28 Apr 2014 18:04:20 +0200 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: Andreas Schwab Cc: libc-alpha@sourceware.org Subject: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument. Message-ID: <20140428160420.GA23142@domone.podge> References: <20140428152937.GA1736@domone.podge> <87mwf5zcl3.fsf@igel.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87mwf5zcl3.fsf@igel.home> User-Agent: Mutt/1.5.20 (2009-06-14) On Mon, Apr 28, 2014 at 05:40:56PM +0200, Andreas Schwab wrote: > Ondřej Bílka writes: > > > + struct timespec dummy; > > + memcpy (&dummy, tmo, sizeof (struct timespec)); > > What's wrong with an assignment? > My first idea was memcpy, thanks. > > if (SINGLE_THREAD_P) > > return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo); > > You still pass a const where a non-const is expected. > fixed. > Andreas. > Here is v2. * sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber timeout argument. diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index 57ddf31..04a065f 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -35,14 +35,16 @@ #ifdef __NR_recvmmsg int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, - const struct timespec *tmo) + const struct timespec *_tmo) { + struct timespec tmo = *_tmo; + if (SINGLE_THREAD_P) - return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo); + return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, &tmo); int oldtype = LIBC_CANCEL_ASYNC (); - int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo); + int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, &tmo); LIBC_CANCEL_RESET (oldtype); @@ -52,18 +54,20 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, # ifndef __ASSUME_RECVMMSG_SOCKETCALL extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, - const struct timespec *tmo) + struct timespec *tmo) attribute_hidden; static int have_recvmmsg; int recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, - const struct timespec *tmo) + const struct timespec *_tmo) { + struct timespec tmo = *_tmo; + if (__glibc_likely (have_recvmmsg >= 0)) { - int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo); + int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, &tmo); /* The kernel returns -EINVAL for unknown socket operations. We need to convert that error to an ENOSYS error. */ if (__builtin_expect (ret < 0, 0)