Kernel TLS
Bjørn Mork
bjorn at mork.no
Sat Nov 30 03:13:35 EST 2019
"Valdis Klētnieks" <valdis.kletnieks at vt.edu> writes:
> On Fri, 29 Nov 2019 23:37:35 -0500, Jeffrey Walton said:
>
> repl: bad addresses:
> Valentin VidiD <vvidic at valentin-vidic.from.hr> -- no mailbox in address, only a phrase (Valentin VidiD)
>> On Fri, Nov 29, 2019 at 3:04 PM Jeffrey Walton <noloader at gmail.com> wrote:
>> > ...
>> > So now I am at:
>> >
>> > $ gcc -Wall -g2 -O1 ktls.c -o ktls
>> > $ ./ktls
>> > setsockopt failed, 524, Unknown error 524
>>
>> Now open in the Fedora bug tracker:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1778348
>
> Looks like the 'unknown error' issue is a glibc strerror() problem. On the
> kernel side, git blame says:
>
> [/usr/src/linux-next] git blame include/linux/errno.h | grep -C 5 524
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 22)
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 23) /* Defined for the NFSv3 protocol */
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 24) #define EBADHANDLE 521 /* Illegal NFS file handle */
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 25) #define ENOTSYNC 522 /* Update synchronization mismatch */
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 26) #define EBADCOOKIE 523 /* Cookie is stale */
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 27) #define ENOTSUPP 524 /* Operation is not supported */
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 28) #define ETOOSMALL 525 /* Buffer or request is too small */
> ^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 29) #define ESERVERFAULT 526 /* An untranslatable error occurred */
>
> So I'm mystified why glibc's strerror() doesn't handle it.
> Though I think Alexander is correct on why the kernel returns ENOTSUPP.
include/linux/errno.h is kernel internal only. The UAPI header is
uapi/linux/errno.h, which is an alias for uapi/asm/errno.h. There is no
524 in include/uapi/asm-generic/errno.h or
include/uapi/asm-generic/errno-base.h
The codes in include/linux/errno.h should be translated for userspace.
This does look like a bug in the kernel tls code.
Bjørn
More information about the Kernelnewbies
mailing list