All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	bugs+kernel.org@dtnr.ch, David Howells <dhowells@redhat.com>,
	Al Viro <viro@zeniv.linux.org.uk>
Cc: bugzilla-daemon@bugzilla.kernel.org, linux-mm@kvack.org
Subject: Re: [Bug 213785] New: hugetlbfs scrambles mode when sticky bit is set
Date: Tue, 20 Jul 2021 21:38:48 -0700	[thread overview]
Message-ID: <4a02aa78-c600-f2f4-c7d3-d79164c2c8a1@oracle.com> (raw)
In-Reply-To: <20210720150704.59f78224be810a0cf9dd5f39@linux-foundation.org>

Add David, Al

On 7/20/21 3:07 PM, Andrew Morton wrote:
>> https://bugzilla.kernel.org/show_bug.cgi?id=213785
>>
>>            Summary: hugetlbfs scrambles mode when sticky bit is set
>>            Product: Memory Management
>>            Version: 2.5
>>     Kernel Version: >4.19 (certainly >= 5.4)
>>         Regression: Yes
>>
>> I noticed the following strange behaviour with hugetlbfs mounts for kernel
>> versions something north of 4.19, but certainly since 5.4:
>>
>> when the mode= option of the mount has the sticky bit set, the mode of the
>> mount point gets scrambled.
>>
>> To test the following command line can be used:
>> mkdir -p /tmp/tlbtest && mount -t hugetlbfs -o mode=.... none /tmp/tlbtest &&
>> stat -c 'mode: %04a' /tmp/tlbtest
>>
>> For kernel versions <= 4.19 or if the first byte of mode is 0, stat outputs
>> what was set using "-o mode".
>>
>> But on newer kernel versions if the first byte of mode is 1 the output of stat
>> is as follows (input -> output):
>> 1700 -> 1244
>> 1750 -> 1326
>> 1770 -> 1352
>> 1775 -> 1357
>> 1777 -> 1361
>>
>> The behaviour is reproducible across different kernel versions and
>> architectures (5.4.47-amd64, 5.9.8-amd64, 5.10.40-ppc64el, 5.12.15-amd64).

I took a quick look and believe a change in behavior was caused by
commit 32021982a324 "Convert the hugetlbfs to use the fs_context
during mount".

Prior to the commit, code processing the mode option used
match_octal() to convert the command line string to a numeric value.
Since match_octal expects a string representing an octal value, it does
not require a leading '0'.  As a result, prior to this commit the
argument 'mode=1700' would result in a mode value of 01700.  After the
commit one must precede octal values with 0.  So, mode=1700 would result
in a mode value of 03244 (& 01777U) = 1244.

If my analysis is correct, I am not sure how to proceed.  IMO, the
current behavior is 'more correct'.  However, until v5.1 a preceeding 0
was not required when specifying mode for hugetlbfs.  So, this was
certainly a change in behavior.  Suggestions?  
-- 
Mike Kravetz


  reply	other threads:[~2021-07-21  4:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-213785-27@https.bugzilla.kernel.org/>
2021-07-20 22:07 ` [Bug 213785] New: hugetlbfs scrambles mode when sticky bit is set Andrew Morton
2021-07-21  4:38   ` Mike Kravetz [this message]
2021-07-21  7:59     ` [Bug 213785] New: hugetlbfs: interprets mode as decimal (was: hugetlbfs scrambles mode when sticky bit is set) Dennis Camera
2021-07-21 11:57     ` [Bug 213785] New: hugetlbfs scrambles mode when sticky bit is set Matthew Wilcox
2021-07-21 17:48       ` Mike Kravetz

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=4a02aa78-c600-f2f4-c7d3-d79164c2c8a1@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bugs+kernel.org@dtnr.ch \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.