lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 22 Apr 2020 08:09:22 +0200
From:   Christoph Hellwig <hch@....de>
To:     Al Viro <viro@...iv.linux.org.uk>
Cc:     Christoph Hellwig <hch@....de>, Kees Cook <keescook@...omium.org>,
        Iurii Zaikin <yzaikin@...gle.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        linux-fsdevel@...r.kernel.org, netdev@...r.kernel.org,
        bpf@...r.kernel.org
Subject: Re: [PATCH 5/5] sysctl: pass kernel pointers to ->proc_handler

On Wed, Apr 22, 2020 at 03:46:26AM +0100, Al Viro wrote:
> > Better allocate count + 1 bytes here, that way a lot of insanity in the
> > instances can be simply converted to snprintf().  Yes, I know it'll bring
> > the Church Of Avoiding The Abomination Of Sprintf out of the woodwork,
> > but...
> 
> FWIW, consider e.g. net/sunrpc/sysctl.c:
> 
> Nevermind that the read side should be simply
> 		int err = proc_douintvec(table, write, buffer, lenp, ppos);
> 		/* Display the RPC tasks on writing to rpc_debug */
> 		if (!err && strcmp(table->procname, "rpc_debug") == 0)
> 			rpc_show_tasks(&init_net);
> 		return err;
> the write side would become
> 		len = snprintf(buffer, *lenp + 1, "0x%04x\n",
> 				*(unsigned int *)table->data);
> 		if (len > *lenp)
> 			len = *lenp;
> 		*lenp -= len;
> 		*ppos += len;
> 		return 0;
> and I really wonder if lifting the trailing boilerplate into the caller would've
> been better.  Note that e.g. gems like
>                         if (!first)
>                                 err = proc_put_char(&buffer, &left, '\t');
>                         if (err)
>                                 break;
>                         err = proc_put_long(&buffer, &left, lval, neg);
>                         if (err)
>                                 break;
> are due to lack of snprintf-to-user; now, lose the "to user" part and we suddenly
> can be rid of that stuff...

That sounds pretty sensible, but can we do that as an extra step?
That is in merge window N just move to passing kernel pointers, check
for fall out.  In merge window N + 1 start allocatin the extra byte and
switch at least the common helpers for snprintf?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ