From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51544 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932366AbeGIJfs (ORCPT ); Mon, 9 Jul 2018 05:35:48 -0400 From: David Howells In-Reply-To: <10670.1531128774@warthog.procyon.org.uk> References: <10670.1531128774@warthog.procyon.org.uk> <20180708210154.10423-4-ebiggers3@gmail.com> <20180708210154.10423-1-ebiggers3@gmail.com> Cc: dhowells@redhat.com, Eric Biggers , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Biggers Subject: Re: [PATCH 03/18] fs_context: fix detecting full log buffer MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10921.1531128946.1@warthog.procyon.org.uk> Date: Mon, 09 Jul 2018 10:35:46 +0100 Message-ID: <10922.1531128946@warthog.procyon.org.uk> To: unlisted-recipients:; (no To-header on input) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: David Howells wrote: > > When 'head' and 'tail' wrap around, 'log->head - log->tail' will be > > something like '4 - 252 = -248', and comparing that directly to the > > array size is wrong. Fix by casting to 'u8'. > > I think a better fix is to use CIRC_CNT() or CIRC_SPACE(). Or it would be - if CIRC_CNT() and CIRC_SPACE() didn't leave a hole in the buffer - but that's unnecessary if the head and tail counters can hold 2x the ring size or more. David