From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD417C2D0E5 for ; Mon, 30 Mar 2020 13:49:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9875B2073B for ; Mon, 30 Mar 2020 13:49:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eJfWfVdy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbgC3NtB (ORCPT ); Mon, 30 Mar 2020 09:49:01 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:44808 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgC3NtB (ORCPT ); Mon, 30 Mar 2020 09:49:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585576140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HSw3QlrMrON7y7fHzkcW8HIq5O2cHFtMe9BVjREpIm4=; b=eJfWfVdynNV0GZn0//2roTZVYpFgrGMuFa8NI7nG2q481A1Aa9ISof9VtUGrqlrw4yTun7 yC/EpF/KNjpgYzx/QNwqU2JmpDDVb9cvbEg0mBdwCSrAXHRIBjvL3tvfXYwoGWitGpCq8U kr7p8nqngMnKV763eqNXwiADt3/whMU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-TNqMpqGlMOiLGl62BuEfdw-1; Mon, 30 Mar 2020 09:48:58 -0400 X-MC-Unique: TNqMpqGlMOiLGl62BuEfdw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5EE88190B2AE; Mon, 30 Mar 2020 13:48:57 +0000 (UTC) Received: from work (unknown [10.40.192.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65A796031F; Mon, 30 Mar 2020 13:48:56 +0000 (UTC) Date: Mon, 30 Mar 2020 15:48:53 +0200 From: Lukas Czerner To: Jan Kara Cc: Ted Tso , linux-ext4@vger.kernel.org Subject: Re: [PATCH 1/2] ext2fs: Fix error checking in dx_link() Message-ID: <20200330134853.3icodnii6knomwch@work> References: <20200330090932.29445-1-jack@suse.cz> <20200330090932.29445-2-jack@suse.cz> <20200330132440.4kwdwhgsrsnif6ju@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200330132440.4kwdwhgsrsnif6ju@work> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Mar 30, 2020 at 03:24:40PM +0200, Lukas Czerner wrote: > On Mon, Mar 30, 2020 at 11:09:31AM +0200, Jan Kara wrote: > > dx_lookup() uses errcode_t return values. As such anything non-zero is > > an error, not values less than zero. Fix the error checking to avoid > > crashes on corrupted filesystems. > > Looks good, thanks. > > Signed-off-by: Lukas Czerner of course that should be Reviewed-by: Lukas Czerner -Lukas > > > > > Signed-off-by: Jan Kara > > --- > > lib/ext2fs/link.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c > > index 6f523aee718c..7b5bb022117c 100644 > > --- a/lib/ext2fs/link.c > > +++ b/lib/ext2fs/link.c > > @@ -571,7 +571,7 @@ static errcode_t dx_link(ext2_filsys fs, ext2_ino_t dir, > > dx_info.namelen = strlen(name); > > again: > > retval = dx_lookup(fs, dir, diri, &dx_info); > > - if (retval < 0) > > + if (retval) > > goto free_buf; > > > > retval = add_dirent_to_buf(fs, > > -- > > 2.16.4 > > >