Files
linux_media/include/uapi/linux
Eric Biggers 92eb6c3060 crypto: af_alg - avoid undefined behavior accessing salg_name
Commit 3f69cc6076 ("crypto: af_alg - Allow arbitrarily long algorithm
names") made the kernel start accepting arbitrarily long algorithm names
in sockaddr_alg.  However, the actual length of the salg_name field
stayed at the original 64 bytes.

This is broken because the kernel can access indices >= 64 in salg_name,
which is undefined behavior -- even though the memory that is accessed
is still located within the sockaddr structure.  It would only be
defined behavior if the array were properly marked as arbitrary-length
(either by making it a flexible array, which is the recommended way
these days, or by making it an array of length 0 or 1).

We can't simply change salg_name into a flexible array, since that would
break source compatibility with userspace programs that embed
sockaddr_alg into another struct, or (more commonly) declare a
sockaddr_alg like 'struct sockaddr_alg sa = { .salg_name = "foo" };'.

One solution would be to change salg_name into a flexible array only
when '#ifdef __KERNEL__'.  However, that would keep userspace without an
easy way to actually use the longer algorithm names.

Instead, add a new structure 'sockaddr_alg_new' that has the flexible
array field, and expose it to both userspace and the kernel.
Make the kernel use it correctly in alg_bind().

This addresses the syzbot report
"UBSAN: array-index-out-of-bounds in alg_bind"
(https://syzkaller.appspot.com/bug?extid=92ead4eb8e26a26d465e).

Reported-by: syzbot+92ead4eb8e26a26d465e@syzkaller.appspotmail.com
Fixes: 3f69cc6076 ("crypto: af_alg - Allow arbitrarily long algorithm names")
Cc: <stable@vger.kernel.org> # v4.12+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-11-06 14:29:11 +11:00
..
2020-08-22 10:53:12 +01:00
2020-05-28 11:22:14 +02:00
2019-12-18 18:07:31 +01:00
2020-08-12 10:58:00 -07:00
2020-10-09 12:47:02 -06:00
2019-10-09 22:31:14 -04:00
2019-09-25 17:51:39 -07:00
2020-10-09 12:06:52 -07:00
2020-10-01 15:03:40 -04:00
2020-04-27 16:29:41 +05:30
2020-07-19 19:20:22 -07:00
2020-06-24 21:34:11 +02:00
2020-05-14 16:44:25 +02:00
2020-05-28 22:09:47 -04:00
2020-08-27 08:01:47 -07:00
2019-12-11 15:31:52 +01:00
2020-07-19 19:20:22 -07:00
2020-07-24 17:12:41 -07:00
2020-08-05 19:02:07 +05:30
2020-07-13 15:32:56 -07:00
2020-04-20 12:43:24 -07:00
2020-07-24 17:12:41 -07:00
2020-08-27 07:55:59 -07:00
2019-09-08 15:37:04 +02:00
2020-05-21 08:20:35 -06:00
2020-03-29 22:30:57 -07:00
2020-08-18 15:44:44 +02:00
2020-08-27 16:06:47 -04:00
2020-07-09 12:38:41 -07:00
2020-01-18 09:19:18 -05:00
2020-10-19 19:39:22 +02:00
2019-10-02 20:32:27 -06:00
2020-05-21 17:04:07 -07:00
2020-03-29 22:30:57 -07:00
2019-12-18 18:07:31 +01:00
2019-12-09 09:59:07 +01:00
2020-03-29 23:29:08 +02:00
2020-08-18 14:14:25 +02:00
2020-07-13 15:32:56 -07:00
2020-06-24 07:51:01 +02:00