Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5322159ybf; Wed, 4 Mar 2020 22:18:17 -0800 (PST) X-Google-Smtp-Source: ADFU+vt1XpgzqRq1F0raC1oO6Ce9VPThcDcO06cxUWM0qT0DdtbmhjxX+2nCf3XTszRZpUcD8oug X-Received: by 2002:a9d:a16:: with SMTP id 22mr5183018otg.31.1583389097372; Wed, 04 Mar 2020 22:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583389097; cv=none; d=google.com; s=arc-20160816; b=KFzo929K+ZZ79P9SQisXcE0tFNgHTC8tRu3qGEbyfpRY0T67Box+cYNx4OzxQOYOeE UjNGznGbJClmTodDH0BEVe+tfY73ZfKLFbp5iYIDypn+WpusTuAbK5sgPefsK+fJ0PkV +kn8BW1yu5EENGSpg9h0CFXtzAqLEn0kJE1o2kFhZ/BKlsh/INbql/nKRwjzQaNmTXeN oI60oyZ4zxqaShnygTyrnjnD5vreMn6UJ0Rh+0Hzd+JybIykfF08wOlrnjQI1SRI/Ivr 9qXnTfXxaHp0yxxD1f9xyPDZr5uJ3fI8WJJdCBmGPMwayP/8h1ntAjD5INFWztnrEKgh +xRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=E6xu+5UxvlRGBObBERKpxsZYB1W/AKSUkfhw6bHB3FM=; b=vK57xrftEFoZYIw9FkbgeBDtBZTg2MCU9LEjqzpvp0nsY8vrU5RsgtCLEjP6CEaSFa +qoXUYpmx3Q7B7/D/5mj/CNgD1SxwcWZo+SnkPHswZlbsIi6BpSIyselWi13peaGevAS nZ5+puzQD1hO88Qx+N+e56pTmGqd9zajK6Awu/lL9izZxQIl85iJrHfmr5MBPEtAEEvu vJkkKtu7cC2xT1u9pPahH19IKpD7/dqGRPO/awn+YxMx+KjblJniE51ek6vgCd8cTKD1 IzYVt0X8nsTuvj9Ge7Qz7+heXNCJnN5rr2azEY+nkrJWtB0y3ui1pbYYagM+iG21UK/2 zrVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O84g+I4f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y24si1638487oih.7.2020.03.04.22.18.05; Wed, 04 Mar 2020 22:18:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O84g+I4f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725861AbgCEGRf (ORCPT + 99 others); Thu, 5 Mar 2020 01:17:35 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54717 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725818AbgCEGRe (ORCPT ); Thu, 5 Mar 2020 01:17:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583389053; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E6xu+5UxvlRGBObBERKpxsZYB1W/AKSUkfhw6bHB3FM=; b=O84g+I4fr0GoImXk88uidBkTz5IvKo/vJCp327xGHPp+iHmP92GC517TstQcMQgdEvXqCl 9dpMuWXzSMV/aP1hepzuaETYTAERVHNmqHHzInyxGVaBZCTmoGJNEmmnwor+l5gZpI+OKI Z1cItBgRbkVCLw8dBFjW0gS7/TGdhWE= 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-310-fVRD406aNJWJE02WSIVI_w-1; Thu, 05 Mar 2020 01:17:30 -0500 X-MC-Unique: fVRD406aNJWJE02WSIVI_w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C553813E4; Thu, 5 Mar 2020 06:17:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1A1319C6A; Thu, 5 Mar 2020 06:17:29 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A12DA1809563; Thu, 5 Mar 2020 06:17:29 +0000 (UTC) Date: Thu, 5 Mar 2020 01:17:29 -0500 (EST) From: Vladis Dronov To: joeyli Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <1322502214.13237657.1583389049605.JavaMail.zimbra@redhat.com> In-Reply-To: <20200305060123.GS16878@linux-l9pv.suse> References: <20200304154936.24206-1-vdronov@redhat.com> <20200305060123.GS16878@linux-l9pv.suse> Subject: Re: [PATCH v2] efi: fix a race and a buffer overflow while reading efivars via sysfs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.204.88, 10.4.195.7] Thread-Topic: fix a race and a buffer overflow while reading efivars via sysfs Thread-Index: yZpuewxX2bAsD2i1VoJ9lfrdXAYJYw== X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Joey, all, > > - var->DataSize = 1024; > > - if (efivar_entry_get(entry, &entry->var.Attributes, > > - &entry->var.DataSize, entry->var.Data)) > > + ret = efivar_entry_get(entry, &var->Attributes, &datasize, var->Data); > > + var->DataSize = size; > > The size is indeterminate here. I think that it should uses datasize? > var->DataSize = datasize; Indeed, my mistake. Thank you much! I will fix it in the v3 patchset I'm currently composing. Best regards, Vladis Dronov | Red Hat, Inc. | The Core Kernel | Senior Software Engineer