Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1904451imm; Sun, 8 Jul 2018 14:06:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJb06SGuLf5Dmt1/sPUpBFyOtF/Y4QHnJbiZFcD6JhBUHqszNogMosIvlRvqnUO+7CDSSA X-Received: by 2002:aa7:818b:: with SMTP id g11-v6mr18686118pfi.50.1531084006986; Sun, 08 Jul 2018 14:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531084006; cv=none; d=google.com; s=arc-20160816; b=Xth2wp667TIsI7MnRRH8yLXuWSmRPbhYQNRyOzDkcgCuTngsYx8UhRuG41ylPJ6XLH I9akfVvLhT5MX2DsAccwJn6MImO0cW/Ij1ARdMrPXX+OY9Cu7M2cj44go8uZALQzda62 iF4NfuBwfXF9VYvxeLVKw2oWpVTiO6jVoShjtFTGDlls5hJcdcingw6bsoSnAEPAlT+t ouPZomqmAEGLgJQ7OMm2bEW88UsyJ1YPaCB+xzYFqDF/Q8pJSyY4Ir4hBdG4/Wxdkibf jOEhnAVVy1eqBHhq5HKcw25z7Lom1P1nQczsDWxR32V98gtEd1NZZEHiOtR8U0CxDfzH nNTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8aM1k2j6Ljs8a7QqghmRuJpiCg7PJFBEcFzzSa0UZCI=; b=v+ake9/UY9LN2GqSkixjnW6Zx3xk2/GYwrFzbBGcV0MYrhY5IgnB/JbdMawLhlkmeY XSxzDVHTJzDcXdixtITpPoNwIQXcSzf/rcYTxd1iac/uR+KXwPenWNTnHQOxfHKIlrn7 8MepnU3SKAPybTyp9s5GbocfP2Tvgwt48azvfLE4wlka+Do7qpSwpn0D9Rr8oCBgipTr jyePC/gsG+mCAtN8LaeGIgvUZEkQaXLhJ8TIV8Wq2Fuf4xU7QY3KVNDOHB612tB+1fVE +6DQBgrXnaFHnwAiAmEf0NxlIlR7BjXaXz7M8LgUSPaOjZTPJNMHcArE/mMMamxzXRl8 3bLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="uShBzQj/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13-v6si12718536pgr.291.2018.07.08.14.06.32; Sun, 08 Jul 2018 14:06:46 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="uShBzQj/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933512AbeGHVFu (ORCPT + 99 others); Sun, 8 Jul 2018 17:05:50 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:45471 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933292AbeGHVFq (ORCPT ); Sun, 8 Jul 2018 17:05:46 -0400 Received: by mail-pf0-f194.google.com with SMTP id i26-v6so719223pfo.12; Sun, 08 Jul 2018 14:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8aM1k2j6Ljs8a7QqghmRuJpiCg7PJFBEcFzzSa0UZCI=; b=uShBzQj/LW44wtCFABhr9F/KPcDMNPU5VnuDHYdIpZocbFBYuwstdukhag/nOAwJBO jtgspGdaijlzeIGeS05UkZ10jPS9mc7eU85uoPAy9lRNpmMQeRSXbtSxekz7uLZtZSQM 9ig4v48RntCcZFeBBMqABxurj956r4cyi1yUllKvg/FvcGHLj350mT51ceYND5dlr1Gy nDR3sxq3KVnOJHEqZIFEws42UitUkZL2zjbgIHYz/0SrsXGrJZUdpEdAiF3rqxdNPcQr vyyjb4JVKe0SrXGwNksmRpNkvvjPwkEPxn6KNQDKnqyAr7jyzlwLZkDXaRKhK7xTrBIw DyAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8aM1k2j6Ljs8a7QqghmRuJpiCg7PJFBEcFzzSa0UZCI=; b=t74oqkmkN0zi+omSyRiFt59v2ubiaOCd7MMNKnH7SH3zV157vq+aPQRKfiaW9fCwaS IPiydJy561wQMm+iEYT0H66YUVA14RrfUFTeraWRTliqjv4Apw5R/OMWZxZ9MCA2njg8 aLHkJuaLdTWVG1bgqLHh3pumvGBoMKg7CrU8rWWNnguGDjhtYRh2gFpSVWyrhNpe61M2 yyrC3O5jvjmDIXs622C6khiJdoL5OqfZ9qZqBP5VsK9Fou4WUfOHTLbWv9Me94/IoSN6 Lv1i+QvMMlNevpfRXlgndRaHCyJNZIK9RGL9m7xaY50HIAXYXNaywroV0WJBy6rL1eSU iHuQ== X-Gm-Message-State: APt69E0/73IdiWGZ2isgOi6nsP8P2ATeDCu+eFdFpkjWCOs8IfCxL8rq t9/1Us0jFyNNP+JBirpO03c= X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr16720117pgd.372.1531083946119; Sun, 08 Jul 2018 14:05:46 -0700 (PDT) Received: from sol.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id x68-v6sm23355681pfb.138.2018.07.08.14.05.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jul 2018 14:05:45 -0700 (PDT) From: Eric Biggers To: David Howells , Alexander Viro , linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH 16/18] fs_context: de-obfuscate control flow in fscontext_read() Date: Sun, 8 Jul 2018 14:01:52 -0700 Message-Id: <20180708210154.10423-17-ebiggers3@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180708210154.10423-1-ebiggers3@gmail.com> References: <20180708210154.10423-1-ebiggers3@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers Signed-off-by: Eric Biggers --- fs/fsopen.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/fsopen.c b/fs/fsopen.c index 1fbd8b0ca194b..dd38f6b65aace 100644 --- a/fs/fsopen.c +++ b/fs/fsopen.c @@ -161,20 +161,18 @@ static ssize_t fscontext_read(struct file *file, if (ret < 0) return ret; - ret = -ENODATA; - if (log->head != log->tail) { - index = log->tail & (logsize - 1); - p = log->buffer[index]; - need_free = log->need_free & (1 << index); - log->buffer[index] = NULL; - log->need_free &= ~(1 << index); - log->tail++; - ret = 0; + if (log->head == log->tail) { + mutex_unlock(&fc->uapi_mutex); + return -ENODATA; } + index = log->tail & (logsize - 1); + p = log->buffer[index]; + need_free = log->need_free & (1 << index); + log->buffer[index] = NULL; + log->need_free &= ~(1 << index); + log->tail++; mutex_unlock(&fc->uapi_mutex); - if (ret < 0) - return ret; ret = -EMSGSIZE; n = strlen(p); -- 2.18.0