From patchwork Mon Jul 23 19:46:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1228711 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 309193FD4F for ; Mon, 23 Jul 2012 19:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754513Ab2GWTqe (ORCPT ); Mon, 23 Jul 2012 15:46:34 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:63631 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754410Ab2GWTqe (ORCPT ); Mon, 23 Jul 2012 15:46:34 -0400 Received: by gglu4 with SMTP id u4so5884605ggl.19 for ; Mon, 23 Jul 2012 12:46:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=3RlLl+LP/2UG6uUCGsWKKTihpem0AYXEJ/c26oyR1G4=; b=YRYgUqhuvYoeTmmolLK35oyubbaBA90OIQvkNx0sWb5/Yhglu8xsghClJ+S470DB/z KiM9THatNyiYgtLchfDfge9eFJjf11pXS8KyOc/z++swaqLgUiy6COOe9ADtlyjUsMGd m4wUwRLmNgszFskdv7SqPeBAzWqAUlaGp73kijWEKF0S0zJZbaZvM2ze7r6CHDbgL11w D7ivtaZTVro64ZZeEDGKQ7TW45PWrZDoFSCfXUjyjumrNhDw6P58eylb8DSkwrDVAukh lWaLN0Kv/3zlss/dPQ+26bDlR1f5L1f3mxhNRCbImHahNgXNTb9vjd42MzBKl4rO5dU0 /L/Q== Received: by 10.236.72.70 with SMTP id s46mr15674650yhd.108.1343072793307; Mon, 23 Jul 2012 12:46:33 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-076-182-054-194.nc.res.rr.com. [76.182.54.194]) by mx.google.com with ESMTPS id j17sm13308900anl.5.2012.07.23.12.46.32 (version=SSLv3 cipher=OTHER); Mon, 23 Jul 2012 12:46:32 -0700 (PDT) From: Jeff Layton To: trond.myklebust@netapp.com Cc: viro@ZenIV.linux.org.uk, linux-nfs@vger.kernel.org Subject: [PATCH] nfs: explicitly reject LOCK_MAND flock() requests Date: Mon, 23 Jul 2012 15:46:23 -0400 Message-Id: <1343072783-29737-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQkYv1ubNH7bYkg4e9VUfe4TuSelvIr/QzZIlyn0IzOyn2Kol54X646Y2xpRHlyX1uxQUsrg Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We have no mechanism to emulate LOCK_MAND locks on NFSv4, so explicitly return -EINVAL if someone requests it. Signed-off-by: Jeff Layton --- fs/nfs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 61d3670..15f4bbb 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -834,6 +834,15 @@ static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) if (!(fl->fl_flags & FL_FLOCK)) return -ENOLCK; + /* + * The NFSv4 protocol doesn't support LOCK_MAND, which is not part of + * any standard. In principle we might be able to support LOCK_MAND + * on NFSv2/3 since NLMv3/4 support DOS share modes, but for now the + * NFS code is not set up for it. + */ + if (fl->fl_type & LOCK_MAND) + return -EINVAL; + if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FLOCK) is_local = 1;