From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Jones Subject: Re: [PATCH] locks: only validate the lock vs. f_mode in F_SETLK codepaths Date: Fri, 9 May 2014 14:07:44 -0400 Message-ID: <20140509180744.GA9930@redhat.com> References: <1399652489-5217-1-git-send-email-jlayton@poochiereds.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, Reuben Farrelly , bfields@fieldses.org, swhiteho@redhat.com, ssorce@redhat.com To: Jeff Layton Return-path: Received: from mx1.redhat.com ([209.132.183.28]:18855 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756801AbaEISH7 (ORCPT ); Fri, 9 May 2014 14:07:59 -0400 Content-Disposition: inline In-Reply-To: <1399652489-5217-1-git-send-email-jlayton@poochiereds.net> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, May 09, 2014 at 12:21:29PM -0400, Jeff Layton wrote: > - /* Ensure that fl->fl_filp has compatible f_mode */ > - switch (l->l_type) { > - case F_RDLCK: > - if (!(filp->f_mode & FMODE_READ)) > - return -EBADF; > - break; > - case F_WRLCK: > - if (!(filp->f_mode & FMODE_WRITE)) > - return -EBADF; > - break; > - } > +check_fmode_for_setlk(struct file_lock *fl) > +{ > + switch (fl->fl_type) { > + case F_RDLCK: > + if (!(fl->fl_file->f_mode & FMODE_READ)) > + return -EBADF; > + case F_WRLCK: > + if (!(fl->fl_file->f_mode & FMODE_WRITE)) > + return -EBADF; > + } > + return 0; > +} Why are we now checking FMODE_WRITE for the RDLCK case ? Or was losing the break; unintentional ? Dave