On 10/23/20 9:25 AM, Rolf Eike Beer wrote: >> +#define O_NONBLOCK_OLD 000200004 >> +#define O_NONBLOCK_MASK_OUT (O_NONBLOCK_OLD & ~O_NONBLOCK) >> +static int FIX_O_NONBLOCK(int flags) >> +{ >> + if (flags & O_NONBLOCK_MASK_OUT) { >> + struct task_struct *tsk = current; >> + pr_warn("%s(%d) uses old O_NONBLOCK value. " >> + "Please recompile the application.\n", >> + tsk->comm, tsk->pid); >> + } >> + return flags & ~O_NONBLOCK_MASK_OUT; >> +} > > This will also trigger if I just pass 0x4 in flags, no? The check should be > > if ((flags & O_NONBLOCK_OLD) == O_NONBLOCK_OLD) RIGHT! That's a very good point. I was thinking about what would happen if over time a new (unrelated) define gets created which then gets 0x4 as value. My code would then have wrongly modified it. I'll fix this. > because that would correctly reject a bare 0x4, at least I hope that this > would already happen with the strict checking you mentioned. > > Would a pr_warn_once make sense? Otherwise your log may get flooded by them if > e.g. sudo is the problem and my nagios comes every minute to check something. I like the idea. Helge
Attachment:
signature.asc
Description: OpenPGP digital signature