Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1455250imm; Sun, 15 Jul 2018 08:09:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfNORhgSM+T5ImPGiDw8wbRa49BeBl3MaHTYKxtU4YqczX/ChrFMHlifl4pXc+apBig3avV X-Received: by 2002:a63:b349:: with SMTP id x9-v6mr12616663pgt.337.1531667370363; Sun, 15 Jul 2018 08:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531667370; cv=none; d=google.com; s=arc-20160816; b=ZQPqMy3h/TKOUBtmjB+jZEiVUhsn2v32Hk/xw9sj362lv+pTCl+6egRioJaBojB0G1 LeQ5UH1gYdEUlYgUlBspbmHUqQveaC5udyaxW90i4NUerk+IhoqXj/VU4u/HkK2tGq5V hSdu+w9hE2E5gB5DKI5eNvHiGponMS0G7ROC1/37xLLa5sZHYrEYc4fQohWNq1ARGRgY FqhknparXDN70SsuljLR9aujY4Gd8Tt+iPagSA098neQQ791nwvqBqwVwmRXLjFkv91S yhG+IHgTGeG45YIS7pDuuQFPe5uBucdpDZJ/hnC14U3UTIz2kra1iw1yEB3aXoG0JaEk B7Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=GbGD6dICMVOLkZcfAZiQD1V7K+TI1KHGPhQeJUZnzt8=; b=qL+Xd3f44A5g7smr4WwKD9unpUiPGZgE+fQagOcJqJpaZOmHgZwdHhoz++zZs3YtCh 7PJvyWXrKPa09GCD1wY5vG9xg1UgWLQwv681oHqGD3avIdu+aXnrTJdQlx243udL66Rp zJC5OvmbJ9Ywyt1reo8nHbTAzuvKiqFUz4s97xJgLAugKc/Ov0IjFtBXG2yDj/JZIVb6 RTMXpnw8VhEGnFMqREkkqJZTuszexykVrK7JmqpAOEFLhaVpPvoIf5oTrJW1WF5vfgJg hbs7fjQRQZqLhF2ZzvLpFOPUn38Bqf3/DsYYdvEg4FY/Q/cbkXOczF//SBaOgnLXZJ0D eJGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Vv/HJxbK"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5-v6si27210406plr.56.2018.07.15.08.09.15; Sun, 15 Jul 2018 08:09:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Vv/HJxbK"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726932AbeGOPbu (ORCPT + 99 others); Sun, 15 Jul 2018 11:31:50 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34800 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726333AbeGOPbu (ORCPT ); Sun, 15 Jul 2018 11:31:50 -0400 Received: by mail-oi0-f65.google.com with SMTP id 13-v6so70369725ois.1 for ; Sun, 15 Jul 2018 08:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GbGD6dICMVOLkZcfAZiQD1V7K+TI1KHGPhQeJUZnzt8=; b=Vv/HJxbK30WV7mIngWTuQZmheMDo/bkJlq9ewnx94rZmcy5xWzxA/4WaE84ovM4ST0 8qW/JpoHRi4eDsKpFr6JI2Pe3UoDfFHig5bvIP2xHIf0Hk/m7GfrpEGrGBz4H+c4gIUk pxlDcZHUbJWXWmqtReWA4kLOgT1I26SP9gMwjez8+6eBGywrU+jQjeoDyjPeDAyZw9IP Inrc7dndax8Y7B0e9XU5p0GHsGsuWd0MRtbyFK6VAjoZCrJ6EaGt3tXsAP43SB5dBzXR lPeFszhotu65w8GC/7ajpV0Ii3XCTdREoF4S19TYZ0tYdFHWFWDOcY5tKw/bBhOI8OS4 chbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GbGD6dICMVOLkZcfAZiQD1V7K+TI1KHGPhQeJUZnzt8=; b=FtZbKhlRdLmLlusvuB4i+2Xw4rR7LKVsawYz/KK0yE8j74d7RpCmnChFT0KkqutOkM ewz7gC0UU0E6W4Gkd1T+QbCPSjgoA8fCvECiKKDAHKIg/Ps3t4GL83nYcV5EbW2G58Bz QRxoUjlEXrV3R5V/H7Y3LGcnNJO/Uu0ZdaItV0fA3Scg1XuNgI5ss5E3yAbNKN7O7oov 2NezEUQ+y0tIzD/MxY/KirvxZVEPwIzze5ugyiRsJfG7f0MgcmZny0ryW9nIxYEeclXP K5V5bhIvR7exZEIbfSHp0Ncvs/bTq1rT2aRx0UHYwiZbeyAUwNiYE9LjOUHmBVmd1pCD pszA== X-Gm-Message-State: AOUpUlGjnVUwC6CR13E9wa3g/28i95/VvvViagQmPJkJ0N3Qo8hwj8mM jA89bmaPt/G2NM9Gd5Ww/Mudfz6AxM7CCa4BJSxRvvFpLNM= X-Received: by 2002:aca:3546:: with SMTP id c67-v6mr15405882oia.249.1531667314330; Sun, 15 Jul 2018 08:08:34 -0700 (PDT) MIME-Version: 1.0 References: <878t6c7f8p.fsf@mail.parknet.co.jp> <20180715143043.GM30522@ZenIV.linux.org.uk> In-Reply-To: <20180715143043.GM30522@ZenIV.linux.org.uk> From: Anatoly Trosinenko Date: Sun, 15 Jul 2018 18:08:23 +0300 Message-ID: Subject: Re: FAT: Operating on broken FAT FS causes the write syscall to return negative number not equal to -1 To: viro@zeniv.linux.org.uk Cc: OGAWA Hirofumi , akpm@linux-foundation.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you! > This patch returns better error (-EIO) for me. This works for me likewise. > (But note, the corrupted FS image doesn't guarantee POSIX behavior.) Oops, I was just doing some testing and thought that correct behavior for crafted FS is to return arbitrary valid error code (like -EIO) or some arbitrary data, say, not larger than FS (not disclosing the kernel memory, of course). Please excuse me if I was wrong. If fixing this would slow down some hot code path, then I am not insisting on returning valid errno. :) Meanwhile, how should be considered such discrepancies with man pages for invalid FS images: should it be considered low priority bug, not-a-bug or feature request (diagnostics)? Thanks Anatoly =D0=B2=D1=81, 15 =D0=B8=D1=8E=D0=BB. 2018 =D0=B3. =D0=B2 17:30, Al Viro : > > On Sun, Jul 15, 2018 at 11:20:06PM +0900, OGAWA Hirofumi wrote: > > +static inline bool fat_valid_entry(struct msdos_sb_info *sbi, int entr= y) > > +{ > > + if (entry < FAT_START_ENT || sbi->max_cluster <=3D entry) > > + return false; > > + return true; > > +} > > Pet peeve: if (...) return false; return true; instead of return !....; > > In this case, > return entry >=3D FAT_START_ENT && entry < sb->max_cluster;