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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1472C05027 for ; Mon, 23 Jan 2023 16:09:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20F80855A1; Mon, 23 Jan 2023 17:09:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eA1xJu2u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD5D385624; Mon, 23 Jan 2023 17:09:22 +0100 (CET) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1AC0E854D2 for ; Mon, 23 Jan 2023 17:09:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ivan.khoronzhuk@gmail.com Received: by mail-wr1-x42c.google.com with SMTP id e3so11262471wru.13 for ; Mon, 23 Jan 2023 08:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=veNqGaHxvfpjLRQFGmas4LzwnhEekClgwEnaYJMhPe4=; b=eA1xJu2uK2hWtrE7SkPcPO5R8iVabSMAz9xmzI9c438frNuIKzLmaJe+MwkidlUwX9 sJQPZw4nTBIzqqUf30Z0fONXtFOzyPi70hJnMEdgMuqQnr1BuGGK6vVJV51MyQQwQjnE TlNGd6+w4OizC6auxDHOOjngVq25vDxJg6pcz3tW2bfk0SSLx4NVXfs1fkS6lXvF9ZOC sqLKf0pqQTnq5DteIOdZCJxGFD1UzA2g4M6BX7+b/MAEXq3Mu1ybkRjPH4FW5nJNVKPn a0uWOTF6UTSsJgWX/9I5BgtZUFr3Sp3A1NU8eZ4gIVw0cbmXle/7D+/1MHYFqC7PTU85 i8KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=veNqGaHxvfpjLRQFGmas4LzwnhEekClgwEnaYJMhPe4=; b=UiEep9hnlqIZ/APk2HxbA/L/K8BtNmFYfn9eGkvt1CJ8X1CjYYuWhBoy54XsGodfdU W+x9/WtiejZsAhk+PisfjTCH3Maqoi62eaFMqz4JIWE8mUqjFIFt7KnV6Y01hlvWdAZd ibxWiLNnQSPFalvFlKgMncTw4YUQBVW8lFfDG1IlASCOWK1SJT6juddJvE6LxyMbh+aE ThCHmq7e5nuJcVmPyPg49UhzSi8xytczOUWugsnddgVEh3pobIKDyjWb/h5myW3Dltdh L611WvjImbQ38A+8iAen0zI1lvoYAwiA7LEEFDBHkQxNPewTy1JS31VczGpLDRuYFcfL r5YA== X-Gm-Message-State: AFqh2kreZV/0PUl0JB1TT1B7PkJfIPMcRfWRs1zoKeInpK7VkHdx7kZN 7bpzotS8zI9Y8wul2VfPFck= X-Google-Smtp-Source: AMrXdXvUYmZ/tgmKh0h2gMwfF7VGsIUtseh95lMEkJkGg0ejkyqzAli+DeRPoFuUpsP8bUXDpW8nEA== X-Received: by 2002:a5d:6792:0:b0:2be:5393:c5bc with SMTP id v18-20020a5d6792000000b002be5393c5bcmr11115579wru.7.1674490156587; Mon, 23 Jan 2023 08:09:16 -0800 (PST) Received: from ikhor ([46.211.163.169]) by smtp.gmail.com with ESMTPSA id h10-20020a05600016ca00b00267bcb1bbe5sm5200289wrf.56.2023.01.23.08.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 08:09:16 -0800 (PST) Date: Mon, 23 Jan 2023 18:09:12 +0200 From: Ivan Khoronzhuk To: Jens Wiklander Cc: igor.opaniuk@gmail.com, u-boot@lists.denx.de Subject: Re: [PATCH v2] common: avb_verify: prevent opening incorrect session Message-ID: Mail-Followup-To: Jens Wiklander , igor.opaniuk@gmail.com, u-boot@lists.denx.de References: <20230122024130.4028621-1-ivan.khoronzhuk@gmail.com> <20230123145129.4063929-1-ivan.khoronzhuk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Mon, Jan 23, 2023 at 04:34:33PM +0100, Jens Wiklander wrote: >On Mon, Jan 23, 2023 at 04:51:29PM +0200, Ivan Khoronzhuk wrote: >> The arg->session is not valid if arg->ret != NULL, so can't be >> assigned. Leave retry for just "ret" error to save same behaviour. >> >> Signed-off-by: Ivan Khoronzhuk >> --- >> common/avb_verify.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/common/avb_verify.c b/common/avb_verify.c >> index 0520a71455..97451592f5 100644 >> --- a/common/avb_verify.c >> +++ b/common/avb_verify.c >> @@ -619,10 +619,14 @@ static int get_open_session(struct AvbOpsData *ops_data) >> memset(&arg, 0, sizeof(arg)); >> tee_optee_ta_uuid_to_octets(arg.uuid, &uuid); >> rc = tee_open_session(tee, &arg, 0, NULL); >> - if (!rc) { >> - ops_data->tee = tee; >> - ops_data->session = arg.session; >> - } >> + if (rc) >> + continue; >> + >> + if (arg.ret) >> + return -EIO; >> + >> + ops_data->tee = tee; >> + ops_data->session = arg.session; >> } >> >> return 0; > >It looks like this function is still slightly broken. The function >should, if I understand it correctly, return usable tee and session >pointers on success, else return an error code. The unconditional return >0 at the end doesn't seem right. > >Thanks, >Jens It doesn't return, it loops infinitely... Yes, it looks so, but it's how it works. I don't see a reason why the function must loop trying to open the session that potentially never will be opened. But this is how it's implemented and I didn't wont to change this behaviour that can have some "sacral" roots, only add a fix I bother, I've mentioned it in the comment. Better would be drop this loop ofc and add the following: + if (ret || arg.ret) + return -EIO; I can do this in v3 if you don't mind. -- Regards, Ivan Khoronzhuk