From patchwork Tue Nov 14 13:47:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Lipatov X-Patchwork-Id: 10057693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13DAE6023A for ; Tue, 14 Nov 2017 13:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EADC72972F for ; Tue, 14 Nov 2017 13:55:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF99129721; Tue, 14 Nov 2017 13:55:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03E35296BA for ; Tue, 14 Nov 2017 13:55:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755109AbdKNNzl (ORCPT ); Tue, 14 Nov 2017 08:55:41 -0500 Received: from mail.etersoft.ru ([91.232.225.46]:37275 "EHLO mail.etersoft.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754606AbdKNNzl (ORCPT ); Tue, 14 Nov 2017 08:55:41 -0500 From: Vitaly Lipatov DKIM-Filter: OpenDKIM Filter v2.10.3 mail.etersoft.ru 557F9E6AF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etersoft.ru; s=dkim; t=1510667738; bh=GLKotmU5cqjUPsMFXoqDVrnHaCRF7dcC91rN5FVX7d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CmiXoSEAlx0F/uG8N9iICcENo4chht+TGHFOx743noCtJZGSr9u/Cp0vZgBibAD5c IuU/FXwM0c1siyBJMNoWVNT23S7eUysPgTykvDjE2eDE9OnDZ8k00hGf4vn4m/fxqt yIbZ/ZK53QdCs1zr/trxkMLGMEn4wacDKovdrWkE= To: lav@etersoft.ru, wine-patches Cc: Jeff Layton , "J. Bruce Fields" , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] fs/fcntl: restore checking against COMPAT_LOFF_T_MAX for F_GETLK64 Date: Tue, 14 Nov 2017 16:47:15 +0300 Message-Id: <20171114134715.21649-1-lav@etersoft.ru> X-Mailer: git-send-email 2.10.4 In-Reply-To: <20171114013009.26716-1-lav@etersoft.ru> References: <20171114013009.26716-1-lav@etersoft.ru> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP for fcntl64 with F_GETLK64 we need use checking against COMPAT_LOFF_T_MAX. Fixes: 94073ad77fff2 "fs/locks: don't mess with the address limit in compat_fcntl64" Signed-off-by: Vitaly Lipatov --- fs/fcntl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index 30f47d0..e9443d9 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -590,17 +590,17 @@ convert_fcntl_cmd(unsigned int cmd) * GETLK was successful and we need to return the data, but it needs to fit in * the compat structure. * l_start shouldn't be too big, unless the original start + end is greater than - * COMPAT_OFF_T_MAX, in which case the app was asking for trouble, so we return + * COMPAT_OFF_T_MAX/COMPAT_LOFF_T_MAX, in which case the app was asking for trouble, so we return * -EOVERFLOW in that case. l_len could be too big, in which case we just * truncate it, and only allow the app to see that part of the conflicting lock * that might make sense to it anyway */ -static int fixup_compat_flock(struct flock *flock) +static int fixup_compat_flock(struct flock *flock, loff_t off_t_max) { - if (flock->l_start > COMPAT_OFF_T_MAX) + if (flock->l_start > off_t_max) return -EOVERFLOW; - if (flock->l_len > COMPAT_OFF_T_MAX) - flock->l_len = COMPAT_OFF_T_MAX; + if (flock->l_len > off_t_max) + flock->l_len = off_t_max; return 0; } @@ -631,7 +631,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); if (err) break; - err = fixup_compat_flock(&flock); + err = fixup_compat_flock(&flock, COMPAT_OFF_T_MAX); if (err) return err; err = put_compat_flock(&flock, compat_ptr(arg)); @@ -644,7 +644,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock); if (err) break; - err = fixup_compat_flock(&flock); + err = fixup_compat_flock(&flock, COMPAT_OFF_T_MAX); if (err) return err; err = put_compat_flock64(&flock, compat_ptr(arg));