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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 75B94C433ED for ; Sat, 8 May 2021 04:01:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D4B361106 for ; Sat, 8 May 2021 04:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbhEHECW (ORCPT ); Sat, 8 May 2021 00:02:22 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:18794 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbhEHECV (ORCPT ); Sat, 8 May 2021 00:02:21 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FcYTF6Y6tzBtfD; Sat, 8 May 2021 11:58:41 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.177.72) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Sat, 8 May 2021 12:01:12 +0800 From: Zhen Lei To: Kees Cook , linux-kernel CC: Zhen Lei Subject: [PATCH 1/1] samples/seccomp: fix error return code in handle_req() Date: Sat, 8 May 2021 12:01:01 +0800 Message-ID: <20210508040101.2474-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.177.72] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unlike branch "if (lseek(mem, req->data.args[0], SEEK_SET) < 0)" above, 'ret' is overwritten by the previous 'ret = read(...)' statement. Therefore, 'ret' needs to be explicitly assigned to -1 here. Otherwise, 0 is incorrectly returned. Reported-by: Hulk Robot Signed-off-by: Zhen Lei --- samples/seccomp/user-trap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/seccomp/user-trap.c b/samples/seccomp/user-trap.c index 20291ec6489f..c1d4ca0284ba 100644 --- a/samples/seccomp/user-trap.c +++ b/samples/seccomp/user-trap.c @@ -164,6 +164,7 @@ static int handle_req(struct seccomp_notif *req, } if (lseek(mem, req->data.args[1], SEEK_SET) < 0) { + ret = -1; perror("seek"); goto out; } -- 2.25.1