From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78441 invoked by alias); 1 Jun 2018 15:00:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 78352 invoked by uid 89); 1 Jun 2018 15:00:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Subject: Re: [PATCH] Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251) To: Adhemerval Zanella , libc-alpha@sourceware.org References: <1522877210-27934-1-git-send-email-adhemerval.zanella@linaro.org> From: Florian Weimer Message-ID: <36d1d0db-8661-5476-7e42-1a7015f4c766@redhat.com> Date: Fri, 01 Jun 2018 15:00:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1522877210-27934-1-git-send-email-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00009.txt.bz2 On 04/04/2018 11:26 PM, Adhemerval Zanella wrote: > @@ -59,16 +50,56 @@ __libc_fcntl (int fd, int cmd, ...) > > cmd = FCNTL_ADJUST_CMD (cmd); > > - if (cmd == F_SETLKW || cmd == F_SETLKW64) > - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); > - > - return fcntl_common (fd, cmd, arg); > + switch (cmd) > + { > + case F_SETLKW: > + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); > + case F_GETLK64: > + case F_OFD_GETLK: > + { > + struct flock *flk = (struct flock *) arg; > + struct flock64 flk64 = flock_to_flock64 (flk); > + int ret = SYSCALL_CANCEL (fcntl64, fd, cmd, &flk64); > + if (ret == -1) > + return -1; > + flk->l_type = flk64.l_type; > + flk->l_whence = flk64.l_whence; > + flk->l_start = flk64.l_start; > + flk->l_len = flk64.l_len; > + flk->l_pid = flk64.l_pid; > + return ret; Doesn't this need an overflow check? I think you should mention somewhere that this introduces new cancellation points. Thanks, Florian