All of lore.kernel.org
 help / color / mirror / Atom feed
* Advisory file locking behaviour of bpf_link (and others?)
@ 2020-08-25 13:38 Lorenz Bauer
  2020-08-25 18:06 ` Alexei Starovoitov
  0 siblings, 1 reply; 5+ messages in thread
From: Lorenz Bauer @ 2020-08-25 13:38 UTC (permalink / raw)
  To: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko; +Cc: kernel-team

Hi,

I was playing around a bit, and noticed that trying to acquire an
exclusive POSIX record lock on a bpf_link fd fails. I've traced this
to the call to anon_inode_getfile from bpf_link_prime which
effectively specifies O_RDONLY on the bpf_link struct file. This makes
check_fmode_for_setlk return EBADF.

This means the following:
* flock(link, LOCK_EX): works
* fcntl(link, SETLK, F_RDLCK): works
* fcntl(link, SETLK, F_WRLCK): doesn't work

Especially the discrepancy between flock(EX) and fcntl(WRLCK) has me
puzzled. Should fcntl(WRLCK) work on a link?

program fds are always O_RDWR as far as I can tell (so all locks
work), while maps depend on map_flags.

Best
Lorenz

-- 
Lorenz Bauer  |  Systems Engineer
6th Floor, County Hall/The Riverside Building, SE1 7PB, UK

www.cloudflare.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-26 13:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-25 13:38 Advisory file locking behaviour of bpf_link (and others?) Lorenz Bauer
2020-08-25 18:06 ` Alexei Starovoitov
2020-08-26  7:50   ` Lorenz Bauer
2020-08-26  9:22     ` Toke Høiland-Jørgensen
2020-08-26 13:32       ` Lorenz Bauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.