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: Ondrej Bilka X-Patchwork-Id: 727 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id C124D360060 for ; Mon, 28 Apr 2014 09:04:31 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14307373) id 74B0013F8992; Mon, 28 Apr 2014 09:04:30 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx21.g.dreamhost.com 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 homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id 6043513DF3A1 for ; Mon, 28 Apr 2014 09:04:29 -0700 (PDT) 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=faHE70fshuqbvYxP3llg5QYQIiujiN j65MPWYB38jUldjkxHyZosXt17vkDQcXp8JDW90LNuNXQFkw7z/22EYt219f5wxz zb+J1yPPge/Bo6L+yhvB7vbudqoIM0RlF56jX6u/vBURe5Ykn69fC3AaKGYoXKDi If67p5voDxwsM= 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=Gruo MA2CjlL3eKUGg10pv9cqIZcMFNxbiV9RsI1t4qQQlX/yXzVZhZqhT6ABzPeXf0JO hIRTvaTLS25fLTTgm8fOZP/riKh9Wa98DNDWn3Sob5QWDuS8Nsu3xij5iL9O4DOl AArLhdgy7f0IvZSj4EuLDO63wQW7V+4ruEyDy+0= 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) X-DH-Original-To: glibc@patchwork.siddhesh.in 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)