lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250308080549.14464-1-rwchen404@gmail.com>
Date: Sat,  8 Mar 2025 16:05:49 +0800
From: Ruiwu Chen <rwchen404@...il.com>
To: mcgrof@...nel.org
Cc: corbet@....net,
	joel.granados@...nel.org,
	keescook@...omium.org,
	linux-doc@...r.kernel.org,
	linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	rwchen404@...il.com,
	viro@...iv.linux.org.uk,
	zachwade.k@...il.com
Subject: Re: [PATCH v2] drop_caches: re-enable message after disabling

>> When 'echo 4 > /proc/sys/vm/drop_caches' the message is disabled,
>> but there is no interface to enable the message, only by restarting
>> the way, so add the 'echo 0 > /proc/sys/vm/drop_caches' way to
>> enabled the message again.
>> 
>> Signed-off-by: Ruiwu Chen <rwchen404@...il.com>
>
> You are overcomplicating things, if you just want to re-enable messages
> you can just use:
>
> -		stfu |= sysctl_drop_caches & 4;
> +		stfu = sysctl_drop_caches & 4;
>
> The bool is there as 4 is intended as a bit flag, you can can figure
> out what values you want and just append 4 to it to get the expected
> result.
>
>  Luis

Is that what you mean ?

-               stfu |= sysctl_drop_caches & 4;
+               stfu ^= sysctl_drop_caches & 4;

'echo 4 > /sys/kernel/vm/drop_caches' can disable or open messages,
This is what I originally thought, but there is uncertainty that when different operators execute the command,
It is not possible to determine whether this time is enabled or turned on unless you operate it twice.

Ruiwu

>
>> ---
>> v2: - updated Documentation/ to note this new API.
>>     - renamed the variable.
>>     - rebase this on top of sysctl-next [1].
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/log/?h=sysctl-next
>> 
>>  Documentation/admin-guide/sysctl/vm.rst | 11 ++++++++++-
>>  fs/drop_caches.c                        | 11 +++++++----
>>  2 files changed, 17 insertions(+), 5 deletions(-)
>> 
>> diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
>> index f48eaa98d22d..ef73d36e8b84 100644
>> --- a/Documentation/admin-guide/sysctl/vm.rst
>> +++ b/Documentation/admin-guide/sysctl/vm.rst
>> @@ -266,7 +266,16 @@ used::
>>  	cat (1234): drop_caches: 3
>>  
>>  These are informational only.  They do not mean that anything is wrong
>> -with your system.  To disable them, echo 4 (bit 2) into drop_caches.
>> +with your system.
>> +
>> +To disable informational::
>> +
>> +	echo 4 > /proc/sys/vm/drop_caches
>> +
>> +To enable informational::
>> +
>> +	echo 0 > /proc/sys/vm/drop_caches
>> +
>>  
>>  enable_soft_offline
>>  ===================
>> diff --git a/fs/drop_caches.c b/fs/drop_caches.c
>> index 019a8b4eaaf9..a49af7023886 100644
>> --- a/fs/drop_caches.c
>> +++ b/fs/drop_caches.c
>> @@ -57,7 +57,7 @@ static int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
>>  	if (ret)
>>  		return ret;
>>  	if (write) {
>> -		static int stfu;
>> +		static bool silent;
>>  
>>  		if (sysctl_drop_caches & 1) {
>>  			lru_add_drain_all();
>> @@ -68,12 +68,15 @@ static int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
>>  			drop_slab();
>>  			count_vm_event(DROP_SLAB);
>>  		}
>> -		if (!stfu) {
>> +		if (!silent) {
>>  			pr_info("%s (%d): drop_caches: %d\n",
>>  				current->comm, task_pid_nr(current),
>>  				sysctl_drop_caches);
>>  		}
>> -		stfu |= sysctl_drop_caches & 4;
>> +		if (sysctl_drop_caches == 0)
>> +			silent = true;
>> +		else if (sysctl_drop_caches == 4)
>> +			silent = false;
>>  	}
>>  	return 0;
>>  }
>> @@ -85,7 +88,7 @@ static const struct ctl_table drop_caches_table[] = {
>>  		.maxlen		= sizeof(int),
>>  		.mode		= 0200,
>>  		.proc_handler	= drop_caches_sysctl_handler,
>> -		.extra1		= SYSCTL_ONE,
>> +		.extra1		= SYSCTL_ZERO,
>>  		.extra2		= SYSCTL_FOUR,
>>  	},
>>  };
>> -- 
>> 2.27.0
>> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ