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, 18 Feb 2015 00:27:51 +0000
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Joe Perches <joe@...ches.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ipc: Remove uses of return value of seq_printf/seq_puts

On Tue, Feb 17, 2015 at 04:09:44PM -0800, Joe Perches wrote:
> On Tue, 2015-02-17 at 23:16 +0000, Al Viro wrote:
> > Most of the time checking return value of seq_...() is better replaced with
> > not doing that.  And "must check return value and Do Something(tm)" is too
> > strong habit for enough people to cause recurring trouble.
> 
> Does SEQ_SKIP still have value?

Yes, it does, but it's not an error - it's an equivalent of "empty the buffer
before returning".  Basically, it's "I've decided that this entry shouldn't
produce anything".  Look at the caller:
                error = m->op->show(m, p);
                if (error < 0)
                        break;
                if (unlikely(error)) {
                        error = 0;
                        m->count = 0;
                }
Negatives are hard errors.  Positives (without distinction) are equivalent
to zero, except that we discard anything that might've been produced by
this call of ->show().  Another call site (one when we are trying to pack
more into buffer that already has some records in it) is
                size_t offs = m->count;
...
                err = m->op->show(m, p);
                if (seq_has_overflowed(m) || err) {
                        m->count = offs;
                        if (likely(err <= 0))
                                break;
                }
IOW, here we treat positive as "discard everything produced by this call of
->show(), ignore seq_has_overflowed() it might have triggered".  Might as
well have done
	if (err > 0) {
		m->count = offs; /* seq_has_overflowed() is false now */
		err = 0;
	}
	if (seq_has_overflowed(m) || err < 0) {
		m->count = offs;
		break;
	}
except that it'd cost more that way.

In principle, we could've provided seq_discard(m), but that would've required
keeping a snapshot of ->count in another field of struct seq_file, and that -
for a very rarely used thing.  And keep in mind that hard errors need to
be reported anyway, so it's not as if we could realistically make ->show()
return void.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ