From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anton Altaparmakov Subject: CIFS kernel module bug Date: Fri, 30 Sep 2011 14:58:58 +0100 Message-ID: Mime-Version: 1.0 (Apple Message framework v1244.3) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org, LKML , PWF Linux To: Steve French Return-path: Sender: linux-cifs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Hi, Looking at the current kernel (in Linus' repository on github) there is= a silly logic bug in the cifs module in fs/cifs/cifsfs.c::cifs_llseek(= ) there is this bit of code: /* * origin =3D=3D SEEK_END || SEEK_DATA || SEEK_HOLE =3D> we must reval= idate * the cached file length */ if (origin !=3D SEEK_SET || origin !=3D SEEK_CUR) { The logical or should be a logical and, i.e. this should be: if (origin !=3D SEEK_SET && origin !=3D SEEK_CUR) { As the code is at present that line is ALWAYS true because origin is AL= WAYS either !=3D SEEK_SET or !=3D SEEK_CUR as if it equals one it canno= t equal the other and vice versa=85 So at the moment it always does the revalidation instead of only for SE= EK_END, SEEK_DATA, and SEEK_HOLE. Best regards, Anton --=20 Anton Altaparmakov (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer, http://www.linux-ntfs.org/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758579Ab1I3N7C (ORCPT ); Fri, 30 Sep 2011 09:59:02 -0400 Received: from ppsw-41.csi.cam.ac.uk ([131.111.8.141]:58491 "EHLO ppsw-41.csi.cam.ac.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752712Ab1I3N7A convert rfc822-to-8bit (ORCPT ); Fri, 30 Sep 2011 09:59:00 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Apple Message framework v1244.3) Subject: CIFS kernel module bug From: Anton Altaparmakov Date: Fri, 30 Sep 2011 14:58:58 +0100 Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, LKML , PWF Linux Content-Transfer-Encoding: 8BIT Message-Id: To: Steve French X-Mailer: Apple Mail (2.1244.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Looking at the current kernel (in Linus' repository on github) there is a silly logic bug in the cifs module in fs/cifs/cifsfs.c::cifs_llseek() there is this bit of code: /* * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate * the cached file length */ if (origin != SEEK_SET || origin != SEEK_CUR) { The logical or should be a logical and, i.e. this should be: if (origin != SEEK_SET && origin != SEEK_CUR) { As the code is at present that line is ALWAYS true because origin is ALWAYS either != SEEK_SET or != SEEK_CUR as if it equals one it cannot equal the other and vice versa… So at the moment it always does the revalidation instead of only for SEEK_END, SEEK_DATA, and SEEK_HOLE. Best regards, Anton -- Anton Altaparmakov (replace at with @) Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK Linux NTFS maintainer, http://www.linux-ntfs.org/