2021-08-03 11:00:30

by Thomas Huth

[permalink] [raw]
Subject: [PATCH 0/2] Fix /proc/sys/fs/nfs/nsm_use_hostnames on big endian machines

There is an endianess problem with /proc/sys/fs/nfs/nsm_use_hostnames
(which can e.g. be seen on an s390x host) :

# modprobe lockd nsm_use_hostnames=1
# cat /proc/sys/fs/nfs/nsm_use_hostnames
16777216

The nsm_use_hostnames variable is declared as "bool" which is required
for the correct type for the module parameter. However, this does not
work correctly with the entry in the /proc filesystem since this
currently requires "int".

Jia He already provided patches for this problem a couple of years ago,
but apparently they felt through the cracks and never got merged. So
here's a rebased version to finally fix this issue.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1764075

Jia He (2):
sysctl: introduce new proc handler proc_dobool
lockd: change the proc_handler for nsm_use_hostnames

fs/lockd/svc.c | 2 +-
include/linux/sysctl.h | 2 ++
kernel/sysctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 1 deletion(-)

--
2.27.0



2021-08-03 11:00:30

by Thomas Huth

[permalink] [raw]
Subject: [PATCH 2/2] lockd: change the proc_handler for nsm_use_hostnames

From: Jia He <[email protected]>

nsm_use_hostnames is a module parameter and it will be exported to sysctl
procfs. This is to let user sometimes change it from userspace. But the
minimal unit for sysctl procfs read/write it sizeof(int).
In big endian system, the converting from/to bool to/from int will cause
error for proc items.

This patch use a new proc_handler proc_dobool to fix it.

Signed-off-by: Jia He <[email protected]>
Reviewed-by: Pan Xinhui <[email protected]>
[thuth: Fix typo in commit message]
Signed-off-by: Thomas Huth <[email protected]>
---
fs/lockd/svc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 2de048f80eb8..0ab9756ed235 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -584,7 +584,7 @@ static struct ctl_table nlm_sysctls[] = {
.data = &nsm_use_hostnames,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec,
+ .proc_handler = proc_dobool,
},
{
.procname = "nsm_local_state",
--
2.27.0


2021-08-03 14:09:20

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix /proc/sys/fs/nfs/nsm_use_hostnames on big endian machines

Looks good to me. Could Chuck take it with nfsd stuff if somebody could
ACK the sysctl part?

--b.

On Tue, Aug 03, 2021 at 12:59:35PM +0200, Thomas Huth wrote:
> There is an endianess problem with /proc/sys/fs/nfs/nsm_use_hostnames
> (which can e.g. be seen on an s390x host) :
>
> # modprobe lockd nsm_use_hostnames=1
> # cat /proc/sys/fs/nfs/nsm_use_hostnames
> 16777216
>
> The nsm_use_hostnames variable is declared as "bool" which is required
> for the correct type for the module parameter. However, this does not
> work correctly with the entry in the /proc filesystem since this
> currently requires "int".
>
> Jia He already provided patches for this problem a couple of years ago,
> but apparently they felt through the cracks and never got merged. So
> here's a rebased version to finally fix this issue.
>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1764075
>
> Jia He (2):
> sysctl: introduce new proc handler proc_dobool
> lockd: change the proc_handler for nsm_use_hostnames
>
> fs/lockd/svc.c | 2 +-
> include/linux/sysctl.h | 2 ++
> kernel/sysctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 45 insertions(+), 1 deletion(-)
>
> --
> 2.27.0

2021-08-03 14:24:38

by Chuck Lever

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix /proc/sys/fs/nfs/nsm_use_hostnames on big endian machines

Thanks for your review, Bruce. I'll watch for the additional Ack.

> On Aug 3, 2021, at 10:08 AM, J. Bruce Fields <[email protected]> wrote:
>
> Looks good to me. Could Chuck take it with nfsd stuff if somebody could
> ACK the sysctl part?
>
> --b.
>
> On Tue, Aug 03, 2021 at 12:59:35PM +0200, Thomas Huth wrote:
>> There is an endianess problem with /proc/sys/fs/nfs/nsm_use_hostnames
>> (which can e.g. be seen on an s390x host) :
>>
>> # modprobe lockd nsm_use_hostnames=1
>> # cat /proc/sys/fs/nfs/nsm_use_hostnames
>> 16777216
>>
>> The nsm_use_hostnames variable is declared as "bool" which is required
>> for the correct type for the module parameter. However, this does not
>> work correctly with the entry in the /proc filesystem since this
>> currently requires "int".
>>
>> Jia He already provided patches for this problem a couple of years ago,
>> but apparently they felt through the cracks and never got merged. So
>> here's a rebased version to finally fix this issue.
>>
>> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1764075
>>
>> Jia He (2):
>> sysctl: introduce new proc handler proc_dobool
>> lockd: change the proc_handler for nsm_use_hostnames
>>
>> fs/lockd/svc.c | 2 +-
>> include/linux/sysctl.h | 2 ++
>> kernel/sysctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 45 insertions(+), 1 deletion(-)
>>
>> --
>> 2.27.0

--
Chuck Lever




2021-08-04 03:23:43

by Jia He

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix /proc/sys/fs/nfs/nsm_use_hostnames on big endian machines


On 2021/8/3 18:59, Thomas Huth wrote:
> There is an endianess problem with /proc/sys/fs/nfs/nsm_use_hostnames
> (which can e.g. be seen on an s390x host) :
>
> # modprobe lockd nsm_use_hostnames=1
> # cat /proc/sys/fs/nfs/nsm_use_hostnames
> 16777216
>
> The nsm_use_hostnames variable is declared as "bool" which is required
> for the correct type for the module parameter. However, this does not
> work correctly with the entry in the /proc filesystem since this
> currently requires "int".
>
> Jia He already provided patches for this problem a couple of years ago,
> but apparently they felt through the cracks and never got merged. So
> here's a rebased version to finally fix this issue.
>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1764075
>
> Jia He (2):
> sysctl: introduce new proc handler proc_dobool
> lockd: change the proc_handler for nsm_use_hostnames

Thanks for picking them up ;-)

---
Cheers,
Justin (Jia He)


2021-08-09 17:52:32

by Chuck Lever

[permalink] [raw]
Subject: Re: [PATCH 0/2] Fix /proc/sys/fs/nfs/nsm_use_hostnames on big endian machines



> On Aug 3, 2021, at 6:59 AM, Thomas Huth <[email protected]> wrote:
>
> There is an endianess problem with /proc/sys/fs/nfs/nsm_use_hostnames
> (which can e.g. be seen on an s390x host) :
>
> # modprobe lockd nsm_use_hostnames=1
> # cat /proc/sys/fs/nfs/nsm_use_hostnames
> 16777216
>
> The nsm_use_hostnames variable is declared as "bool" which is required
> for the correct type for the module parameter. However, this does not
> work correctly with the entry in the /proc filesystem since this
> currently requires "int".
>
> Jia He already provided patches for this problem a couple of years ago,
> but apparently they felt through the cracks and never got merged. So
> here's a rebased version to finally fix this issue.
>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1764075
>
> Jia He (2):
> sysctl: introduce new proc handler proc_dobool
> lockd: change the proc_handler for nsm_use_hostnames
>
> fs/lockd/svc.c | 2 +-
> include/linux/sysctl.h | 2 ++
> kernel/sysctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 45 insertions(+), 1 deletion(-)
>
> --
> 2.27.0

To get these patches in front of our zero-day apparatus,
I've applied them to the for-next topic branch here:

https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=for-next

However I haven't seen an Ack for the kernel/sysctl.c change yet.


--
Chuck Lever