{"thread":{"id":"53926","subject":"problem about 'git am --rej'","startedAt":"2020-07-27T11:51:05Z","lastAt":"2020-07-27T12:05:53Z","messageCount":2,"participants":["yangerkun"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"402130","messageId":"ebec6423-20f9-d866-1d07-9e6c94ce845c@huawei.com","threadId":"53926","inReplyTo":null,"subject":"problem about 'git am --rej'","fromName":"yangerkun","fromEmail":"yangerkun@huawei.com","sentAt":"2020-07-27T11:50:53Z","receivedAt":"2020-07-27T11:51:05Z","isPatch":false,"sender":{"key":"yangerkun@huawei.com","avatar":null},"body":"Hi,\n\nTrying 'git am --rej'(git version 2.25.4) to apply patch eead1c2ea250 \n(\"netlabel: cope with NULL catmap\") with linux stable branch \n4.4.y(git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git), \nit seems the patch has been applied with wrong function(should be \ncipso_v4_parsetag_rbm or cipso_v4_parsetag_rng, but \ncipso_v4_parsetag_enum). Does this a bug or a expected result?\n\n\n\n\n[xxx@code-website linux-stable]$ git am \n0001-netlabel-cope-with-NULL-catmap.patch --rej\nApplying: netlabel: cope with NULL catmap\nChecking patch net/ipv4/cipso_ipv4.c...\nHunk #1 succeeded at 1435 (offset 177 lines).\nerror: while searching for:\n                         return ret_val;\n                 }\n\n                 secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n         }\n\n         return 0;\n\nerror: patch failed: net/ipv4/cipso_ipv4.c:1439\nChecking patch net/ipv6/calipso.c...\nerror: net/ipv6/calipso.c: does not exist in index\nChecking patch net/netlabel/netlabel_kapi.c...\nerror: while searching for:\n         if ((off & (BITS_PER_LONG - 1)) != 0)\n                 return -EINVAL;\n\n         if (off < catmap->startbit) {\n                 off = catmap->startbit;\n                 *offset = off;\n\nerror: patch failed: net/netlabel/netlabel_kapi.c:734\nApplying patch net/ipv4/cipso_ipv4.c with 1 reject...\nHunk #1 applied cleanly.\nRejected hunk #2.\nApplying patch net/netlabel/netlabel_kapi.c with 1 reject...\nRejected hunk #1.\nPatch failed at 0001 netlabel: cope with NULL catmap\nhint: Use 'git am --show-current-patch' to see the failed patch\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\".\n[xxx@code-website linux-stable]$ git diff\ndiff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c\nindex 0e83c5b08e0e..375733b96bdf 100644\n--- a/net/ipv4/cipso_ipv4.c\n+++ b/net/ipv4/cipso_ipv4.c\n@@ -1435,7 +1435,8 @@ static int cipso_v4_parsetag_enum(const struct \ncipso_v4_doi *doi_def,\n                         return ret_val;\n                 }\n\n-               secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n+               if (secattr->attr.mls.cat)\n+                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n         }\n\n         return 0;\n\n\n"},{"id":"402131","messageId":"1698860c-d0cf-fd54-b143-419bdd9d9185@huawei.com","threadId":"53926","inReplyTo":"ebec6423-20f9-d866-1d07-9e6c94ce845c@huawei.com","subject":"Re: problem about 'git am --rej'","fromName":"yangerkun","fromEmail":"yangerkun@huawei.com","sentAt":"2020-07-27T12:05:44Z","receivedAt":"2020-07-27T12:05:53Z","isPatch":false,"sender":{"key":"yangerkun@huawei.com","avatar":null},"body":"Sorry for that, linux-4.4.y has included this patch.\n\nThe problem actually is that:\nWe reset to the commit before eead1c2ea250 (\"netlabel: cope with NULL\ncatmap\") on linux-4.4.y, and apply this patch, the results show as\nbelow. Fuction 'cipso_v4_parsetag_rbm' and 'cipso_v4_parsetag_enum' has \nbeen changed, but the really function should be changed is \n'cipso_v4_parsetag_rbm' and 'cipso_v4_parsetag_rng'.\n\ndiff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c\nindex 98ed5e43ab7b..209876615461 100644\n--- a/net/ipv4/cipso_ipv4.c\n+++ b/net/ipv4/cipso_ipv4.c\n@@ -1343,7 +1343,8 @@ static int cipso_v4_parsetag_rbm(const struct \ncipso_v4_doi *doi_def,\n                         return ret_val;\n                 }\n\n-               secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n+               if (secattr->attr.mls.cat)\n+                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n         }\n\n         return 0;\n@@ -1434,7 +1435,8 @@ static int cipso_v4_parsetag_enum(const struct \ncipso_v4_doi *doi_def,\n                         return ret_val;\n                 }\n\n-               secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n+               if (secattr->attr.mls.cat)\n+                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n         }\n\n         return 0;\ndiff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c\nindex bfa2b6d5b5cf..25ab12e25e05 100644\n--- a/net/netlabel/netlabel_kapi.c\n+++ b/net/netlabel/netlabel_kapi.c\n@@ -605,6 +605,12 @@ int netlbl_catmap_getlong(struct netlbl_lsm_catmap \n*catmap,\n         if ((off & (BITS_PER_LONG - 1)) != 0)\n                 return -EINVAL;\n\n+       /* a null catmap is equivalent to an empty one */\n+       if (!catmap) {\n+               *offset = (u32)-1;\n+               return 0;\n+       }\n+\n         if (off < catmap->startbit) {\n                 off = catmap->startbit;\n                 *offset = off;\n\n\n\n\n在 2020/7/27 19:50, yangerkun 写道:\n> Hi,\n> \n> Trying 'git am --rej'(git version 2.25.4) to apply patch eead1c2ea250 \n> (\"netlabel: cope with NULL catmap\") with linux stable branch \n> 4.4.y(git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git), \n> it seems the patch has been applied with wrong function(should be \n> cipso_v4_parsetag_rbm or cipso_v4_parsetag_rng, but \n> cipso_v4_parsetag_enum). Does this a bug or a expected result?\n> \n> \n> \n> \n> [xxx@code-website linux-stable]$ git am \n> 0001-netlabel-cope-with-NULL-catmap.patch --rej\n> Applying: netlabel: cope with NULL catmap\n> Checking patch net/ipv4/cipso_ipv4.c...\n> Hunk #1 succeeded at 1435 (offset 177 lines).\n> error: while searching for:\n>                          return ret_val;\n>                  }\n> \n>                  secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n>          }\n> \n>          return 0;\n> \n> error: patch failed: net/ipv4/cipso_ipv4.c:1439\n> Checking patch net/ipv6/calipso.c...\n> error: net/ipv6/calipso.c: does not exist in index\n> Checking patch net/netlabel/netlabel_kapi.c...\n> error: while searching for:\n>          if ((off & (BITS_PER_LONG - 1)) != 0)\n>                  return -EINVAL;\n> \n>          if (off < catmap->startbit) {\n>                  off = catmap->startbit;\n>                  *offset = off;\n> \n> error: patch failed: net/netlabel/netlabel_kapi.c:734\n> Applying patch net/ipv4/cipso_ipv4.c with 1 reject...\n> Hunk #1 applied cleanly.\n> Rejected hunk #2.\n> Applying patch net/netlabel/netlabel_kapi.c with 1 reject...\n> Rejected hunk #1.\n> Patch failed at 0001 netlabel: cope with NULL catmap\n> hint: Use 'git am --show-current-patch' to see the failed patch\n> When you have resolved this problem, run \"git am --continue\".\n> If you prefer to skip this patch, run \"git am --skip\" instead.\n> To restore the original branch and stop patching, run \"git am --abort\".\n> [xxx@code-website linux-stable]$ git diff\n> diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c\n> index 0e83c5b08e0e..375733b96bdf 100644\n> --- a/net/ipv4/cipso_ipv4.c\n> +++ b/net/ipv4/cipso_ipv4.c\n> @@ -1435,7 +1435,8 @@ static int cipso_v4_parsetag_enum(const struct \n> cipso_v4_doi *doi_def,\n>                          return ret_val;\n>                  }\n> \n> -               secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n> +               if (secattr->attr.mls.cat)\n> +                       secattr->flags |= NETLBL_SECATTR_MLS_CAT;\n>          }\n> \n>          return 0;\n> \n\n"}]}