From patchwork Fri Jan 31 14:27:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Prabhu X-Patchwork-Id: 3561851 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 95BB5C02DC for ; Fri, 31 Jan 2014 14:31:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BC8F2022D for ; Fri, 31 Jan 2014 14:31:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DA7C20249 for ; Fri, 31 Jan 2014 14:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754081AbaAaObP (ORCPT ); Fri, 31 Jan 2014 09:31:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25697 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754034AbaAaObP (ORCPT ); Fri, 31 Jan 2014 09:31:15 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0VEVCoJ020532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 31 Jan 2014 09:31:12 -0500 Received: from sachin-laptop.home (vpn1-7-121.ams2.redhat.com [10.36.7.121]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0VEVAZi005882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 31 Jan 2014 09:31:11 -0500 From: Sachin Prabhu To: linux-cifs Cc: Steve French Subject: [PATCH] cifs: Fix check for regular file in couldbe_mf_symlink() Date: Fri, 31 Jan 2014 14:27:16 +0000 Message-Id: <1391178436-10069-1-git-send-email-sprabhu@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP MF Symlinks are regular files containing content in a specified format. The function couldbe_mf_symlink() checks the mode for a set S_IFREG bit as a test to confirm that it is a regular file. This bit is also set for other filetypes and simply checking for this bit being set may return false positives. We ensure that we are actually checking for a regular file by using the S_ISREG macro to test instead. Signed-off-by: Sachin Prabhu Reported-by: Neil Brown Reported-by: Dan Carpenter Reviewed-by: Jeff Layton --- fs/cifs/link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 52f41f9..264ece7 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -185,7 +185,7 @@ format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str) bool couldbe_mf_symlink(const struct cifs_fattr *fattr) { - if (!(fattr->cf_mode & S_IFREG)) + if (!S_ISREG(fattr->cf_mode)) /* it's not a symlink */ return false;