lkml.org 
[lkml]   [2020]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.19 03/89] cgroup, netclassid: periodically release file_lock on classid updating
Hi!

> From: Dmitry Yakunin <zeil@yandex-team.ru>
>
> [ Upstream commit 018d26fcd12a75fb9b5fe233762aa3f2f0854b88 ]
...
> Now update is non atomic and socket may be skipped using calls:
>
> dup2(oldfd, newfd);
> close(oldfd);
>
> But this case is not typical. Moreover before this patch skip is possible
> too by hiding socket fd in unix socket buffer.

Dunno. This makes interface even more interesting.

> +
> static int update_classid_sock(const void *v, struct file *file, unsigned n)
> {
> int err;
> + struct update_classid_context *ctx = (void *)v;
> struct socket *sock = sock_from_file(file, &err);
>
...
> + if (--ctx->batch == 0) {
> + ctx->batch = UPDATE_CLASSID_BATCH;
> + return n + 1;
> + }
> return 0;
> }

We take "const void *" and then write to it. That's asking for
trouble... right? Should the const annotation be removed, at least for
sake of humans trying to understand the code?

Best regards,
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-03-18 10:03    [W:0.284 / U:4.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site