Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2040822rwl; Thu, 30 Mar 2023 05:20:49 -0700 (PDT) X-Google-Smtp-Source: AKy350Y25T9er/G2T1Pom2JeJmmBS5IMRmyRsvUhnAK0aoJEo+EEl0S94Fii1SOKB6pN4KuR+Hpk X-Received: by 2002:a17:90a:fd81:b0:240:c0df:64fc with SMTP id cx1-20020a17090afd8100b00240c0df64fcmr2194458pjb.2.1680178849018; Thu, 30 Mar 2023 05:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680178849; cv=none; d=google.com; s=arc-20160816; b=zp2uVD1Ps2PucDZOC5x40cvvjl88/htuHbL5RqjNpImE/HluERhV8DNhOiOf2hjUyQ /yCRmDfz03jPhURrwpk9Gz12ZhA4QRNb5ajUuJrR56P4vNqQPEzKop6409e4oZUGYmEp ZKwBKSeQ6Fy+bRCKoIdeoKVq/dQ3ngw0ZSBUpPNPhv33ZtiE71xLZccXe02yU5JOTvoV RdEJhwvvTjDVqZVADElD+3v9f/8/yjGxCDIK4mWfhgdEzMVBea6Mi4kagf2gSvLx7Ytg jgzd/VuOPdFEdsxYtCpGCuBJbOmCpJwWtGsucZM1XmBI2crD1GqxvAGytx6a6SPI5tTI LGOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=GiRnxJYGLZl9gkE3Btj0DPwx3kYOXRqdQVjP40JuFAY=; b=kbRILehEhvekJPFxmOzu5rbzEgA+zSDY1qtaMD2sObQGCIlcwzMvcQtKjruCHUSBo4 eJ2CTiG6+HXRi4tT3lWgNhbOw9tvex7xfZLwhJ2YAEebVd+UAEzUPfreUyT93kz2UGpR ecIa45oSt1mmI5F4ocd0K/SOihGLOlCKBt5Hj8WaYSXvDlkark+zBdbassUWDIXZ6Z7O 8Nohylr804lzIOaAThuitwPcaDI7FQraSzOV0bONxQhVsgEYuPQje9kXhbJUQqaJTYs5 CxlaMt58IcVGp8xOB3LJ2wxqTWMkdcpcdKlWftIGZZjujLIZSW8mw0yabR+p9Azina/m gEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F1ak3hFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp16-20020a17090b4a9000b0022962fb35b8si4200664pjb.133.2023.03.30.05.20.36; Thu, 30 Mar 2023 05:20:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F1ak3hFr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231398AbjC3MKJ (ORCPT + 99 others); Thu, 30 Mar 2023 08:10:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjC3MKI (ORCPT ); Thu, 30 Mar 2023 08:10:08 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D2744202; Thu, 30 Mar 2023 05:10:07 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id t10so75404019edd.12; Thu, 30 Mar 2023 05:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680178206; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=GiRnxJYGLZl9gkE3Btj0DPwx3kYOXRqdQVjP40JuFAY=; b=F1ak3hFr6X15BX5WccChl/IPbvU4a7NsfyYFRjtDQM6zmbxrqsLndm7btSBas8MJug 5tYIT50GpNMwK+mHzCvXXbZVNnOXh5Kqlpiz7/pvAOPxajXyiqpMrZM/SUUkzgNZPvEf cW1+Epw8vv8URa2lBH4luvQP9dCvDn+Nr/nENjnZdhJ136wYh7uJMEZvOUbZSDaCKf46 48uA6AavC3uxBWsja340ItGoXOtQjd5Is0gBDpjjpq39kHdTlu0bf1N4rgv/CrhMSoOT WRdXGG89dDMtxDhnM4gY5A1A+ScbIebdypev6ZMAag0pkpColvlhIu3fXpXsfusDWI1O mZ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680178206; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GiRnxJYGLZl9gkE3Btj0DPwx3kYOXRqdQVjP40JuFAY=; b=i8bCWKCf/kbGxxKQZ/hXz5Cra1hkj+7Ziq7bCehs0ZZyfkFbAEckWNcwpRxOCuWy97 th99z5Tmz8GICYfbWaHG3q5WEunBWXaKl2Zzvq1gCQXLP4N0QOT3424BHSObgnzFpp9H DilCzRu5sYv4OGsk6QVF7bwoDwqdYlJcaM1e51w9zv7fIMks8ZPuXK7/bgRlvelZk+YI kTc9t5AP44dFEcdcSBDl5N6CACm8xCeyG8wojOBHEqX2RZvXonuAa1FA+DwF+goDMAkt +kn4+wScbmhDCdgouVOTpUZbzGT8Fp3XskqUNnoTZQBNojJ1C2wizxq9xfqvTHztOrnW wVTQ== X-Gm-Message-State: AAQBX9de+xzZe30nhlOnWL9j7B8f0n66kWkGRqvdBKKPkIxj/5K8xFxZ 6jXG4QQcl/ZN6oaLBzpOjQ== X-Received: by 2002:a17:907:9725:b0:93f:9594:d97d with SMTP id jg37-20020a170907972500b0093f9594d97dmr20670831ejc.14.1680178205762; Thu, 30 Mar 2023 05:10:05 -0700 (PDT) Received: from p183 ([46.53.250.0]) by smtp.gmail.com with ESMTPSA id i11-20020a170906264b00b009255b14e91dsm17519658ejc.46.2023.03.30.05.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 05:10:05 -0700 (PDT) Date: Thu, 30 Mar 2023 15:10:03 +0300 From: Alexey Dobriyan To: Joe Lawrence Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Josh Poimboeuf , Miroslav Benes , Petr Mladek , Marcos Paulo de Souza Subject: Re: [PATCH v7 00/10] livepatch: klp-convert tool Message-ID: <4ce29654-4e1e-4680-9c25-715823ff5e02@p183> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Joe Lawrence wrote: > +static int update_strtab(struct elf *elf) > +{ > > + buf = malloc(new_size); > + if (!buf) { > + WARN("malloc failed"); > + return -1; > + } > + memcpy(buf, (void *)strtab->data, orig_size); This code is called realloc(). :-) > +static int write_file(struct elf *elf, const char *file) > +{ > > + fd = creat(file, 0664); > + e = elf_begin(fd, ELF_C_WRITE, NULL); elf_end() doesn't close descriptor, so there is potentially corrupted data. There is no unlink() call if writes fail as well. > +void elf_close(struct elf *elf) > +{ > + > + if (elf->fd > 0) > + close(elf->fd); Techically, it is "fd >= 0". > +filechk_klp_map = \ > + echo "klp-convert-symbol-data.0.1"; \ > + echo "*vmlinux"; \ > + $(NM) -f posix vmlinux | cut -d\ -f1; \ > + sort $(MODORDER) $(MODULES_LIVEPATCH) | \ This probably should be "LC_ALL=C sort" for speed and reproducibility (?).