memcpy安全吗? [英] Is memcpy secure?

查看:355
本文介绍了memcpy安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在努力确保我的数据不会出现在外面的任何地方

我的流程未加密。我担心如果我使用memcpy,复制后的字节

会在我完成之后的某个内存中结束。

我是偏执狂吗?

谢谢,


奥尔加

Hi,

I am trying to make sure that my data doesn''t show up anywhere outside
my process unencrypted. I am concerned that if I use memcpy, the bytes
copied will end up in some memory somewhere after I am done with it.
Am I being paranoid?
Thanks,

Olga

推荐答案

文章< 50 **** **********************@posting.google.com>,
sa ***** @ yahoo.com (Olga Sayenko)写道:
In article <50**************************@posting.google.com >,
sa*****@yahoo.com (Olga Sayenko) wrote:


我想确保我的数据不会出现在外面的任何地方
我的过程未加密。我担心如果我使用memcpy,那么复制的字节将在我完成之后的某个内存中结束。


它会在某个地方的内存中:你从哪里复制它,以及你把b $ b复制到的地方。

Am我是偏执狂?
Hi,

I am trying to make sure that my data doesn''t show up anywhere outside
my process unencrypted. I am concerned that if I use memcpy, the bytes
copied will end up in some memory somewhere after I am done with it.
It will be in memory somewhere: where you copied it from, and where you
copied it to :)
Am I being paranoid?




我会说你是偏执狂。 < OT>如果您使用的是受保护的内存
的系统,则memcpy不会在您的进程外复制。如果你在没有提供内存的系统上获得
,那么你无需做任何事情来保护你的数据来自其他应用程序。 memcpy的使用是

irrrelevant。< / OT>



I''d say you''re being paranoid. <OT>If you''re on a system with protected
memory, memcpy is not going to copy outside of your process. If you''re
on a system without proected memory, then there''s nothing you can do to
*hide* your data from other applications. The use of memcpy is
irrrelevant.</OT>


在文章< 50 ****** ********************@posting.google.com>,

Olga Sayenko< sa ***** @ yahoo。 COM>写道:

:我正在努力确保我的数据不会出现在任何地方外面

:我的流程未加密。我担心如果我使用memcpy,那么字节

:复制将在我完成之后的某个内存中结束。

:我是偏执狂吗? br />

取决于您的操作系统和架构。一般来说,如果memcpy效率不高,那么Linux类型的人们会认为这是一个错误。

但你可能会在一个不寻常的架构上效率

涉及向硬件dma单元发送页面大小的复制请求。

要记住的一件事是,除非你特别小心,否则

包含你的数据的页面可能会被换成磁盘,可能多次兑换


-

哦,要成为Blobel!
In article <50**************************@posting.google.com >,
Olga Sayenko <sa*****@yahoo.com> wrote:
:I am trying to make sure that my data doesn''t show up anywhere outside
:my process unencrypted. I am concerned that if I use memcpy, the bytes
:copied will end up in some memory somewhere after I am done with it.
:Am I being paranoid?

Depends on your OS and architecture. Generally speaking, the Linux-type
people consider it a bug if memcpy is not as efficient as possible,
but you could be on an unusual architecture on which efficiency
involved sending a page-sized copy request to a hardware dma unit.
One thing to keep in mind is that unless you take special care,
the page containing your data might get swapped out to disk, possibly
multiple times.
--
Oh, to be a Blobel!


在文章< clarkcox3-7CDEAB.21383810012004@localhost>,

Clark Cox< cl ******* @ mac。 COM>写道:

:我会说你是偏执狂。 < OT>如果您使用受保护的系统
:内存:memcpy不会在您的进程外复制。


开启 - 任何系统,memcpy都可能涉及通过拥有的
cpu和硬件寄存器移动字节。通过操作系统而不是任何一个进程的



调用约定通常指定特定寄存器可能被系统覆盖
调用,所以一个进入理论上的可能性,即系统调用进程后寄存器的值

A可能碰巧是由代表进程的工作设置的B.


-

哦,是的,非洲燕子可能,但不是欧洲燕子。

那个''我的观点。
In article <clarkcox3-7CDEAB.21383810012004@localhost>,
Clark Cox <cl*******@mac.com> wrote:
:I''d say you''re being paranoid. <OT>If you''re on a system with protected
:memory: memcpy is not going to copy outside of your process.

On -any- system, memcpy is likely to involve moving bytes through
cpu and hardware registers that are "owned" by the OS rather than
by any one process.

Calling conventions often specify that particular registers may be
overwritten by system calls, so one runs into the theoretical
possibility that the value of a register after a system call by process
A might happen to have been set by work on behalf of process B.

--
Oh, yeah, an African swallow maybe, but not a European swallow.
That''s my point.


这篇关于memcpy安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆