4

In the book The Linux Programming Interface, it says

The kernel imposes limits on the number of dereferences to handle the possibility of circular chains of symbolic links.

Where can I find this limit?

extremeaxe5
  • 1,183
  • I can think of 2 very different ways to answer this question... either with the API to find the limit within a program, or with a pointer to the kernel code that enforces the limit. –  Aug 12 '18 at 23:24
  • @WumpusQ.Wumbley Really? I was hoping for a particular file in procfs. – extremeaxe5 Aug 12 '18 at 23:28
  • I went looking for the API, I believe I found it (SYMLOOP_MAX defined in POSIX <limits.h> and more dynamically, sysconf(_SC_SYMLOOP_MAX)) but it seems to be unimplemented in Linux. –  Aug 12 '18 at 23:51

1 Answers1

7

Looking at the 4.18 kernel sources, I see a constant named MAXSYMLINKS in include/linux/namei.h whose value is 40.

Reference: https://elixir.bootlin.com/linux/latest/source/include/linux/namei.h#L12

#include <linux/kernel.h>
#include <linux/path.h>
#include <linux/fcntl.h>
#include <linux/errno.h>

enum { MAX_NESTED_LINKS = 8 };

#define MAXSYMLINKS 40

Andy Dalton
  • 13,993