<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/crypto, branch linux-2.6.26.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-2.6.26.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-2.6.26.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2008-08-20T18:05:15Z</updated>
<entry>
<title>crypto: padlock - fix VIA PadLock instruction usage with irq_ts_save/restore()</title>
<updated>2008-08-20T18:05:15Z</updated>
<author>
<name>Suresh Siddha</name>
<email>suresh.b.siddha@intel.com</email>
</author>
<published>2008-08-15T00:13:20Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=faf996d6cdc3a8e6205ae5226f667aa7d1f5f6c2'/>
<id>urn:sha1:faf996d6cdc3a8e6205ae5226f667aa7d1f5f6c2</id>
<content type='text'>
crypto: padlock - fix VIA PadLock instruction usage with irq_ts_save/restore()

[ Upstream commit: e49140120c88eb99db1a9172d9ac224c0f2bbdd2 ]

Wolfgang Walter reported this oops on his via C3 using padlock for
AES-encryption:

##################################################################

BUG: unable to handle kernel NULL pointer dereference at 000001f0
IP: [&lt;c01028c5&gt;] __switch_to+0x30/0x117
*pde = 00000000
Oops: 0002 [#1] PREEMPT
Modules linked in:

Pid: 2071, comm: sleep Not tainted (2.6.26 #11)
EIP: 0060:[&lt;c01028c5&gt;] EFLAGS: 00010002 CPU: 0
EIP is at __switch_to+0x30/0x117
EAX: 00000000 EBX: c0493300 ECX: dc48dd00 EDX: c0493300
ESI: dc48dd00 EDI: c0493530 EBP: c04cff8c ESP: c04cff7c
DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 0068
Process sleep (pid: 2071, ti=c04ce000 task=dc48dd00 task.ti=d2fe6000)
Stack: dc48df30 c0493300 00000000 00000000 d2fe7f44 c03b5b43 c04cffc8 00000046
   c0131856 0000005a dc472d3c c0493300 c0493470 d983ae00 00002696 00000000
   c0239f54 00000000 c04c4000 c04cffd8 c01025fe c04f3740 00049800 c04cffe0
Call Trace:
[&lt;c03b5b43&gt;] ? schedule+0x285/0x2ff
[&lt;c0131856&gt;] ? pm_qos_requirement+0x3c/0x53
[&lt;c0239f54&gt;] ? acpi_processor_idle+0x0/0x434
[&lt;c01025fe&gt;] ? cpu_idle+0x73/0x7f
[&lt;c03a4dcd&gt;] ? rest_init+0x61/0x63
=======================

Wolfgang also found out that adding kernel_fpu_begin() and kernel_fpu_end()
around the padlock instructions fix the oops.

Suresh wrote:

These padlock instructions though don't use/touch SSE registers, but it behaves
similar to other SSE instructions. For example, it might cause DNA faults
when cr0.ts is set. While this is a spurious DNA trap, it might cause
oops with the recent fpu code changes.

This is the code sequence  that is probably causing this problem:

a) new app is getting exec'd and it is somewhere in between
start_thread() and flush_old_exec() in the load_xyz_binary()

b) At pont "a", task's fpu state (like TS_USEDFPU, used_math() etc) is
cleared.

c) Now we get an interrupt/softirq which starts using these encrypt/decrypt
routines in the network stack. This generates a math fault (as
cr0.ts is '1') which sets TS_USEDFPU and restores the math that is
in the task's xstate.

d) Return to exec code path, which does start_thread() which does
free_thread_xstate() and sets xstate pointer to NULL while
the TS_USEDFPU is still set.

e) At the next context switch from the new exec'd task to another task,
we have a scenarios where TS_USEDFPU is set but xstate pointer is null.
This can cause an oops during unlazy_fpu() in __switch_to()

Now:

1) This should happen with or with out pre-emption. Viro also encountered
similar problem with out CONFIG_PREEMPT.

2) kernel_fpu_begin() and kernel_fpu_end() will fix this problem, because
kernel_fpu_begin() will manually do a clts() and won't run in to the
situation of setting TS_USEDFPU in step "c" above.

3) This was working before the fpu changes, because its a spurious
math fault  which doesn't corrupt any fpu/sse registers and the task's
math state was always in an allocated state.

With out the recent lazy fpu allocation changes, while we don't see oops,
there is a possible race still present in older kernels(for example,
while kernel is using kernel_fpu_begin() in some optimized clear/copy
page and an interrupt/softirq happens which uses these padlock
instructions generating DNA fault).

This is the failing scenario that existed even before the lazy fpu allocation
changes:

0. CPU's TS flag is set

1. kernel using FPU in some optimized copy  routine and while doing
kernel_fpu_begin() takes an interrupt just before doing clts()

2. Takes an interrupt and ipsec uses padlock instruction. And we
take a DNA fault as TS flag is still set.

3. We handle the DNA fault and set TS_USEDFPU and clear cr0.ts

4. We complete the padlock routine

5. Go back to step-1, which resumes clts() in kernel_fpu_begin(), finishes
the optimized copy routine and does kernel_fpu_end(). At this point,
we have cr0.ts again set to '1' but the task's TS_USEFPU is stilll
set and not cleared.

6. Now kernel resumes its user operation. And at the next context
switch, kernel sees it has do a FP save as TS_USEDFPU is still set
and then will do a unlazy_fpu() in __switch_to(). unlazy_fpu()
will take a DNA fault, as cr0.ts is '1' and now, because we are
in __switch_to(), math_state_restore() will get confused and will
restore the next task's FP state and will save it in prev tasks's FP state.
Remember, in __switch_to() we are already on the stack of the next task
but take a DNA fault for the prev task.

This causes the fpu leakage.

Fix the padlock instruction usage by calling them inside the
context of new routines irq_ts_save/restore(), which clear/restore cr0.ts
manually in the interrupt context. This will not generate spurious DNA
in the  context of the interrupt which will fix the oops encountered and
the possible FPU leakage issue.

Reported-and-bisected-by: Wolfgang Walter &lt;wolfgang.walter@stwm.de&gt;
Signed-off-by: Suresh Siddha &lt;suresh.b.siddha@intel.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>[CRYPTO] padlock-aes: Use generic setkey function</title>
<updated>2008-04-21T02:19:34Z</updated>
<author>
<name>Sebastian Siewior</name>
<email>sebastian@breakpoint.cc</email>
</author>
<published>2008-04-01T13:24:50Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7dc748e4e720c1a98185363096ad7582e9113092'/>
<id>urn:sha1:7dc748e4e720c1a98185363096ad7582e9113092</id>
<content type='text'>
The Padlock AES setkey routine is the same as exported by the generic
implementation. So we could use it.

Signed-off-by: Sebastian Siewior &lt;sebastian@breakpoint.cc&gt;
Cc: Michal Ludvig &lt;michal@logix.cz&gt;
Tested-by: Stefan Hellermann &lt;stefan@the2masters.de&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>[CRYPTO] sha384: Hardware acceleration for s390</title>
<updated>2008-04-21T02:19:21Z</updated>
<author>
<name>Jan Glauber</name>
<email>jang@linux.vnet.ibm.com</email>
</author>
<published>2008-03-06T11:53:50Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=4e2c6d7f4d8f466f4420e10dda7126537de09c94'/>
<id>urn:sha1:4e2c6d7f4d8f466f4420e10dda7126537de09c94</id>
<content type='text'>
Exploit the System z10 hardware acceleration for SHA384.

Signed-off-by: Jan Glauber &lt;jang@linux.vnet.ibm.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>[CRYPTO] sha512: Hardware acceleration for s390</title>
<updated>2008-04-21T02:19:21Z</updated>
<author>
<name>Jan Glauber</name>
<email>jang@linux.vnet.ibm.com</email>
</author>
<published>2008-03-06T11:52:00Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=291dc7c0996b09a7c58b2cf6e9cc3495123a607e'/>
<id>urn:sha1:291dc7c0996b09a7c58b2cf6e9cc3495123a607e</id>
<content type='text'>
Exploit the System z10 hardware acceleration for SHA512.

Signed-off-by: Jan Glauber &lt;jang@linux.vnet.ibm.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>[S390] zcrypt: add support for large random numbers</title>
<updated>2008-04-17T05:47:02Z</updated>
<author>
<name>Ralph Wuerthner</name>
<email>rwuerthn@de.ibm.com</email>
</author>
<published>2008-04-17T05:46:15Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2f7c8bd6dc6540aa3275c0ad9f657401985c00e9'/>
<id>urn:sha1:2f7c8bd6dc6540aa3275c0ad9f657401985c00e9</id>
<content type='text'>
This patch allows user space applications to access large amounts of
truly random data. The random data source is the build-in hardware
random number generator on the CEX2C cards.

Signed-off-by: Ralph Wuerthner &lt;rwuerthn@de.ibm.com&gt;
Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Signed-off-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
</content>
</entry>
<entry>
<title>drivers/crypto/hifn_795x.c trivial endianness annotations</title>
<updated>2008-03-30T21:20:24Z</updated>
<author>
<name>Al Viro</name>
<email>viro@ftp.linux.org.uk</email>
</author>
<published>2008-03-29T03:09:58Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e68970cdd90e3d27297a404a050bad520f9a49cd'/>
<id>urn:sha1:e68970cdd90e3d27297a404a050bad520f9a49cd</id>
<content type='text'>
NB: remaining endianness warnings in the file are, AFAICS, real bugs.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>[HIFN]: Fix invalid config ifdefs for RNG support</title>
<updated>2008-02-15T11:15:05Z</updated>
<author>
<name>Patrick McHardy</name>
<email>kaber@trash.net</email>
</author>
<published>2008-02-15T11:15:05Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f881d8290c59beb472062142aab54af2554d0d9c'/>
<id>urn:sha1:f881d8290c59beb472062142aab54af2554d0d9c</id>
<content type='text'>
    
The CRYPTO_DEV_HIFN_795X_RNG ifdefs are missing the CONFIG_ prefix.
    
Signed-off-by: Patrick McHardy &lt;kaber@trash.net&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>[S390] crypto: move s390 Kconfig options.</title>
<updated>2008-01-26T13:11:17Z</updated>
<author>
<name>Jan Glauber</name>
<email>jan.glauber@de.ibm.com</email>
</author>
<published>2008-01-26T13:11:07Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=3f5615e012b4593943bbc2a6c3ce150bb33e1966'/>
<id>urn:sha1:3f5615e012b4593943bbc2a6c3ce150bb33e1966</id>
<content type='text'>
Move s390 crypto Kconfig options to drivers/crypto/Kconfig to have all
hardware crypto devices in one place.

This also makes messing up the kernel source tree easier for some people.

Signed-off-by: Jan Glauber &lt;jan.glauber@de.ibm.com&gt;
Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
</content>
</entry>
<entry>
<title>[CRYPTO] hifn795x: Disallow built-in hifn795x when HW_RANDOM is m</title>
<updated>2008-01-25T22:48:44Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2008-01-25T22:48:44Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=946fef4e14ebc2f14ab05f54789843621fe87f60'/>
<id>urn:sha1:946fef4e14ebc2f14ab05f54789843621fe87f60</id>
<content type='text'>
Currently it is possible to select HW_RANDOM as a module and have
hifn795x built-in.  This causes a build problem because hifn795x
will then call hwrng_register which isn't built-in.

This patch introduces a new config option to control the hifn795x
RNG which lets us avoid this problem.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6</title>
<updated>2008-01-25T16:38:25Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2008-01-25T16:38:25Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=eba0e319c12fb098d66316a8eafbaaa9174a07c3'/>
<id>urn:sha1:eba0e319c12fb098d66316a8eafbaaa9174a07c3</id>
<content type='text'>
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (125 commits)
  [CRYPTO] twofish: Merge common glue code
  [CRYPTO] hifn_795x: Fixup container_of() usage
  [CRYPTO] cast6: inline bloat--
  [CRYPTO] api: Set default CRYPTO_MINALIGN to unsigned long long
  [CRYPTO] tcrypt: Make xcbc available as a standalone test
  [CRYPTO] xcbc: Remove bogus hash/cipher test
  [CRYPTO] xcbc: Fix algorithm leak when block size check fails
  [CRYPTO] tcrypt: Zero axbuf in the right function
  [CRYPTO] padlock: Only reset the key once for each CBC and ECB operation
  [CRYPTO] api: Include sched.h for cond_resched in scatterwalk.h
  [CRYPTO] salsa20-asm: Remove unnecessary dependency on CRYPTO_SALSA20
  [CRYPTO] tcrypt: Add select of AEAD
  [CRYPTO] salsa20: Add x86-64 assembly version
  [CRYPTO] salsa20_i586: Salsa20 stream cipher algorithm (i586 version)
  [CRYPTO] gcm: Introduce rfc4106
  [CRYPTO] api: Show async type
  [CRYPTO] chainiv: Avoid lock spinning where possible
  [CRYPTO] seqiv: Add select AEAD in Kconfig
  [CRYPTO] scatterwalk: Handle zero nbytes in scatterwalk_map_and_copy
  [CRYPTO] null: Allow setkey on digest_null 
  ...
</content>
</entry>
</feed>
