* + memory-hotplug-fix-store_mem_state-return-value.patch added to -mm tree
@ 2016-09-01 20:37 akpm
0 siblings, 0 replies; 2+ messages in thread
From: akpm @ 2016-09-01 20:37 UTC (permalink / raw)
To: arbab, abanman, baiyaowei, dan.j.williams, david.vrabel, gregkh,
iamjoonsoo.kim, qiuxishi, rientjes, sjenning, slaoub, vbabka,
vkuznets, mm-commits
The patch titled
Subject: memory-hotplug: fix store_mem_state() return value
has been added to the -mm tree. Its filename is
memory-hotplug-fix-store_mem_state-return-value.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/memory-hotplug-fix-store_mem_state-return-value.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/memory-hotplug-fix-store_mem_state-return-value.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Reza Arbab <arbab@linux.vnet.ibm.com>
Subject: memory-hotplug: fix store_mem_state() return value
If store_mem_state() is called to online memory which is already online,
it will return 1, the value it got from device_online().
This is wrong because store_mem_state() is a device_attribute .store
function. Thus a non-negative return value represents input bytes read.
Set the return value to -EINVAL in this case.
Link: http://lkml.kernel.org/r/1472743777-24266-1-git-send-email-arbab@linux.vnet.ibm.com
Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Chen Yucong <slaoub@gmail.com>
Cc: Andrew Banman <abanman@sgi.com>
Cc: Seth Jennings <sjenning@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/base/memory.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff -puN drivers/base/memory.c~memory-hotplug-fix-store_mem_state-return-value drivers/base/memory.c
--- a/drivers/base/memory.c~memory-hotplug-fix-store_mem_state-return-value
+++ a/drivers/base/memory.c
@@ -361,8 +361,11 @@ store_mem_state(struct device *dev,
err:
unlock_device_hotplug();
- if (ret)
+ if (ret < 0)
return ret;
+ if (ret)
+ return -EINVAL;
+
return count;
}
_
Patches currently in -mm which might be from arbab@linux.vnet.ibm.com are
memory-hotplug-fix-store_mem_state-return-value.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
* + memory-hotplug-fix-store_mem_state-return-value.patch added to -mm tree
@ 2016-08-31 20:26 akpm
0 siblings, 0 replies; 2+ messages in thread
From: akpm @ 2016-08-31 20:26 UTC (permalink / raw)
To: arbab, abanman, baiyaowei, dan.j.williams, david.vrabel, gregkh,
iamjoonsoo.kim, qiuxishi, rientjes, slaoub, vbabka, vkuznets,
mm-commits
The patch titled
Subject: memory-hotplug: fix store_mem_state() return value
has been added to the -mm tree. Its filename is
memory-hotplug-fix-store_mem_state-return-value.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/memory-hotplug-fix-store_mem_state-return-value.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/memory-hotplug-fix-store_mem_state-return-value.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Reza Arbab <arbab@linux.vnet.ibm.com>
Subject: memory-hotplug: fix store_mem_state() return value
Attempting to online memory which is already online will cause this:
1. store_mem_state() called with buf="online"
2. device_online() returns 1 because device is already online
3. store_mem_state() returns 1
4. calling code interprets this as 1-byte buffer read
5. store_mem_state() called again with buf="nline"
6. store_mem_state() returns -EINVAL
Example:
$ cat /sys/devices/system/memory/memory0/state
online
$ echo online > /sys/devices/system/memory/memory0/state
-bash: echo: write error: Invalid argument
Fix the return value of store_mem_state() so this doesn't happen.
Link: http://lkml.kernel.org/r/1472658241-32748-1-git-send-email-arbab@linux.vnet.ibm.com
Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Chen Yucong <slaoub@gmail.com>
Cc: Andrew Banman <abanman@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/base/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -puN drivers/base/memory.c~memory-hotplug-fix-store_mem_state-return-value drivers/base/memory.c
--- a/drivers/base/memory.c~memory-hotplug-fix-store_mem_state-return-value
+++ a/drivers/base/memory.c
@@ -361,7 +361,7 @@ store_mem_state(struct device *dev,
err:
unlock_device_hotplug();
- if (ret)
+ if (ret < 0)
return ret;
return count;
}
_
Patches currently in -mm which might be from arbab@linux.vnet.ibm.com are
memory-hotplug-fix-store_mem_state-return-value.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-01 20:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01 20:37 + memory-hotplug-fix-store_mem_state-return-value.patch added to -mm tree akpm
-- strict thread matches above, loose matches on Subject: below --
2016-08-31 20:26 akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).