public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dmitry Dmitriev <dimondmm@yandex.ru>
Cc: hirofumi@mail.parknet.co.jp, linux-kernel@vger.kernel.org
Subject: Re: PROBLEM: Corrupt inode flags when remove ATTR_SYS flag on fat file system mounted with “sys_immutable” mount option.
Date: Mon, 6 Jun 2011 16:51:06 -0700	[thread overview]
Message-ID: <20110606165106.b0afea46.akpm@linux-foundation.org> (raw)
In-Reply-To: <31181306830445@web159.yandex.ru>

On Tue, 31 May 2011 12:27:24 +0400
Dmitry Dmitriev <dimondmm@yandex.ru> wrote:

> Hello,
> 
> Inode flags are corrupted when removing ATTR_SYS flag by FAT_IOCTL_SET_ATTRIBUTES ioctl on fat file system mounted with ___sys_immutable___ mount option. In this case S_IMMUTABLE flag must be removed from inode flags, but actually removed all other flags except S_IMMUTABLE. This problem observed on 2.6.34 kernel, but it seems still exist( after examine of 2.6.39 kernel source code ).
> 
> The problem in fat_ioctl_set_attributes function( fs/fat/file.c ). This function contains following code(2.6.39 kernel):
>  101        if (sbi->options.sys_immutable) {
>  102                if (attr & ATTR_SYS)
>  103                        inode->i_flags |= S_IMMUTABLE;
>  104                else
>  105                        inode->i_flags &= S_IMMUTABLE;
>  106        }
> 
> Instead of removing S_IMMUTABLE flag from inode flags on line 105 function removes all other flags from inode flags. I think that line 105 must be following:
> 
>  105                        inode->i_flags &= ~S_IMMUTABLE;
> 

Thank, I queued this:


From: Andrew Morton <akpm@linux-foundation.org>

Inode flags are corrupted when removing ATTR_SYS flag by
FAT_IOCTL_SET_ATTRIBUTES ioctl on fat file system mounted with
`sys_immutable' mount option.

Fix fat-fingered bitop from 21bea495943f9532 ("fat: split
fat_generic_ioctl").

Reported-by: Dmitry Dmitriev <dimondmm@yandex.ru>
Cc: Cristoph Hellwig <hch@lst.de>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/fat/file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN fs/fat/file.c~fs-fat-filec-fix-clearing-of-s_immutable fs/fat/file.c
--- a/fs/fat/file.c~fs-fat-filec-fix-clearing-of-s_immutable
+++ a/fs/fat/file.c
@@ -102,7 +102,7 @@ static int fat_ioctl_set_attributes(stru
 		if (attr & ATTR_SYS)
 			inode->i_flags |= S_IMMUTABLE;
 		else
-			inode->i_flags &= S_IMMUTABLE;
+			inode->i_flags &= ~S_IMMUTABLE;
 	}
 
 	fat_save_attrs(inode, attr);
_


      reply	other threads:[~2011-06-06 23:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31  8:27 PROBLEM: Corrupt inode flags when remove ATTR_SYS flag on fat file system mounted with “sys_immutable” mount option Dmitry Dmitriev
2011-06-06 23:51 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110606165106.b0afea46.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dimondmm@yandex.ru \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox